Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Php FPDI and FPDF open pdf file and edit one page?

Posted on 2008-10-10
2
Medium Priority
?
6,402 Views
Last Modified: 2012-05-05
I use this FPDI and FPDF script (in code snippet) to open pdf file and to stamp it in php, but there is the problem with the server "internal server error" when i try to stamp pdf file with 130 pages. AND there is the problem if i try to join this 130 pages as well without stamping. (the problem is on hosting server, it works on localhost)

so i wanted to open pdf file and parse it back with  file_get_contents($filename) and i wrote ...

$my_file = file_get_contents($filename);
$pdf =& new FPDF();
$pdf->buffer = $my_file;  
$pdf->Output($name."_go.pdf", 'D');

and its working! but...
i want now to stamp just one page, is that possible? how can i do that ?
$pdf =& new FPDI();
		
		
		// set the sourcefile
		$pages=$pdf->setSourceFile($filename);
		
			 
		
		
		// import pages one after the other
		for($i = 1; $i < $pages; $i ++) {
		    // add a page
		    //echo memory_get_usage() . "\n";
		    $pdf->AddPage();
		    $tplIdx = $pdf->importPage($i);
		    // use the imported page and place it at point 10,10 with a width of 100 mm
		    $pdf->useTemplate($tplIdx);
		 	echo memory_get_usage();
		    // write text with link to www.fpdf.org website
		    $pdf->SetFont('Arial');
		    $pdf->SetTextColor(255,102,102);
		    $pdf->SetXY(15, 15); // X (cm),  Y (cm)
		    $pdf->Write(0,$signature_text,'http://www.address.cc');
 
		    //$pdf->Write(0,'w w w . f p d f . o r g');
		}
		$pdf->Output('newpdf.pdf', 'D');

Open in new window

0
Comment
Question by:galic1987
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
khaledf earned 2000 total points
ID: 22690802
it is very likely that the problem is caused by memory size in php
increase your php memory size to 32 and see if it works. to test if this is the case try to put this line at the top of your code

ini_set('memory_limit', '32M' );

or

ini_set('memory_limit', '64M' );
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question