0
我需要在內存中創建PDF文檔我正在使用pdfbox。在內存中創建pdf文檔
這是我的代碼,但它在磁盤上創建文檔。
public PDDocument generatePDF(String name, String v1, String v2, String v3, String v4) {
PDPageContentStream contentStream = null;
PDDocument document = null;
try {
document = new PDDocument();
PDPage page = new PDPage();
document.addPage(page);
contentStream = new PDPageContentStream(document, page);
fillDataInPDF(...);
corpPDF(page);
} catch (IOException err) {
LOG.error("Error occured .");
} finally {
if (contentStream != null) {
try {
contentStream.close();
} catch (IOException e) {
LOG.error("Error occured .");
}
}
}
return document;
}
好的。我贊同你在記憶中創造它的慾望。你真的做到了,或做了一些沒有用的東西? –
我已經創建了磁盤,不知道如何在內存中繼續。 – singhal
您的代碼示例中沒有任何內容會暗示它是在光盤上創建的。 –