Am 29.07.21 um 22:09 schrieb Alexander Slonim:
Hello Andreas,

Thanks, yes the first test was a mistake.

To alleviate the concern I have ensured the code verifies the document being
read is there and exactly as expected.
  Acrobat 8 says there was an error opening this document, however PDF
Debugger does not complain.
Is there any specific error message? Did you try a more recent version of Acrobat (8 is quite old) or some other PDF viewer? Please upload the resulting pdf to a sharehoster or another public place.

Andreas


I try it two ways,
Using an input stream:
         PDDocument document = Loader.loadPDF(fis);
         corruptPDFDocument("inputStreamSave", document);

Using a File
         PDDocument document = Loader.loadPDF(file);
         corruptPDFDocument("classLoaderSave", document);

And all I do is
         document.save(tempFile);
         document.close();

Any thoughts very much appreciated, I am stuck.

Alex


-----Original Message-----
From: Andreas Lehmkuehler [mailto:andr...@lehmi.de]
Sent: Thursday, July 29, 2021 1:05 PM
To: users@pdfbox.apache.org
Subject: Re: PDFBox corrupting PDFs when saving

Am 28.07.21 um 22:22 schrieb Alexander Slonim:
Hello,

When I attempt to use PDDocument.save, the saved output file is
corrupted, even when no action is taken on the file other than saving it.
Works fine for me using the current trunk and my own code

Your test cases are probleatic.

The first one doesn't make that much sense, there isn't any PDDcoument.save
involved.

The second and the third one are using the very same file name. The only
difference is the current timestamp. But there is/was an issue on windows
systems where those timestamps aren't accurate so that those are maybe the
same if they are close enough. Saying, maybe oen tests overwrites the output
of the other one

Maybe you should follow Tilmans comment and double check if the ressources
are copied without filtering

Amdreas


For example:

```

          File file = new
File("C:\\Users\\Public\\Desktop\\projects\\test-pdfbox-corruption\\sr
c\\mai
n\\resources\\chicken.pdf");

          PDDocument document = Loader.loadPDF(file);

          document.save("C:\\Users\\Public\\Music\\file" + new
Date().getTime() + ".pdf");

          document.close();

```

I am currently using PDFBox 3.0.1-RC, however, I also used 2.0.15 and
2.0.24, and experienced the same issues.

For a more complete example, I have posted the project to GitHub
(https://github.com/pdinc-oss/pdfbox-corrupt-test.git)

I am new to PDFbox and am unsure if this is a usage error on my end or
a bug within PDFBox itself.

Best,

Alex




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to