В настоящее время я использую ZendPDF, и я создал тестовый файл PDF, который выглядел следующим образом при просмотре в виде текста. Когда я изменил текст «Это тест» на «Это супер тест» в самом файле PDF, я смог изменить окончательный файл PDF, и он открылся в foxit. Итак, скопируйте это и используйте C ++, чтобы заменить строку на то, что вы хотите. Я также смог заставить новый текст появляться только с помощью текстового редактора, скопировав этот материал F1 14 Tf.
php используется для вывода этого текста
<?php
require("inc/function.inc.php");
// start authorization check
require("inc/authcheckhdr.inc.php");
$pdf = new Zend_Pdf();
// Fetch the first page so you can draw on top of it.
$page = $pdf->pages[0] = $pdf->newPage('A4');
// Set font and text color.
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 14);
$page->setFillColor(new Zend_Pdf_Color_HTML('black'));
// Draw some text on top of the page at x,y
$page->drawText('This is a test', 72, 720);
// More drawing commands...
// Save the resulting PDF document. OR
$pdf->save('result.pdf');
// Render the resulting PDF and send it to the browser
$pdfDocument = $pdf->render();
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=result.pdf");
echo $pdfDocument;
?>
PDF-файл ...
%PDF-1.4
%âãÏÓ
1 0 obj
<</Type /Catalog /Version /1.4 /Pages 2 0 R /Names 7 0 R >>
endobj
2 0 obj
<</Type /Pages /Kids [3 0 R ] /Count 1 >>
endobj
3 0 obj
<</Type /Page /LastModified (D:20091231114504-08'00') /Resources <</ProcSet [/Text /PDF ] /Font <</F1 8 0 R >> >> /MediaBox [0 0 595 842 ]
/Contents [4 0 R ] /Parent 2 0 R >>
endobj
4 0 obj
<</Length 50 >>
stream
/F1 14 Tf
0 g
BT
72 620 Td
(This is a test) Tj
ET
/F1 14 Tf
0 g
BT
72 720 Td
(This is a super test) Tj
ET
endstream
endobj
5 0 obj
[]
endobj
6 0 obj
<</Names 5 0 R >>
endobj
7 0 obj
<</Dests 6 0 R >>
endobj
8 0 obj
<</Type /Font /Encoding /WinAnsiEncoding /Subtype /Type1 /BaseFont /Helvetica >>
endobj
xref
0 9
0000000000 65535 f
0000000015 00000 n
0000000091 00000 n
0000000149 00000 n
0000000341 00000 n
0000000441 00000 n
0000000460 00000 n
0000000494 00000 n
0000000528 00000 n
trailer
<</ID [<65386133343365653231383339346131> <64663632306233616663343536616332> ] /Size 9 /Root 1 0 R >>
startxref
625
%%EOF