Add page to pdf in php
I need to add into pdf file one page after already existing first page and into this added page write text. I read somewhere, that Zend framework can do it, 开发者_如何学Cbut I have no idea how.
Thanks in advance for answer
First you need to create a pdf object and assign it to a variable:
$pdf = pdf_new();
Then you need to read your pdf file into the object:
pdf_open_file($pdf, "path/to/your/pdf/file.pdf");
Now, you add a (A4) page to the pdf object:
pdf_begin_page($pdf, 595, 842);
Then, before you can write text to the page, you need to grab a font:
$arial = pdf_findfont($pdf, "Arial", "host", 1);
And state that you will be using this font:
pdf_setfont($pdf, $arial, 10);
Now you can write text to the page with:
pdf_show_xy($pdf, "Text to write to the page.", 50, 750);
We're done with the page, so close it with:
pdf_end_page($pdf);
Finally, close and save the file:
pdf_close($pdf);
Credit: Generate PDFs with PHP Other good tutorials:
- How To: Create PDF With Php
- PDF Generation Using Only PHP - Part 2
精彩评论