tags:

views:

53

answers:

5

I want to make a online PDF Creator and Reader in PHP which will support all features available in Adobe Acrobat like Bookmarking, Signing, Commenting, Editing, Header and Footer, watermark etc etc.. Can you please suggest me a good PHP Library which will help me to do that?

A: 

Try this one. It should be exactly what you are looking for.

You can take a look at this example how to create a "Hello World" PDF.

<?php
$p = PDF_new();

/*  open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "") == 0) {
    die("Error: " . PDF_get_errmsg($p));
}

PDF_set_info($p, "Creator", "hello.php");
PDF_set_info($p, "Author", "XYZ");
PDF_set_info($p, "Title", "Hello world (PHP)!");

PDF_begin_page_ext($p, 595, 842, "");

$font = PDF_load_font($p, "Helvetica-Bold", "winansi", "");

PDF_setfont($p, $font, 24.0);
PDF_set_text_pos($p, 50, 700);
PDF_show($p, "Hello world!");
PDF_continue_text($p, "(says PHP)");
PDF_end_page_ext($p, "");

PDF_end_document($p, "");

$buf = PDF_get_buffer($p);
$len = strlen($buf);

header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;

PDF_delete($p);
?>
Forlan07
This is to create PDF (Signing, Watermark etc. are not available here) but whats about PDF reading??
chanchal1987
I do only know this one. I'm not sure whether there are librarys out there to read PDFs.
Forlan07
+1  A: 

Google search led me to http://davidwalsh.name/read-pdf-doc-file-php for reading a pdf, for creating a pdf I would use tcpdf, its the best free one I have used although with all the font files its a large library.

Regards

Luke

Luke
@Luke:1. Is **tcpdf** supports watermark, background image, edit existing pdf file etc.?2. Can I insert comment while reading a file using **tcpdf** and **xpdf**? If yes then how?3. Can I able to implement bookmark wise navigation using **xpdf**?Please help...
chanchal1987
@chanchal1987 - There may not be a PDF library that does everything that you need, and you may have to take something like fpdf or tcpdf as a base and actually modify it yourself to add extra features... If you do, I hope you'd submit them back to the library for the benefit of others.
Mark Baker
A: 

Google is creating a PDF reader for Chrome, as Chromium is open source you can take a look on how they render it inside the browser. Maybe that method is usable for you.

Fabian
A: 

Have a look at FREE and popular FPDF

FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.

FPDF has other advantages: high level functions. Here is a list of its main

Features:

  • Choice of measure unit, page format and margins
  • Page header and footer management
  • Automatic page break
  • Automatic line break and text justification
  • Image support (JPEG, PNG and GIF)
  • Colors
  • Links
  • TrueType, Type1 and encoding support
  • Page compression
Sarfraz
A: 

@chanchal1987 I've used Tcpdf as well, it's an really usefull library! Please visit the link Luke provided for more information about tcpdf. I know that tcpdf does support watermarks and background images.

@user400175: Thanks
chanchal1987