I have a pdf that allows users to type in the data fields
I use pdftk to pre-populate this pdf with values from the database and this works perfectly
I then need to draw lines on the pdf to “strike through” the empty fields (so the ultimate recipient then knows that the particular section on the pdf if not required and not that the data is missing accidentally)
I use pdftk to populate the pdf
I then use the fpdf library to draw the lines on the appropriate pages/locations
The problem I have is that drawing the lines on the pdf flattens the output pdf, which means that the pdf cannot then be edited
I need the fields in the pdf to be editable
For what it is worth, the code snippet that draws the lines and saves the output is here (but as I say, the code works, it’s just that the output command is flattening the pdf so I can then later on edit the values on the pdf)
$sourceFile="test.pdf"
$outputFile="output.pdf";
$pdf = new Fpdi('P', 'mm', 'A4');
$pageCount = $pdf->setSourceFile($sourceFile);
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++)
{
$templateId = $pdf->importPage($pageNo);
$pdf->AddPage();
$pdf->useTemplate($templateId);
//now we add custom colours and lines
$pdf->SetDrawColor(0, 0, 0); // red
$pdf->SetLineWidth(3);
$pdf->Line(10,20,30,40);
}
}
$pdf->Output($outputFile,'F');
Hope this makes sense and that someone can help me, please 🙂