Cleanup of embedded fonts and tansparency in the PDF

Hi ,

I have a scenario where I need to do the cleanup of the embedded fonts if persent in the PDF and also for the tansparent images in the PDF.

Please advice if aspose has any such feature to do the cleanup post detecting this in the PDF. Currenly I am able to do the detection of embedded fonts and transparent images in the PDF. I just want to know if the cleanup is possible .

Thanks,
Shilpi

Hi Shilpi,


Thanks for contacting support.

From cleanup, if you mean to remove the embedded fonts ? then you may consider using following code snippet.

[C#]

//Open the document<o:p></o:p>

Document doc = new
Document(@“C:\pdftest\test_03.pdf”);<o:p></o:p>

//Iterate through all the pages<o:p></o:p>

foreach (Page page in doc.Pages)<o:p></o:p>

{<o:p></o:p>

if (page.Resources.Fonts != null)<o:p></o:p>

{<o:p></o:p>

foreach (Aspose.Pdf.Text.Font
pageFont in page.Resources.Fonts)<o:p></o:p>

{<o:p></o:p>

//Check if font is already embedded<o:p></o:p>

if (pageFont.IsEmbedded)<o:p></o:p>


pageFont.IsSubset = pageFont.IsEmbedded = false;<o:p></o:p>

}<o:p></o:p>

}<o:p></o:p>

//Check for the Form objects<o:p></o:p>

foreach (XForm
form in page.Resources.Forms)<o:p></o:p>

{<o:p></o:p>

if (form.Resources.Fonts != null)<o:p></o:p>

{<o:p></o:p>

foreach (Aspose.Pdf.Text.Font
formFont in form.Resources.Fonts)<o:p></o:p>

{<o:p></o:p>


//Check if the font is embedded<o:p></o:p>


if (formFont.IsEmbedded)<o:p></o:p>


formFont.IsSubset = formFont.IsEmbedded = false;<o:p></o:p>

}<o:p></o:p>

}<o:p></o:p>

}<o:p></o:p>

}
//Save the document<o:p></o:p>

doc.Save(@“C:\pdftest\test_03_outut.pdf”);


Now concerning to removing the image, please follow the instructions specified over Delete Images from a PDF File