Class CPDFGeneration

java.lang.Object
com.compdfkit.core.convert.CPDFGeneration

public class CPDFGeneration extends Object
  • Constructor Details

    • CPDFGeneration

      public CPDFGeneration()
  • Method Details

    • LicenseVerify

      public static CPDFGeneration.GeneratorLicenseErrorCode LicenseVerify(String license)
    • htmlToPdfConvert

      public static CPDFGeneration.HtmlToPdfErrorCode htmlToPdfConvert(String htmlPath, String outputPdf, String baseUrl, int width, int height, CPDFGeneration.HtmlToPdfFontListener fontListner)
      Convert HTML file to PDF
      Parameters:
      htmlPath - HTML file path
      outputPdf - Output PDF file path
      baseUrl - base URL path(Used for parsing relative path resources)
      width - Page width(Pixel)
      height - Page height(Pixel)
      fontListner - Font callback,Pass NULL to use the default font
      Returns:
      Html2PdfErrorCode Error code,HTML2PDF_SUCCESS is success.
    • htmlToPdfConvertFromString

      public static CPDFGeneration.HtmlToPdfErrorCode htmlToPdfConvertFromString(String htmlContent, String outputPdf, String baseUrl, int width, int height, CPDFGeneration.HtmlToPdfFontListener fontListner)
      Convert HTML string to PDF
      Parameters:
      htmlContent - HTML content string
      outputPdf - Output PDF file path
      baseUrl - Base URL path(Used for parsing relative path resources)
      width - Page width(Pixel)
      height - Page height(Pixel)
      fontListner - Font callback,Pass NULL to use the default font
      Returns:
      Html2PdfErrorCode Font callback,HTML2PDF_SUCCESS is success.
    • htmlToPdfRenderTemplate

      public static String htmlToPdfRenderTemplate(String templateFile, String jsonFile)
      Combine the JSON file with the HTML template to generate HTML content
      Parameters:
      templateFile - HTML template file path
      jsonFile - JSON data file path
      Returns:
      String HTML content
    • htmlToPdfConvertTemplate

      public static CPDFGeneration.HtmlToPdfErrorCode htmlToPdfConvertTemplate(String templateFile, String jsonFile, String outputPdf, String baseUrl, int width, int height, CPDFGeneration.HtmlToPdfFontListener fontListner)
      Combine the JSON file with the HTML template and convert it to PDF
      Parameters:
      templateFile - HTML template file path
      jsonFile - JSON data file path
      outputPdf - Output PDF file path
      baseUrl - Base URL path(Used for parsing relative path resources)
      width - Page width(Pixel)
      height - Page height(Pixel)
      fontListner - Font callback,Pass NULL to use the default font
      Returns:
      Html2PdfErrorCode Error,HTML2PDF_SUCCESS is success
    • htmlToPdfConvertBatch

      public static CPDFGeneration.HtmlToPdfErrorCode htmlToPdfConvertBatch(CPDFHtmlToPdfTask[] tasks, int width, int height, CPDFGeneration.HtmlToPdfFontListener fontListner, CPDFGeneration.HtmlToPdfProgressListener progressCallback)
      Multithreaded batch conversion of JSON and HTML templates to PDF
      Parameters:
      tasks - Task array
      width - Page width(Pixel)
      height - Page height(Pixel). Pass 0 to use the default height
      fontListner - Font callback. Pass NULL to use the default font
      progressCallback - Progress callback. Pass NULL to avoid callback
      Returns:
      Html2PdfErrorCode Error code,HTML2PDF_SUCCESS is success
    • htmlToPdfGetErrorString

      public static String htmlToPdfGetErrorString(int id)
      Get the description string corresponding to the error code
      Parameters:
      id - Error code
      Returns:
      Error description string