PDFbox loads blank pdf [duplicate]

大兔子大兔子 提交于 2021-02-17 06:31:24

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!