public class

HTML2PDF

extends Object
java.lang.Object
   ↳ com.pdftron.pdf.utils.HTML2PDF

Class Overview

Utility class to convert HTML to PDF. API 19+ only. The following permissions are required:

Sample usage:

  HTML2PDF.fromUrl(activity, someLink, new HTML2PDF.HTML2PDFListener() {

      public void onConversionFinished(String pdfOutput) {

      }


      public void onConversionFailed() {

      }
  });
 

Summary

Nested Classes
interface HTML2PDF.HTML2PDFListener  
Fields
public static final String TAG
Public Constructors
HTML2PDF(Context context)
HTML2PDF(WebView webView)
HTML2PDF(WebView webView, Uri outputFolderUri)
Public Methods
void doHtml2Pdf()
static void fromHTMLDocument(Context context, String baseUrl, String htmlDocument, HTML2PDF.HTML2PDFListener listener)
Convert from HTML document
void fromHTMLDocument(String baseUrl, String htmlDocument)
Convert from HTML document
static void fromUrl(Context context, String url, File folder, HTML2PDF.HTML2PDFListener listener)
Convert from a URL link
static void fromUrl(Context context, String url, Uri folder, String outputFileName, HTML2PDF.HTML2PDFListener listener)
Convert from a URL link
void fromUrl(String url)
Convert from a URL link
static void fromUrl(Context context, String url, HTML2PDF.HTML2PDFListener listener)
Convert from a URL link
static void fromUrl(Context context, String url, Uri folder, HTML2PDF.HTML2PDFListener listener)
Convert from a URL link
static void fromWebView(WebView webView, HTML2PDF.HTML2PDFListener listener)
Convert from content in a WebView
void setHTML2PDFListener(HTML2PDF.HTML2PDFListener listener)
void setHorizontalDpi(int horizontalDpi)
The horizontal dpi, default to 600
void setMargins(PrintAttributes.Margins margins)
The margin, default to NO_MARGINS
void setMediaSize(PrintAttributes.MediaSize mediaSize)
The page size, default to NA_LETTER
void setOutputFileName(String fileName)
The output file name, default to website title.
void setOutputFolder(Uri outputFolder)
The output folder path, default to "Download/HTML2PDF"
void setOutputFolder(File outputFolder)
The output folder path, default to "Download/HTML2PDF"
void setVerticalDpi(int verticalDpi)
The vertical dpi, default to 600
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final String TAG

Public Constructors

public HTML2PDF (Context context)

public HTML2PDF (WebView webView)

public HTML2PDF (WebView webView, Uri outputFolderUri)

Public Methods

public void doHtml2Pdf ()

public static void fromHTMLDocument (Context context, String baseUrl, String htmlDocument, HTML2PDF.HTML2PDFListener listener)

Convert from HTML document

Parameters
context the context
baseUrl the base URL
htmlDocument the HTML string
listener the listener

public void fromHTMLDocument (String baseUrl, String htmlDocument)

Convert from HTML document

Parameters
baseUrl the base URL
htmlDocument the HTML string

public static void fromUrl (Context context, String url, File folder, HTML2PDF.HTML2PDFListener listener)

Convert from a URL link

Parameters
context the context
url the link
folder the destination folder
listener the listener

public static void fromUrl (Context context, String url, Uri folder, String outputFileName, HTML2PDF.HTML2PDFListener listener)

Convert from a URL link

Parameters
context the context
url the link
folder the destination folder
listener the listener

public void fromUrl (String url)

Convert from a URL link

Parameters
url the URL link

public static void fromUrl (Context context, String url, HTML2PDF.HTML2PDFListener listener)

Convert from a URL link

Parameters
context the context
url the link
listener the listener

public static void fromUrl (Context context, String url, Uri folder, HTML2PDF.HTML2PDFListener listener)

Convert from a URL link

Parameters
context the context
url the link
folder the destination folder
listener the listener

public static void fromWebView (WebView webView, HTML2PDF.HTML2PDFListener listener)

Convert from content in a WebView

Parameters
webView the WebView
listener the listener

public void setHTML2PDFListener (HTML2PDF.HTML2PDFListener listener)

public void setHorizontalDpi (int horizontalDpi)

The horizontal dpi, default to 600

Parameters
horizontalDpi The horizontal dpi

public void setMargins (PrintAttributes.Margins margins)

The margin, default to NO_MARGINS

Parameters
margins The margin

public void setMediaSize (PrintAttributes.MediaSize mediaSize)

The page size, default to NA_LETTER

Parameters
mediaSize The page size

public void setOutputFileName (String fileName)

The output file name, default to website title.

Parameters
fileName the output file name

public void setOutputFolder (Uri outputFolder)

The output folder path, default to "Download/HTML2PDF"

Parameters
outputFolder The output path as a Uri

public void setOutputFolder (File outputFolder)

The output folder path, default to "Download/HTML2PDF"

Parameters
outputFolder The output file path

public void setVerticalDpi (int verticalDpi)

The vertical dpi, default to 600

Parameters
verticalDpi The vertical dpi