HTML to PDF with PHP
Using open-source HTML2FPDF project
This solution uses HTML2PDF project (sourceforge.net/projects/html2fpdf/). It simply gets a HTML text and generates a PDF file. This project is based upon FPDF script (www.fpdf.org), which is pure PHP, not using the PDFlib or other third party library. Download HTML2PDF, add it to your projects and you can start coding.
Code example
require("html2fpdf.php");
$htmlFile = "http://www.dancrintea.ro";
$buffer = file_get_contents($htmlFile);
$pdf = new HTML2FPDF('P', 'mm', 'Letter');
$pdf->AddPage();
$pdf->WriteHTML($buffer);
$pdf->Output('test.pdf', 'F');
HTML to PDF with Java
Using OpenOffice.org
You can use OpenOffice.org(must be available on the same computer or in your network) for document conversion.
Besides HTML to PDF, there are also possible other conversions:
doc --> pdf, html, txt, rtf
xls --> pdf, html, csv
ppt --> pdf, swf
Code example
import officetools.OfficeFile;
// this is my tools package ...
FileInputStream fis = new FileInputStream(new File("test.html"));
FileOutputStream fos = new FileOutputStream(new File("test.pdf"));
// suppose OpenOffice.org runs on localhost, port 8100
OfficeFile f = new OfficeFile(fis,"localhost","8100", true);
f.convert(fos,"pdf");
How to get my Java tools package for OpenOffice.org
If you want to use this solution in your projects, please contact me:
Contact
HTML to PDF with ASP
Using ASPPDF
You can use AspPDF (www.asppdf.com), an ActiveX server component for dynamically creating, reading and modifying PDF files.
Code example(VB)
Set Pdf = Server.CreateObject("Persits.Pdf")
Set Doc = Pdf.CreateDocument Doc.ImportFromUrl "http://www.dancrintea.ro" Filename = Doc.Save( Server.MapPath("test.pdf"), False )
Using open-source HTML2FPDF project
This solution uses HTML2PDF project (sourceforge.net/projects/html2fpdf/). It simply gets a HTML text and generates a PDF file. This project is based upon FPDF script (www.fpdf.org), which is pure PHP, not using the PDFlib or other third party library. Download HTML2PDF, add it to your projects and you can start coding.
Code example
require("html2fpdf.php");
$htmlFile = "http://www.dancrintea.ro";
$buffer = file_get_contents($htmlFile);
$pdf = new HTML2FPDF('P', 'mm', 'Letter');
$pdf->AddPage();
$pdf->WriteHTML($buffer);
$pdf->Output('test.pdf', 'F');
HTML to PDF with Java
Using OpenOffice.org
You can use OpenOffice.org(must be available on the same computer or in your network) for document conversion.
Besides HTML to PDF, there are also possible other conversions:
doc --> pdf, html, txt, rtf
xls --> pdf, html, csv
ppt --> pdf, swf
Code example
import officetools.OfficeFile;
// this is my tools package ...
FileInputStream fis = new FileInputStream(new File("test.html"));
FileOutputStream fos = new FileOutputStream(new File("test.pdf"));
// suppose OpenOffice.org runs on localhost, port 8100
OfficeFile f = new OfficeFile(fis,"localhost","8100", true);
f.convert(fos,"pdf");
How to get my Java tools package for OpenOffice.org
If you want to use this solution in your projects, please contact me:
Contact
HTML to PDF with ASP
Using ASPPDF
You can use AspPDF (www.asppdf.com), an ActiveX server component for dynamically creating, reading and modifying PDF files.
Code example(VB)
Set Pdf = Server.CreateObject("Persits.Pdf")
Set Doc = Pdf.CreateDocument Doc.ImportFromUrl "http://www.dancrintea.ro" Filename = Doc.Save( Server.MapPath("test.pdf"), False )
No comments:
Post a Comment