Which One Is the Best Pdf-API For PHP

best plugin to generate pdf from php

I am not sure which one that fits your requirements.
But I seen much people talking good about tcpdf
See the list below of a couple:

  • ApacheFOP
  • dompdf
  • FPDF
  • html2ps
  • mPDF
  • PDFlib
  • TCPDF
  • wkhtmltopdf
  • Zend_Pdf

source:
Which one is the best PDF-API for PHP?

Which PHP API or library is the best for converting from HTML to PDF and DOCX?

According to answers from @Ruchi and @BananaMan, I'll try to use the combination of HTML to docx and dompdf libraries instead of the former combination of Pdfcrowd and Pdfaid limited APIs. Thank you so much for your answers.

PHP PDF Generator Advice

Try TCPDF, have good features
http://www.tcpdf.org/examples.php

Also simple HTML to PDF Converter API in (PHP, C#, ASP.net C#, ASP VB.net, JAVA,...)

from "PDF CROWD"
http://pdfcrowd.com/html-to-pdf-api/

very simple to use, but I think this API may need to purchase even they provide a free test account..

PDF Export in php

If your intention is to create a PDF from PHP, pdflib will help you.

Otherwise, if you want to convert an HTML page to PDF via PHP, you'll find a little trouble outta here.

So, the options I know are:

DOMPDF : PHP class that wraps the HTML and builds the PDF. Works good, customizable (if you know PHP), based on pdflib, and, if I remember correctly, it takes even some CSS. Bad news: slow when the HTML is big or very complex.

HTML2PS: same as DOMPDF, but this one converts first in .ps (GhostScript), then, in whatever format you need (PDF, JPEG, PNG). For me it is a little better then DOMPDF, but have the same speed problem. Oh, better compatibility with CSS.

Those two are PHP classes, but if you can install some software on the server, and access it through passthru() or system(), give a look to these too:

wkhtmltopdf: based on WebKit (Safari's wrapper), it's really fast and powerful. Seems like it is the best one (at the moment) for HTML to PDF conversion on the fly, taking only 2 seconds for a 3 page XHTML document with CSS2. It's a recent project anyway, so the google.code page is often updated.

htmldoc : this one is a tank, it really never stops/crashes. The project seems dead, as of 2007, but if you don't need CSS compatibility this can be nice for you.

tcpdf - this is an enhanced and maintained version of fpdf. It has all the main Features of tpdf and it also has faster execution time with great output. For detailed tutorial on using the two most popular PDF generation classes: TCPDF and FPDF, please follow this link. I think you should continue using TCPDF.

See these posts also:

  1. Convert HTML + CSS to PDF with PHP?
  2. Which one is the best PDF-API for PHP?
  3. Export a html into PDF in PHP?
  4. Writing HTML with PHP variables to PDF file?
  5. How to convert html into pdf with php?
  6. Tool for exporting html as pdf
  7. Converting HTML in PHP File to PDF File

Read pdf files with php

Check out FPDF (with FPDI):

http://www.fpdf.org/

http://www.setasign.de/products/pdf-php-solutions/fpdi/

These will let you open an pdf and add content to it in PHP. I'm guessing you can also use their functionality to search through the existing content for the values you need.

Another possible library is TCPDF: https://tcpdf.org/

Update to add a more modern library: PDF Parser

How to generate a pdf document using an API?

It looks that the contents available at http://webexpress.cargus.ro/custom_print/shipment_import/view_awb.php?user=canai_test&parola=test&awb=TSD21185178T is already a .pdf.

You may try (I based on example at http://davidwalsh.name/curl-download):

<?php

header("Content-Type: application/pdf");

function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}

$url = "http://webexpress.cargus.ro/custom_print/shipment_import/view_awb.php?user=canai_test&parola=test&awb=TSD21185178T";

$pdf = get_data($url);

echo $pdf;

?>


Related Topics



Leave a reply



Submit