Skip to content

Commit

Permalink
PDFBOX-5873: add acroform default resources and another annotation ap…
Browse files Browse the repository at this point in the history
…pearance

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1920218 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Aug 27, 2024
1 parent 3a4414e commit 331fbe5
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
import org.apache.pdfbox.pdmodel.graphics.state.PDSoftMask;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream;
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;

/**
* This will extract all true type-fonts of a pdf.
Expand Down Expand Up @@ -136,6 +139,11 @@ private void extractFonts(String[] args) throws IOException
}
try (PDDocument document = Loader.loadPDF(new File(pdfFile), password))
{
PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm();
if (acroForm != null)
{
processResources(acroForm.getDefaultResources(), prefix, addKey);
}
PDPageTree pageTree = document.getPages();
for (PDPage page : pageTree)
{
Expand All @@ -150,6 +158,19 @@ private void extractFonts(String[] args) throws IOException
{
processResources(nas.getResources(), prefix, addKey);
}
PDAppearanceDictionary appearance = ann.getAppearance();
if (appearance != null)
{
PDAppearanceEntry nae = appearance.getNormalAppearance();
if (nae != null)
{
nas = nae.getAppearanceStream();
if (nas != null)
{
processResources(nas.getResources(), prefix, addKey);
}
}
}
}
}
}
Expand Down

0 comments on commit 331fbe5

Please sign in to comment.