| | |
How to write the new line existing pdf file using php
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2006
Posts: 197
Reputation:
Solved Threads: 5
Hi Friends
I got very big issue I hope some one can solve my issue!!
How to write the new line in existing pdf file ?
I am using third party library file libphp_pdf.dll its working in linux machine only.
I am try to configure windows machine i got the error message.
any otherway to write the new line exiting pdf file ..
Please send me any suggestion .
Thanks
VSSP
I got very big issue I hope some one can solve my issue!!
How to write the new line in existing pdf file ?
I am using third party library file libphp_pdf.dll its working in linux machine only.
I am try to configure windows machine i got the error message.
any otherway to write the new line exiting pdf file ..
Please send me any suggestion .
Thanks
VSSP
•
•
Join Date: Sep 2005
Posts: 10
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by vssp
Hi Friends
I got very big issue I hope some one can solve my issue!!
How to write the new line in existing pdf file ?
I am using third party library file libphp_pdf.dll its working in linux machine only.
I am try to configure windows machine i got the error message.
any otherway to write the new line exiting pdf file ..
Please send me any suggestion .
Thanks
VSSP
check FPDF (www.fpdf.org) and the extension FPDI (fpdi.setasign.de)
this way it's possible to create dynamic pdf file while using php4 only
Last edited by olaf; Aug 9th, 2006 at 4:16 am.
•
•
Join Date: Jul 2006
Posts: 197
Reputation:
Solved Threads: 5
hai friends
I got the solution. Thanks for your replay .
Step1: download the pdf lib file www.pdflib.com
Copy the dll php extension folder.
Try this code you got the solution
<?php
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
echo $errstr;
}
$old_error_handler=set_error_handler("myErrorHandl er");
//trigger_error("Incorrect page limit", E_USER_ERROR);
//Folder where the temporary files will be uploaded for modifications if(is_uploaded_file($_FILES['file']['tmp_name']))
//Create a new pdf object
$pdf = pdf_new();
//Set the required parameters
pdf_set_parameter($pdf, 'pdiwarning', 'true');
pdf_set_parameter($pdf, 'compatibility','1.5');
//Open an inmemory pdf file
pdf_open_file($pdf,"");
//$pdi = pdf_open_pdi($pdf, "firstfile.pdf", "", 0);
//$page= pdf_open_pdi_page($pdf, $pdi, 1, "");
//Get the file to add the content
//ile='pdffiles/'.$_FILES['file']['name'];
//Actual filename which will be used later to download the modified file
//ilename=$_FILES['file']['name'];
//Get the file to add the content
$file='pdffiles/'.$_FILES['file']['name'];
//Actual filename which will be used later to download the modified file
$filename=$_FILES['file']['name'];
//$file='pdffiles/'."doc.pdf";
//Actual filename which will be used later to download the modified file
//$filename='doc.pdf';
$pdi = pdf_open_pdi($pdf, $file, "", 0);
//$page= pdf_open_pdi_page($pdf, $pdi, 1, "");
// $width = pdf_get_pdi_value($pdf, "width", $pdi, $page, 0);
// $height = pdf_get_pdi_value($pdf, "height", $pdi, $page, 0);
//Gets the content to be added and noof pages in the pdf document
//$content='test test';
//$length=strlen($content);
$content=$_REQUEST['content'];
$length=strlen($content);
$noofpages = pdf_get_pdi_value($pdf, "/Root/Pages/Count", $pdi, 0, 0);
//$noofpages=3;
//Creates a pdi instance for the selected file
//$pdi = pdf_open_pdi($pdf, $file, "", 0);
//Loop for importing the contents of every page
for($i=1;$i<=$noofpages;$i++)
{
//Imports the selected page
$page= pdf_open_pdi_page($pdf, $pdi, $i, "");
//Gets the dimensions of the selected page
$width = pdf_get_pdi_value($pdf, "width", $pdi, $page, 0);
$height = pdf_get_pdi_value($pdf, "height", $pdi, $page, 0);
//Starts a new pdf page
pdf_begin_page($pdf, $width, $height);
// place page from pdi into the pdf file
pdf_place_pdi_page($pdf, $page, 0.0, 0.0, 1.0, 1.0);
// now add text to the first page at the top right corner
if($i==1)
{
$font = pdf_findfont($pdf, "Courier", "host", 0);
pdf_setfont($pdf, $font, 10);
pdf_show_xy($pdf, $content, $width-(($length*6)+10), $height-15);
}
//
pdf_close_pdi_page($pdf, $page);
pdf_end_page($pdf);
}
pdf_close($pdf);
//Send the modified pdf file to the user
$data = pdf_get_buffer($pdf);
header("Content-type: application/pdf");
header("Content-disposition: attachement; filename=$filename");
header("Content-length: " . strlen($data));
echo $data;
?>
I got the solution. Thanks for your replay .
Step1: download the pdf lib file www.pdflib.com
Copy the dll php extension folder.
Try this code you got the solution
<?php
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
echo $errstr;
}
$old_error_handler=set_error_handler("myErrorHandl er");
//trigger_error("Incorrect page limit", E_USER_ERROR);
//Folder where the temporary files will be uploaded for modifications if(is_uploaded_file($_FILES['file']['tmp_name']))
//Create a new pdf object
$pdf = pdf_new();
//Set the required parameters
pdf_set_parameter($pdf, 'pdiwarning', 'true');
pdf_set_parameter($pdf, 'compatibility','1.5');
//Open an inmemory pdf file
pdf_open_file($pdf,"");
//$pdi = pdf_open_pdi($pdf, "firstfile.pdf", "", 0);
//$page= pdf_open_pdi_page($pdf, $pdi, 1, "");
//Get the file to add the content
//ile='pdffiles/'.$_FILES['file']['name'];
//Actual filename which will be used later to download the modified file
//ilename=$_FILES['file']['name'];
//Get the file to add the content
$file='pdffiles/'.$_FILES['file']['name'];
//Actual filename which will be used later to download the modified file
$filename=$_FILES['file']['name'];
//$file='pdffiles/'."doc.pdf";
//Actual filename which will be used later to download the modified file
//$filename='doc.pdf';
$pdi = pdf_open_pdi($pdf, $file, "", 0);
//$page= pdf_open_pdi_page($pdf, $pdi, 1, "");
// $width = pdf_get_pdi_value($pdf, "width", $pdi, $page, 0);
// $height = pdf_get_pdi_value($pdf, "height", $pdi, $page, 0);
//Gets the content to be added and noof pages in the pdf document
//$content='test test';
//$length=strlen($content);
$content=$_REQUEST['content'];
$length=strlen($content);
$noofpages = pdf_get_pdi_value($pdf, "/Root/Pages/Count", $pdi, 0, 0);
//$noofpages=3;
//Creates a pdi instance for the selected file
//$pdi = pdf_open_pdi($pdf, $file, "", 0);
//Loop for importing the contents of every page
for($i=1;$i<=$noofpages;$i++)
{
//Imports the selected page
$page= pdf_open_pdi_page($pdf, $pdi, $i, "");
//Gets the dimensions of the selected page
$width = pdf_get_pdi_value($pdf, "width", $pdi, $page, 0);
$height = pdf_get_pdi_value($pdf, "height", $pdi, $page, 0);
//Starts a new pdf page
pdf_begin_page($pdf, $width, $height);
// place page from pdi into the pdf file
pdf_place_pdi_page($pdf, $page, 0.0, 0.0, 1.0, 1.0);
// now add text to the first page at the top right corner
if($i==1)
{
$font = pdf_findfont($pdf, "Courier", "host", 0);
pdf_setfont($pdf, $font, 10);
pdf_show_xy($pdf, $content, $width-(($length*6)+10), $height-15);
}
//
pdf_close_pdi_page($pdf, $page);
pdf_end_page($pdf);
}
pdf_close($pdf);
//Send the modified pdf file to the user
$data = pdf_get_buffer($pdf);
header("Content-type: application/pdf");
header("Content-disposition: attachement; filename=$filename");
header("Content-length: " . strlen($data));
echo $data;
?>
•
•
Join Date: Sep 2005
Posts: 10
Reputation:
Solved Threads: 0
and what if your hosting provider doesn't support this commercial library?
fpdf works on every php host and is free... I tried the same some years before and skipped pdf-lib because I needed to host on a dedicated server
fpdf works on every php host and is free... I tried the same some years before and skipped pdf-lib because I needed to host on a dedicated server
![]() |
Similar Threads
- Open the exixting pdf file Using PHP (PHP)
- Removing Watermark from an existing pdf file (Windows Software)
Other Threads in the PHP Forum
- Previous Thread: I give up
- Next Thread: PHP Script
Views: 8173 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cookies cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube





