Hello Guys, Im using pdflib for generating pdf, It is working fine, when I used a single page pdf as the template, but when I use a pdf with two pages I dont know how to write in first page and second page $page = PDF_open_pdi_page($p, $blockcontainer, 2, ""); // I have set the pdf points to second page Here in the above line, I have set the pdf to write in second page, but I dont know how to write in first page of the pdf. here is the code that I have used to generate pdf. Can anyone help me to sort out this issue. Thanks in Advance. [code] <?php $infile = "Template.pdf"; $searchpath = "./data"; $p = PDF_new(); /* open new PDF file; insert a file name to create the PDF on disk */ if (PDF_begin_document($p, "", "") == 0) { die("Error1: " . PDF_get_errmsg($p)); } /* Set the search path for fonts and PDF files */ PDF_set_parameter($p, "SearchPath", $searchpath); /* This line is required to avoid problems on Japanese systems */ PDF_set_parameter($p, "hypertextencoding", "winansi"); PDF_set_info($p, 'Creator', 'PDF Builder using PDFlib'); PDF_set_info($p, 'Author', 'Author Name'); PDF_set_info($p, "Title", "Card Title"); $blockcontainer = PDF_open_pdi($p, $infile, "", 0); if ($blockcontainer == 0){ die ("Error2: " . PDF_get_errmsg($p)); } $page = PDF_open_pdi_page($p, $blockcontainer, 2, ""); // I have set the pdf points to second page if ($page == 0){ die ("Error3: " . PDF_get_errmsg($p)); } PDF_begin_page_ext($p, 600, 600, ""); /* dummy page size */ /* This will adjust the page size to the block container's size. */ PDF_fit_pdi_page($p, $page, 0, 0, "adjustpage"); //Load the fonts to be used // FuturaHeavy PDF_set_parameter($p, 'FontOutline', 'FuturaHeavy=lte50188.ttf' ); $font = PDF_load_font($p, 'FuturaHeavy', 'winansi', 'embedding'); // FuturaHeavy PostScript Font PDF_set_parameter($p, 'FontPFM', 'FuturaLtBt=0138A___.PFM' );//NOTE - you have to use 'FontPFM' for the FontMetrics of PS font in place of FontOutline as for TT fonts PDF_set_parameter($p, 'FontOutline', 'FuturaLtBt=0138A___.PFB' );//NOTE - you have to use 'FontOutline' for PS font FontOutline in addition to the above $font = PDF_load_font($p, 'FuturaLtBt', 'winansi', 'embedding'); PDF_set_parameter($p, "charref", "true");// allows   etc //Do colour //$spot = PDF_makespotcolor($p, "PANTONE 341 U", 0); //PDF_setcolor($p, "both", $spot, 0.7, 0, 0); //Create the name $text="<leading=100% charspacing=0.35 fontname=FuturaLtBt fontsize=5 encoding=winansi>Name\r\n"; $text.="<leading=250% charspacing=0.95 fontname=FuturaLtBt fontsize=5 encoding=winansi>email@email.com\r\n"; $text.="<leading=290% charspacing=0.35 fontname=FuturaLtBt fontsize=5 encoding=winansi>000 0000 0000\r\n"; $text.="<leading=140% charspacing=0.35 fontname=FuturaLtBt fontsize=5 encoding=winansi>000 0000 0000\r\n"; $text.="<leading=143% charspacing=0.35 fontname=FuturaLtBt fontsize=5 encoding=winansi>000 0000 0000\r\n"; $text.="<leading=409% charspacing=0.35 fontname=FuturaLtBt fontsize=5 encoding=winansi>Address Address \r\n"; $text.="<leading=139% charspacing=0.35 fontname=FuturaLtBt fontsize=5 encoding=winansi>POSTCODE \r\n"; $textbox = PDF_create_textflow($p, $text, "fillcolor={ spotname {PANTONE 341 U} 1 } alignment=left leading=170% charspacing=1 fontname=FuturaHeavy fontsize=9 encoding=winansi") or die ("PDF Error=" . PDF_get_errmsg($p)); $left_x=114.175; $left_y=6.175; // $right_x=227.05515; // Horizontal moving towards right $right_y=128.13203; // moving the box top vertically $offset = 0; //"fillcolor={rgb 1 0 0}" $result = PDF_fit_textflow($p, $textbox, $left_x, $left_y, $right_x, $right_y, "verticalalign=top showborder=false") or die ("PDF Error=" . PDF_get_errmsg($p)); if (strcmp($result, "_stop")) { die ("Error: result=" . $result . " PDF Error=" . PDF_get_errmsg($p)); } PDF_delete_textflow($p, $textbox); $text=""; PDF_end_page_ext($p, ""); PDF_close_pdi_page($p, $page); PDF_end_document($p, ""); PDF_close_pdi($p, $blockcontainer); $buf = PDF_get_buffer($p); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=test.pdf"); print $buf; PDF_delete($p); ?> [/code]