在这段代码中,我试图访问服务器以获取pdf文件,并读取这些pdf文件,然后尝试将其写入新的pdf文件中。
URL vConcreteUrl = new URL(Globals.c_Retrieve_Url_Equals.replace("{BD_ID}", vBdId));
PDDocument p = PDDocument.load(vConcreteUrl.openStream());
PDDocument c = new PDDocument();
PDPage page = p.getPage(1);
PDPageContentStream contentStream = new PDPageContentStream(p, page);
contentStream.beginText();
String text = vBdId;
contentStream.showText(vBdId);
contentStream.endText();
System.out.println("content added");
contentStream.close();
p.save(new File("U:/pdf" + vBdId + ".pdf"));
p.close();
但是我遇到了以下错误。
java.io.IOException: Error: End-of-File, expected line
at org.apache.pdfbox.pdfparser.BaseParser.readLine(BaseParser.java:1119)
at org.apache.pdfbox.pdfparser.COSParser.parseHeader(COSParser.java:2017)
at org.apache.pdfbox.pdfparser.COSParser.parsePDFHeader(COSParser.java:1988)
at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:269)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1143)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1040)
at com.ikea.stebu.od.util.pdf.DownloadPDFFromOndemand.execute
为什么我会收到此错误?