1

How to create PDF FILE from HTML page using itextrenderer in android? I am using itextrenderer but in this can't import java.awt.geom in eclipse because there is no support for awt in android so how could i generate PDF from HTML page using iTextRenderer or any other library if avail

  • After generating PDF i want

    - Text Selection (Copy)
    - Text highlighting etc..
    

because of this features i can not convert HTML to JPEG and then PDF so is there any other option to convert the HTML page to PDF with above Features......????

Joel Peltonen
  • 13,025
  • 6
  • 64
  • 100
Dara Saini
  • 293
  • 1
  • 3
  • 15
  • 1
    take a look at the following link http://massapi.com/source/trunk/JFix/WEB-INF/src/jfix/html/Html2Pdf.java.html – Usman Kurd Dec 28 '12 at 06:16
  • 1
    Go with this link:http://stackoverflow.com/questions/10493837/how-to-export-html-page-to-pdf-format – Ricky Khatri Dec 28 '12 at 06:21
  • yes i am using that java code in android...when i am using that code i got error can't import java.awt.geom in eclipse. Any one help me.. – Dara Saini Dec 28 '12 at 06:27
  • Especially old versions of iText were not designed with Android as target platform. They actually made use of some awt classes. Thus, either use new iText versions (which may not work with Flying Saucer) or some Android-ified patch of the old ones. – mkl Dec 28 '12 at 11:29
  • i ma using org.xhtmlrenderer:flying-saucer-pdf - PDF output using iText it give error can't import java.awt.geom in eclipse because there is no support for awt in android – Dara Saini Dec 28 '12 at 12:13
  • 1
    Contact iText Software. We have a special iText version that works on Android. You can combine it with XML Worker to convert HTML to PDF. This has been tested on Android. – Bruno Lowagie Dec 29 '12 at 09:14
  • I used itextpdf-5.3.5.jar,xmlworker-5.3.5.jar,itext-pdfa-5.3.5.jar I Got errors. 1. Could not find class 'com.itextpdf.awt.PdfPrinterGraphics2D', referenced from method com.itextpdf.text.pdf.PdfContentByte.createPrinterGraphics 2. Could not find class 'org.bouncycastle.cert.X509CertificateHolder', referenced from method com.itextpdf.text.pdf.PdfReader.readDecryptedDocObj – Dara Saini Dec 29 '12 at 10:41
  • create PDF File form url=http://en.wikipedia.org/wiki/Android_%28operating_system%29 or url=http://developer.android.com/sdk/index.html – Dara Saini Dec 29 '12 at 13:55
  • Another approach is Docmosis which is not a HTML->PDF converter, but allows you control over text highlighting etc (depending on what you really mean). – Paul Jowett Feb 28 '13 at 12:22

1 Answers1

0

One possible method is to use MPDF (PHP library for HTML to PDF) and use an AsyncTask to call the script. I have yet to see anything local, but MPDF doesn't need an external server if you find a method to run it on the device (your java app somehow triggers the PHP script locally) which is what I'm trying to figure out right now.

MaKR
  • 1,882
  • 2
  • 17
  • 29
  • MPDF is now closed. – Daksh Agrawal Nov 13 '17 at 16:10
  • Their website is closed, but not the project. I'd suggest GitHub https://github.com/mpdf/mpdf as the source to download. It's still active, and has been updated within the last week. Version 6 is still available from the old website, version 7 is available on GitHub. – MaKR Nov 13 '17 at 23:00