Check if fonts are embedded in an existing PDF?

697 views Asked by At

How can I check if the fonts are embedded in an existing PDF?

That is, read an existing PDF and list out the results in a .txt file

I went through the following example:

http://itextpdf.com/examples/iia.php?id=287

The above example tries to create a new PDF, but I want to read a PDF file and check if the fonts are embedded or not.

I am more of a PHP guy so having a hard time to tweak the code. Any help would be appreciated

1

There are 1 answers

0
Abhinav On BEST ANSWER

I am not sure what I have done is correct. Based on the suggestion by Bruno,

I actually removed the dependency of that FontTypes package itself.

Instead created a new variable public static final String PREFACE = "resources/pdfs/sample.pdf";//Path of Existing PDF File

And Passed the PREFACE to the main method

   public static void main(String[] args) throws IOException, DocumentException {
        Set<String> set = new ListUsedFonts().listFonts(PREFACE);
        PrintWriter out = new PrintWriter(new FileOutputStream(RESULT));
        for (String fontname : set)
            out.println(fontname);
        out.flush();
        out.close();
    }

But I did get the output in the form fonts.txt