PdfStamper with append = true drastically improves performance, even though JavaDoc says "nothing is gained in speed or memory"?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start by reading the PdfStamper constructor JavaDoc and the implementation of the constructor that accepts the append flag. Compare how append and normal stamping handle the described PDF changes, then check whether the documentation’s performance claim is accurate and identify any side effects. The issue does not name relevant files or tests, so locating the behavior will require reading around the stamper implementation.
Written by the indexing model from the issue text.
Description
I was facing a bad performance on using PdfStamper on a certain PDF. The PDF contained 45 pages with 23k objects (partially heavy illustrations) and took 80 seconds to complete adding a simple text on all pages.
I was using the general PdfStamper constructor, but then tried using the constructor that sets the append flag:
PdfStamper stamp = new PdfStamper(reader, fos, "\0", true); // tried append = true
Suddenly, execution time is reduced from 70 seconds to 5 seconds, which is quite amazing.
What is confusing me is the following comment in the JavaDoc of the respective constructor:
* @param append if <CODE>true</CODE> appends the document changes as a new revision. This is only useful for
* multiple signatures as nothing is gained in speed or memory
It claims that there should be no performance impact.
Can anyone clarify
- whether the JavaDoc is simply outdated?
- whether there can be any side effects when using
append?
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 714
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from LibrePDF/OpenPDF
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
IndexOutOfBoundsException in PdfReaderPossibly taken @andreasrosdalw claimed this 94 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
`PdfSmartCopy` can take effectively unbounded time on nested shared Form XObjectsPossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 38/100
All issues in LibrePDF/OpenPDF
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
snowflakedb/snowflake-kafka-connector#1610 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
swagger-api/swagger-petstore#245 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
liquid-java/liquidjava#443 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
quarkiverse/quarkus-google-cloud-services#1188 ·
Maintainers usually reply within 1 day