问题
I am trying to create a pdf based on baselayout.pdf by just populating data inside that baselayout. while Trying to load thta pdf placed inside war deployed on weblogic server, PDFbox loads blank pdf. Data is getting populated but pdf layout is not.
I have tried placing the baselayout.pdf inside resource folder.
InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("BaseLayout.pdf");
doc = PDDocument.load(resourceAsStream);
page = doc.getPage(0);
contentStream = new PDPageContentStream(doc, page, PDPageContentStream.AppendMode.APPEND, true);
PDImageXObject pdImage = PDImageXObject.createFromByteArray(doc, generateBarcode(paramValue), "Test");
contentStream.beginText();
contentStream.setLeading(14.5f);
contentStream.setFont(PDType1Font.TIMES_ROMAN, 8);
writeFirstBlock(contentStream);
contentStream.endText();
contentStream.drawImage(pdImage, 403, 770);
contentStream.close();
doc.save("./Test/Test_"+new Date().getTime()+".pdf");
doc.close();
来源:https://stackoverflow.com/questions/55722595/pdfbox-loads-blank-pdf