Package cn.net.pap.common.pdf
Class PDFUtil
java.lang.Object
cn.net.pap.common.pdf.PDFUtil
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addProtect
(String pdfFilePath, String ownerPassword, String userPassword, String outputFilePath) 添加禁止编辑(密码)static void
添加数字签名static void
添加印章static void
convertPDFA
(String inputFilePath, String outputFilePath) convert PDF/Astatic boolean
convertPDFToJPG
(String pdfFilePath, String outputPath, Integer DPI) 单页 PDF 转换 JPGstatic Boolean
static void
drawParagraphs
(String pdfPath, List<String> paragraphs) 写入段落static void
drawRectangleBy4Point
(String pdfPath, PointDTO leftBottom, PointDTO rightBottom, PointDTO rightTop, PointDTO leftTop) 画矩形, 或者是表格的一个长方形的框。 提供一个从左下角开始,左上角结束的逆时针的四个点坐标.static void
写文字,支持字体大小和按照写入顺序读取.static Boolean
-
Constructor Details
-
PDFUtil
public PDFUtil()
-
-
Method Details
-
convertPDFToJPG
单页 PDF 转换 JPG- Parameters:
pdfFilePath
- PDF文件绝对路径outputPath
- JPG文件绝对路径DPI
- DPI
-
addStamp
public static void addStamp(String pdfFilePath, String imageFilePath, String outputFilePath) throws Exception 添加印章- Parameters:
pdfFilePath
-imageFilePath
-outputFilePath
-- Throws:
Exception
-
addSign
public static void addSign(String pdfFilePath, String keystorePath, String keystorePassword, String outputFilePath) throws Exception 添加数字签名- Parameters:
pdfFilePath
-keystorePath
- *.p12 可以申请SSL证书(*.key, .crt),然后使用openssl 命令转换为 p12 证书keystorePassword
- 密码outputFilePath
-- Throws:
Exception
-
addProtect
public static void addProtect(String pdfFilePath, String ownerPassword, String userPassword, String outputFilePath) throws Exception 添加禁止编辑(密码)- Parameters:
pdfFilePath
-ownerPassword
-userPassword
-outputFilePath
-- Throws:
Exception
-
convertPDFA
convert PDF/A- Parameters:
inputFilePath
-outputFilePath
-- Throws:
Exception
-
drawText
写文字,支持字体大小和按照写入顺序读取.- Parameters:
pdfPath
-coordsDTOList
-- Throws:
IOException
-
drawParagraphs
写入段落- Parameters:
pdfPath
-paragraphs
-- Throws:
IOException
-
drawRectangleBy4Point
public static void drawRectangleBy4Point(String pdfPath, PointDTO leftBottom, PointDTO rightBottom, PointDTO rightTop, PointDTO leftTop) throws IOException 画矩形, 或者是表格的一个长方形的框。 提供一个从左下角开始,左上角结束的逆时针的四个点坐标.- Parameters:
pdfPath
-leftBottom
- 左下角rightBottom
- 右下角rightTop
- 右上角leftTop
- 左上角- Throws:
IOException
-
jpg2Pdf
-
dir2Pdf
-