我正在使用PdfBox for android以便将数据附加到PDF文件.
要追加的数据
public byte [] prerparePdfToAppend() {
final PDDocument document = new PDDocument();
final PDPage sourcePage = new PDPage();
document.addPage(sourcePage);
PDPageContentStream contentStream = new PDPageContentStream(document, sourcePage);
contentStream.beginText();
contentStream.setFont(PDType1Font.COURIER, 12);
contentStream.showText("Name: " + firstName + " " + lastName);
contentStream.newLine();
...
contentStream.endText();
contentStream.close();
output = new ByteArrayOutputStream();
document.save(output);
document.close();
byte [] bytesToAppend = new byte[output.size()];
output.write(bytes);
output.close();
return bytesToAppend;
}
合并代码(简体)
public