Jul 4, 2009
Pages: 1, 2, 3

How To: Create PDF With Php - Create on-the-fly PDF on the web server

free web hosting
Free Web Hosting > Computers & Tech > How-To's and Tutorials > Programming > PHP

How To: Create PDF With Php - Create on-the-fly PDF on the web server

vmkrightpoint
Omg,

i was looking for something like this for a while!!

thank you

Comment/Reply (w/o sign-up)

Avinash Raut Nagpur(india)
QUOTE(FeedBacker @ Dec 12 2007, 04:24 AM) *
Question actually.
I have problems at GEN02.Php:
The function PDF_open_image_file (I also tried with PDF_load_image)
Always return 0.

I tried a lot of things (SearchPath, different type of pictures, different pictures...) but still return 0.

Please help!

Tks,

Ferasse.

-Mr. Tea


*******************************************************************
Hello
here is the solution
<?php
$mypdf = PDF_new();
PDF_open_file($mypdf, "");
PDF_begin_page($mypdf, 595, 842);
$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
PDF_setfont($mypdf, $myfont, 10);
//PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);
//PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730);
//PDF_show_xy($mypdf, "A JPEG image, on 60 % of its original size.", 50, 710);
//$myimage = PDF_open_image_file($mypdf, "jpeg", "trump.jpg");
$myimage = PDF_load_image($mypdf, "jpeg", "D:\wamp\www\srms_test\pdf\a.jpg", "");
//PDF_place_image($mypdf, $myimage, 50, 650, 0.6);
PDF_fit_image($mypdf, $myimage, 0, 700, "boxsize {200 100} fitmethod meet");
PDF_end_page($mypdf);
PDF_close($mypdf);
$mybuf = PDF_get_buffer($mypdf);
$mylen = strlen($mybuf);
header("Content-type: application/pdf");
header("Content-Length: $mylen");
header("Content-Disposition: inline; filename=gen02.pdf");
print $mybuf;
PDF_delete($mypdf);
?>

 

 

 


Comment/Reply (w/o sign-up)

FeedBacker
Font weight and style
How To: Create PDF With Php

How do make text bold or italic, and such?
Thanks a lot for the tutorial, it's very helpful!

Philippe Alves

Comment/Reply (w/o sign-up)

Quatrux
I needed to create a printable version of a html application form with PHP, due to printing the html from a browser was quite lame, so I thought to use PDF generation and really found a great class which doesn't require any extra libs like in the tutorial and it works with PHP4 and PHP5, there are two different versions for support for both of them..

the class is called TCPDF, you'll find it through google, as I know a lot of PHP apps are using it to generate PDF files and it's really powerful, there are ~22 examples in the package how would you need to create them, at first it was quite hard for me, but in a couple of hours I got myself a PHP script to generate PDF files I wanted.. before that I tried fpdf, I think tcpdf is written the way fpdf is, but tcpdf has much more features and the main thing it has UTF-8 support, fpdf doesn't support UTF-8, thats why I had problems with some Lithuanian letters and found TCPDF, really a great class! wink.gif

FPDF: http://www.fpdf.org/
TCPDF: http://www.tecnick.com/public/code/cp_dpag...?aiocp_dp=tcpdf

Comment/Reply (w/o sign-up)

FirefoxRocks
This is a very good tutorial nonetheless lengthy. I personally do not see much use for PDF documents unless you are scanning things in and converting those to PDF files.

This method can be useful if you are trying to convert Word documents into PDF and you do not have access to certain PDF software or OpenOffice.org.

I may decide to try this sometime when I need it.

Comment/Reply (w/o sign-up)

FeedBacker
Euro Symbol with pdflib
How To: Create PDF With Php

How Can I print the euro symbol in a pdf document generated with pdflib???
I try print it by different ways but I can't do it.

Anyone can help me???

Thank in advance.

-reply by Jorge Roman

Comment/Reply (w/o sign-up)

alex198555
Interesting tutorial! Do you know if it is possible to convert the PDF File into content management system. This is the thing I would like to know about it,

Let's say, I have a PDF file on my local drive, and I want to convert that file into my database, or using CMS editor to do so, and this file will automatically will be added to my database, by parts, chapters and so on.


Comment/Reply (w/o sign-up)

iGuest-Mohamed badr
contents from MySQL
How To: Create PDF With Php

How can I generate contents in the pdf using data coming from MySQL database ??

-reply by Mohamed badr

Comment/Reply (w/o sign-up)

rockarolla
Hei,,whats the script you'r using for your singature...a kind of impressed - am totally unfamiliar with ada ..

thanks

Comment/Reply (w/o sign-up)

(G)

How about creating a PDF from whatever program you would normally use, such as inDesign or Word and then updating text fields with data generated from a PDF query?  This seems like a streamline method that would allow a template to be created in more detail and then use PHP to populate various fields as a final product.

Any plans on doing a tutorial that covers these features?

 

Thanks


Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2, 3

See Also,

*SIMILAR VIDEOS*
Searching Video's for howto, create, pdf, php, create, fly, pdf, web, server
advertisement



How To: Create PDF With Php - Create on-the-fly PDF on the web server

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com