Free Support Forum - aspose.com

How to compress fonts with Aspose.Total for C++

Hi,

I want to compress fonts in files with Words, Slides, Cells and PDF.
Because the embedded fonts are too big.
Any idea?
Thanks.

I’m trying to write this funtion, but got some exceptions.

ppttopdf.font.err.txt.zip (1.4 KB)
ppttopdf.font.cpp.zip (2.0 KB)

@kngstr,

Regarding your question about Aspose.Slides for C++, there is no provision in API to compress the embedded fonts. We have created an investigation ticket with ID SLIDESCPP-2555 to check for the solution of this problem. We will keep you posted here on further updates.

Regarding Aspose.Words for C++, please try the following code to save a document without embedded TrueType fonts. The code should just remove any embedded fonts from Word document:

auto doc = MakeObject<Document>(MyDir + u"Document containing embedded fonts.docx");     
SharedPtr<Aspose::Words::Fonts::FontInfoCollection> fontInfos = doc->get_FontInfos();
fontInfos->set_EmbedTrueTypeFonts(false);
// fontInfos->set_EmbedSystemFonts(false);
// fontInfos->set_SaveSubsetFonts(false);
doc->Save(ArtifactsDir + u"Font.FontInfoCollection.docx");

Regarding Aspose.PDF for C++ API, please try the following code to optimize/compress PDF file:

auto doc = System::MakeObject<Document>(u"1.pdf");
auto opt = System::MakeObject<Aspose::Pdf::Optimization::OptimizationOptions>();
opt->set_AllowReusePageContent(true);
opt->set_LinkDuplcateStreams(true);
opt->set_RemoveUnusedObjects(true);
opt->set_RemoveUnusedStreams(true);
opt->get_ImageCompressionOptions()->set_CompressImages(true);
opt->get_ImageCompressionOptions()->set_Encoding(Aspose::Pdf::Optimization::ImageEncoding::Jpeg);
opt->get_ImageCompressionOptions()->set_ImageQuality(75);
opt->set_SubsetFonts(true);
doc->OptimizeResources(opt);
doc->Save(u"1.pdf");

You can also try : opt->set_UnembedFonts(true);

@awais.hafeez

Thanks.

// fontInfos->set_EmbedSystemFonts(false);
// fontInfos->set_SaveSubsetFonts(false);

Will this be supported for Words in the future?

BTW:Sildes proceed fonts very slow.

@kngstr,

These two options are also supported by Aspose.Words for C++ API. The EmbedSystemFonts property can be used to specify whether or not to embed System fonts into the Word document. The SaveSubsetFonts property can be used to specify whether or not to save a subset of the embedded TrueType fonts with the document. Note that this option works only when EmbedTrueTypeFonts property is set to true.

We will update you here soon.

Can you please elaborate the above and share findings in the form of comparison and statistics where you have observed the API performing slow while working with fonts. Perhaps, a working sample project along with snapshot of statistics and expected response may be provided so that we may investigate that as well.

@awais.hafeez

Thanks.

@mudassir.fayyaz

File is too big to upload.
You can download from here: https://share.weiyun.com/MiyqiZLL.

@kngstr

Can you please share the sample presentation along with used sample project on some public file server. The link you have shared ask for either QQ or WeChat accounts that we don’t have.

@mudassir.fayyaz

Try this link https://pan.baidu.com/s/1HR4sRRhRNPcrFyN6e58z-A password: cxax
The project was uploaded already. Look at post above

@kngstr

The link seems to be expired. Can you please share again with us.

@mudassir.fayyaz

It’s not expired.
If you can not download.
Try this link: http://dl.05nx.com/aspose.test.7z

@kngstr

Thank you for sharing this. Now, I can access that on my end.