Jump to content

Recommended Posts

Hello all. I need to write to a pdf!

 

Say I have a mysql database:

 

ID | Name

 

and a directory of images, entitled

 

pic.id.jpg

 

where id is tied to the id field of the db. so in actuality it'd be

 

pic1.jpg , pic45.jpg , etc

 

What would be the best way to write to a pdf with a header string, and then the corresponding image in the middle of the page.

 


$res=mysql_query("SELECT * FROM `table`");
while($row=mysql_fetch_array($res)){

$title=$row['title'];
$image="picture".$row['id']."jpg";

fopen("filenumber".$row['id'].pdf", w);

//write to it somehow

fclose();

}//end while

 

yaya, its bad fopen etc, just trying to get the idea across. I need to do this for ~2700 images :'(.

 

So the question is: how do i write a pdf with db info so it looks like this:

 

 

<--pdf-->

 

TITLE

 

IMAGE

 

DATATABLE

 

<--pdf-->

 

Thanks all!

Link to comment
https://forums.phpfreaks.com/topic/167678-solved-writing-to-a-pdf/
Share on other sites

A forum isn't exactly an appropriate medium for explaining all of this. That is why there are tutorials. Have you looked at any tutorials for this? If you have problems understanding something in those tutorials then post a question for clarification.

 

This should get you started: http://www.sitepoint.com/article/generate-pdfs-php/

 

Note: I have not read/followed that tutorial so I cannot comment on its quality, but the general descriptions sounds like it is just what you need.

 

However, I'm not sure if you can edit an already created PDF document with the PDF library.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.