Forum Moderators: coopster

Message Too Old, No Replies

Create multiple pages in one PDF file

         

woldie

2:24 pm on Apr 28, 2004 (gmt 0)

10+ Year Member



Hi there,

I'm using the PDFLib functions and just need advice on who has actually worked with these functions.

The reason I am asking is because I have created a PDF on the fly, however I have created just one page, but need to create another page within the PDF, like you press ctrl+enter to create a new page in a word doc.

Here's the code....can anyone help me on this one.

[PHP]

$pdf = pdf_new();
pdf_open_file($pdf);
pdf_set_info($pdf,'Creator','test.php');
pdf_set_info($pdf,'Author','woldie');
pdf_set_info($pdf,'Title','test');
pdf_begin_page($pdf,595,842);

$font = pdf_findfont($pdf,'Helvetica','host',0);
pdf_setfont($pdf,$font,12.0);

// logo placement
$pdfimage = pdf_open_image_file ( $pdf, "jpeg", "logo.jpg");

// $pdfimage = pdf_open_image_file($pdf, "jpeg", "test.jpg");
pdf_place_image($pdf, $pdfimage, 47, 750, 0.6);

$pdfimage = pdf_open_image_file ( $pdf, "jpeg", "sig.jpg");
pdf_place_image($pdf, $pdfimage, 57, 290, 0.6);

$text = "Our Reference:$QuoteNumber";
$todays_date = date("dS of F Y");
$text2 = "Date: $todays_date";
pdf_show_xy($pdf,$text,50,700);

pdf_continue_text($pdf,$text2);
pdf_continue_text($pdf,' ');
pdf_continue_text($pdf,'Dear someone,');
pdf_continue_text($pdf,' ');
pdf_continue_text($pdf,'hello this is a test');

pdf_end_page($pdf);
pdf_set_parameter($pdf,"openaction","fitpage");
pdf_close($pdf);

$buf = pdf_get_buffer($pdf);
$len = strlen($buf);
header('Content-Type: application/pdf');
header("Content-Length: $len");
header('Content-Disposition: inline; filename=test.pdf');
echo $buf;
pdf_delete($pdf);

[/PHP]

Thanks

httpwebwitch

12:40 am on Apr 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd recommend trying the free FPDF class (to get it, search google for "fpdf"). I tried both libraries and found the FPDF easier to manage. FPDF has a method: $pdf->AddPage();

with FPDF I've been making multi-page documents with no trouble at all.

I haven't used PDFLib as much, but I think you can just call the begin_page method again, and it'll add another page to your document.

PDF_begin_page($pdf, 595, 842);

good luck!

woldie

7:44 am on Apr 29, 2004 (gmt 0)

10+ Year Member



Thanks httpwebwitch (like your profile name!)

I'll have a go with your recommendation, but I did try using that command (PDF_begin_page($pdf, 595, 842); )but it didn't seem to work for me, perhaps I was using it in the wrong place..

Thanks