Class ConvertHelper

java.lang.Object
org.ofdrw.converter.ConvertHelper

public class ConvertHelper extends Object
PDF 转换 工具
Since:
12:53 2020/11/14
Author:
minghu.zhang
  • Field Details

  • Constructor Details

    • ConvertHelper

      public ConvertHelper()
  • Method Details

    • useIText

      public static void useIText()
      使用iText作为转换实现
    • usePDFBox

      public static void usePDFBox()
      使用PDFBox作为转换实现
    • ofd2pdf

      @Deprecated public static void ofd2pdf(Object input, Object output)
      Deprecated.
      不建议使用该方法,建议使用 toPdf(Path, Path) 系列明确参数方法。
      OFD转换PDF

      Parameters:
      input - OFD文件路径,支持OutputStream、Path、String(文件路径)
      output - PDF输出流,支持OutputStream、Path、File、String(文件路径)
      Throws:
      IllegalArgumentException - 参数错误
      GeneralConvertException - 文档转换过程中异常
    • toPdf

      public static void toPdf(InputStream input, OutputStream output)
      转PDF
      Parameters:
      input - OFD输入流
      output - PDF输出流
      Throws:
      IllegalArgumentException - 参数错误
      GeneralConvertException - 文档转换过程中异常
    • toPdf

      public static void toPdf(InputStream input, File output)
      转PDF
      Parameters:
      input - OFD输入流
      output - PDF输出文件
      Throws:
      IllegalArgumentException - 参数错误
      GeneralConvertException - 文档转换过程中异常
    • toPdf

      public static void toPdf(InputStream input, String output)
      转PDF
      Parameters:
      input - OFD输入流
      output - PDF输出文件路径
      Throws:
      IllegalArgumentException - 参数错误
      GeneralConvertException - 文档转换过程中异常
    • toPdf

      public static void toPdf(Path input, OutputStream output)
      转PDF
      Parameters:
      input - OFD输入文件
      output - PDF输出流
      Throws:
      IllegalArgumentException - 参数错误
      GeneralConvertException - 文档转换过程中异常
    • toPdf

      public static void toPdf(Path input, File output)
      转PDF
      Parameters:
      input - OFD输入文件
      output - PDF输出文件
      Throws:
      IllegalArgumentException - 参数错误
      GeneralConvertException - 文档转换过程中异常
    • toPdf

      public static void toPdf(Path input, Path output)
      转PDF
      Parameters:
      input - OFD输入文件
      output - PDF输出文件路径
      Throws:
      IllegalArgumentException - 参数错误
      GeneralConvertException - 文档转换过程中异常
    • toPdf

      public static void toPdf(String unzippedPathRoot, String output, boolean deleteOnClose)
      转PDF,源文件目录为已经解压的OFD根目录
      Parameters:
      unzippedPathRoot - 已经解压的OFD根目录位置,因此通过参数控制是否删除目录。
      output - PDF输出文件路径
      deleteOnClose - 退出时是否删除 unzippedPathRoot 文件,true - 退出时删除;false - 不删除
    • toHtml

      public static void toHtml(OFDReader ofdReader, String output, int screenWidth) throws IOException
      转HTML

      需要手动关闭外部Reader

      Parameters:
      ofdReader - OFD输入文件,OFDReader应该由外部关闭
      output - HTML输出文件路径
      screenWidth - 页面宽度,或者屏幕宽度
      Throws:
      IOException - 文件处理异常
    • toHtml

      public static void toHtml(Path ofdIn, Path htmlOut, int screenWidth) throws IOException
      OFD转HTML
      Parameters:
      ofdIn - OFD文件路径
      htmlOut - HTML输出文件路径
      screenWidth - 页面宽度,或者屏幕宽度
      Throws:
      IOException - 文件处理异常