MySQL to PHP to PDF

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpcloud
Forum Newbie
Posts: 2
Joined: Fri Apr 28, 2006 1:54 am

MySQL to PHP to PDF

Post by phpcloud »

I am trying to fill an existing PDF form with data from MySQL. I have found a lot of resources on generating a PDF using PHP but nothing on populating an existing PDF form from MySQL using PHP.

Any help would be greatly appreciated. Thanks in advanced for your time and help!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If you can fill the form through PHP, then it's pretty simple to use MySQL result data to fill the same information. It's all basic variables in the end. :)
phpcloud
Forum Newbie
Posts: 2
Joined: Fri Apr 28, 2006 1:54 am

Post by phpcloud »

I don't know how to fill it with PHP. I don't have much PDF experience and am not sure how to interact PHP with PDF. Any help you can provide would be great!

Thanks!
danielconaghan1
Forum Newbie
Posts: 2
Joined: Fri Apr 28, 2006 9:05 am

Post by danielconaghan1 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


The problem is that its quite a competetive field at the moment.


I use a php script that creates a pdf object. The object is written by the php then converted to a pdf.
the way html is written by php.

Code: Select all

$field ="SELECT * FROM field_data WHERE page_id=" . $page_no;

	$field_results = $db->query($field);
	while($field_row = mysql_fetch_assoc($field_results)) {

		$data=$field_row['text'];
		$FormatCode = array("~b->", "<-b~", "~i->", "<-i~","~u->", "<-u~");
		$RemovedCode  = array("<b>", "</b>", "<i>", "</i>","<c:uline>", "</c:uline>");
		$data = str_replace($FormatCode, $RemovedCode, $data);
		
		$size=($field_row['size']*3);
		$x1 =($field_row['x1']*$co_change);
		$y1 =($docheight - ($field_row['y1']*$co_change));
		$ydif = $pdf->getFontHeight($size);
		$y1 = $y1 - $ydif;
		$width =($field_row['x2']*$co_change);

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply