I'm trying to use the reportlab library to write an 'annotation' on a pdf. I've successfully written new data to a pdf using reportlab, but I can't find any information on how I would create an annotation.
When I say annotation I am referring to TCPDF's annotate function. This creates a clickable and movable text object in the pdf.
https://tcpdf.org/examples/example_036/
There has to be a way to do this in python, but so far I haven't been able to find any information.
I've looked at this post and the related links posted in the accepted answer.
Add text to existing PDF document in Python
I've seen this tool for using php in python, but I can't get it to work correctly and It doesn't seem to have any support.
https://github.com/dnet/ppcg/blob/master/tcpdf_example.py
When I run the example I get a unreadable pdf with the text shown below:
<?
include('tcpdf/config/lang/eng.php');
include('tcpdf/tcpdf.php');
$v0 = new TCPDF('PDF_PAGE_ORIENTATION', 'PDF_UNIT', 'PDF_PAGE_FORMAT', 'true', 'UTF-8', 'false');
$v0->setFontSubsetting(False);
$v0->setAuthor('VSzA');
$v0->setCreator('PPCG');
$v0->setTitle('TCPDF in Python!?');
$v0->setPrintHeader(False);
$v0->setMargins(10, 10);
$v0->AddPage();
$v0->SetFont('dejavusans', 'B', 12);
$v0->Cell(0, 0, 'Hello Python');
$v0->Ln();
$v2 = $v0->GetX();
$v1 = $v0->GetY();
$v0->setXY(30, 30);
$v0->Cell(0, 0, 'GOTOs are bad');
$v3 = $v1 + 2.5;
$v0->setXY($v2, $v3);
$v0->Cell(0, 0, 'I can has PHP variables');
$v0->Output();
?>
This looks like the correct php code to create a pdf using TCPDF, but the code is being saved to the pdf file instead of being ran.
The conclusion I've came to as of now is to just send all my data from a python script over to a http server using php and creating my pdf on the server using TCPDF, and then sending the new pdf back to my python script to serve it to the end user. This just sounds unefficient so I'd prefer not to do it this way.
Any help would be appreciated! -Jake