We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Search and Get Text Segments from All Pages of PDF Document

Hi all, i am trying to see if my pdf document has an non embedded fonts. i see code snippets for detecting embedded/non-embedded fonts in the area " Search and Get Text Segments from All Pages of PDF Document" but this is done using a search term.
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“Figure”);

but i need to search for all words in all pages of the document. how can i do that

@smandepudi

Thanks for contacting support.

As per my assumptions, you want to check if font(s) are embedded or not, inside your PDF document. Please check following code snippet which will display all the font names along with the information about, if they are embedded or not.

Document pdfdoc = new Document(dataDir + "sample.pdf");
Aspose.Pdf.Page page = pdfdoc.Pages[1];
FontCollection fontcoll = page.Resources.Fonts;
foreach (Aspose.Pdf.Text.Font font in fontcoll)
{
 Console.WriteLine("Font : " + font.FontName + ", IsEmbedded : " + (font.IsEmbedded == true ? "Yes" : "No"));
}

In case if my assumptions are different than your requirements or you face any issue, please feel free to contact us.


Best Regards,
Asad Ali

oh i see that seems like a great ides. let me check that. Thank you

Hi There, i need to check in all pages and not just page 1. how can i do that . your example only looks at one page

Aspose.Pdf.Page page = pdfdoc.Pages[1];

@smandepudi

Thanks for writing back.

In order to check font embedded status for all pages, you need to traverse through all pages of a document in a loop. Please check following code snippet to achieve that.

Document pdfdoc = new Document(dataDir + "sample-descendant-font.pdf");
foreach (Aspose.Pdf.Page page in pdfdoc.Pages)
{
 FontCollection fontcoll = page.Resources.Fonts;
 foreach (Aspose.Pdf.Text.Font font in fontcoll)
 {
  Console.WriteLine("Font : " + font.FontName + ", IsEmbedded : " + (font.IsEmbedded == true ? "Yes" : "No"));
 }
} 

In case of any further assistance, please feel free to contact us.


Best Regards,
Asad Ali

Thank you. That works. also i am trying to check the document for CMYK or RGB standards. is there anyway to find that out using ASPOS

@smandepudi

Thanks for your feedback.

It is good to know that your requirement has been achieved by the suggested approach.

I can see that you have created a separate topic for this requirement and it has been replied as well in the respective forum thread. You may check the reply there. In event of any further query, please feel free to contact us.


Best Regards,
Asad Ali

Is it possible for me to do the opposite. I have the font name, can I get the text matching the font names?

regards,
AR

@adzapp

Would you please share your sample PDF document with us. We will test the scenario in our environment and address it accordingly.