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

Free Support Forum - aspose.com

How to partialy embed font in existing pdf

Hi,

We have a pdf document with the following font :

MyriadPro-Regular (Incorporé(e(s))

Type : Type 1

Encodage : ANSI


We need to have this police partialy embeded this way :

MyriadPro-Regular (Jeux partiels incorporés)

Type : Type 1

Encodage : Personalisés


The only way we managed to do that is to open the PDF with Adobe Pro, export it as .ps file, than recreate the PDF with Distiller.

Can we do the same thing using Aspose in a C# program?

Thanks,

Frank

Hi Frank,


Thanks for contacting support.

As per my understanding, you need to replace the font in existing PDF file. If so is the case, then please try following the instructions specified over Replace fonts in existing PDF file.

Besides above mentioned approach, if you need to trim down fonts used by PDF document to subsets, this functionality to control font subsetting is declared in interface Document.IDocumentFontUtilities. Every object of type Aspose.Pdf.Document has property FontUtilities of type IDocumentFontUtilities. This interface includes method SubsetFonts(FontSubsetStrategy subsetStrategy).

Parameter subsetStrategy helps to tune subset strategy. Two variants of font subsetting are supported. It is possible to subset all fonts used by document(strategy SubsetAllFonts) or to subset only fully embedded fonts(or font subsets which are larger than it required by current document). In case 1(SubsetAllFonts) all fonts will be embedded into document. Font subset is embedded into PDF document by definition, but in case 2(SubsetEmbeddedFontsOnly) process will not affect fonts which are not embedded into document.

Specified below is the code snippet to reduce fully embedded font sets to only those subsets:

[C#]

//
load existing PDF file
<o:p></o:p>

Document doc = new Document(“doc.pdf”);<o:p></o:p>

//
embed font subset only
<o:p></o:p>

doc.FontUtilities.SubsetFonts(Document.FontSubsetStrategy.SubsetEmbeddedFontsOnly);<o:p></o:p>

//
save PDF document
<o:p></o:p>

doc.Save();

Hi,


I tried both method (SubsetAllFonts and SubsetEmbeddedFontsOnly) and it didn’t partialy embed my font. It still :
MyriadPro-Regular (Incorporé(e(s))
Type : Type 1
Encodage : ANSI

Do you have an idea why?

Thanks
Frank

Hi Frank,


Thanks for sharing the updates.

Can you please share the input PDF file, so that we can test the scenario in our environment. We are sorry for this inconvenience.