reset 'os' before saving. Also call load() directly with the byte array, and update to the current version.
Tilman Gesendet mit der Telekom Mail App --- Original-Nachricht --- Von: Romain Sarry Betreff: Adobe Acrobat prompts saving Datum: 13.05.2020, 15:06 Uhr An: users@pdfbox.apache.org @font-face { font-family: telegrotesk-medium_normal; src: url("file:///android_asset/fonts/telegrotesk_normal.ttf");}html,body { font-family: "telegrotesk-medium_normal"; font-size: medium; color: #4b4b4b; width: 100%;} Hello, I'm using Apache PDFBox version 2.0.16 to add paging to an existing PDF file. My method is working great, the generated PDF is fine. However, when I open the file with Adobe Acrobat Reader, if I try to close the file, it prompts an alert asking me if I want to save the file even though I haven't edited anything, and the file is not editable at first. I can't manage to understand what's happening, and how to prevent it from prompting saving My code is the following : private void paging(ByteArrayOutputStream os) throws IOException { PDDocument doc = PDDocument.load(new ByteArrayInputStream( os.toByteArray())); PDFont font = getFont(doc); PDPageTree pages = doc.getDocumentCatalog().getPages(); for (int i = 0; i < pages.getCount(); i++) { PDPage page = pages.get(i); PDPageContentStream contentStream = new PDPageContentStream(doc, page, PDPageContentStream.AppendMode.APPEND, true, false); contentStream.beginText(); contentStream.setFont(font, FONT_SIZE); contentStream.setNonStrokingColor(Color.BLACK); contentStream.newLineAtOffset(page.getCropBox().getWidth() - 40, 15); contentStream.showText((i + 1) + " / " + pages.getCount()); contentStream.endText(); contentStream.close(); } doc.save(os); doc.close(); } *Romain SARRY* *Ingénieur en Développement* *06 29 08 34 02* *13 rue des Teinturiers **69100 Villeurbanne*