DvdM created PDFBOX-5627:
----------------------------

             Summary: Fonts are not subsetted when saving incrementally
                 Key: PDFBOX-5627
                 URL: https://issues.apache.org/jira/browse/PDFBOX-5627
             Project: PDFBox
          Issue Type: Bug
          Components: PDModel
    Affects Versions: 2.0.28, 2.0.29, 3.0.0 PDFBox
            Reporter: DvdM
         Attachments: IncrementalSubsetFontBug1.java, 
IncrementalSubsetFontBug2.java

I've noticed saving documents incrementally does not trigger fonts to be 
subsetted.

The function {{PDDocument.save()}} contains the following code:

{code:java}
// subset designated fonts
for (PDFont font : fontsToSubset)
{
    font.subset();
}
fontsToSubset.clear();
{code}


However, this code to subset fonts does not seem te be included in the 
{{PDDocument.saveIncremental(...)}} and 
{{PDDocument.saveIncrementalForExternalSigning(...)}} functions. When loading a 
font and indicating it should be subset, the font will be used in the 
appearance stream as if subsetted, but it won't be in the end, resulting in a 
corrupt file.

h3. Solution
I propose to also call subset when signing incrementally.

I use this for files to which I add multiple signatures. In between signatures, 
text fields are filled in using PDFBox. Since the fields are not user-editable, 
fonts can be subsetted since the value cannot be changed afterwards.

h3. Reproduce
I have attached 2 files to reproduce this issue. In both files you can change 
{{saveIncremental()}} by {{save()}} or manually call {{font.subset()}} and the 
output will be valid.

Note: both files are minimal reproducible files just designed to trigger this 
issue, that's why the implementations don't make sense (especially the first 
file).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to