PDF框 |执行此行 `PDDocument.load(input)` 时出错
PDFBox | getting error while executing this line `PDDocument.load(input)`
执行行 PDDocument.load(input)
时出现错误
代码示例:
PDDocument pd
String pdfDir = "C:/Users/user/Desktop/file.pdf"
File input = new File("${pdfDir}")
pd = PDDocument.load(input) // System can't execute this line
pdfUtil.writePDF(pd, addr, data)
错误:
Error |
java.io.IOException: Error: End-of-File, expected line
Error |
at org.apache.pdfbox.pdfparser.BaseParser.readLine(BaseParser.java:1519)
Error |
at org.apache.pdfbox.pdfparser.PDFParser.parseHeader(PDFParser.java:360)
Error |
at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:186)
Error |
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1230)
Error |
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1197)
Error |
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1168)
Error |
at org.apache.pdfbox.pdmodel.PDDocument$load.call(Unknown Source)
Error |
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
Error |
依赖性:compile 'org.apache.pdfbox:pdfbox:1.8.11'
如评论中所述:文件为空。这通常是出现这样的异常的原因
IOException: Error: End-of-File, expected line
在堆栈跟踪中有 parseHeader
。
执行行 PDDocument.load(input)
代码示例:
PDDocument pd
String pdfDir = "C:/Users/user/Desktop/file.pdf"
File input = new File("${pdfDir}")
pd = PDDocument.load(input) // System can't execute this line
pdfUtil.writePDF(pd, addr, data)
错误:
Error |
java.io.IOException: Error: End-of-File, expected line
Error |
at org.apache.pdfbox.pdfparser.BaseParser.readLine(BaseParser.java:1519)
Error |
at org.apache.pdfbox.pdfparser.PDFParser.parseHeader(PDFParser.java:360)
Error |
at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:186)
Error |
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1230)
Error |
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1197)
Error |
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1168)
Error |
at org.apache.pdfbox.pdmodel.PDDocument$load.call(Unknown Source)
Error |
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
Error |
依赖性:compile 'org.apache.pdfbox:pdfbox:1.8.11'
如评论中所述:文件为空。这通常是出现这样的异常的原因
IOException: Error: End-of-File, expected line
在堆栈跟踪中有 parseHeader
。