Embed fonts?

Hi, in my system, I need to embed all the fonts in the result file (save/export document with fonts ?). Does the Aspose.Words

library can do that ? I can’t find any topics or code abut that

Hi,

Thanks for your inquiry. Sure, you can control how fonts are embedded into the resulting PDF documents by using the PdfSaveOptions.EmbedFullFonts property. The default value of this property is false, which means the fonts are subsetted before embedding. Subsetting is useful if you want to keep the output file size smaller. Subsetting removes all unused glyphs from a font.

When this value is set to true, a complete font file is embedded into PDF without subsetting. This will result in larger output files, but can be a useful option when you want to edit the resulting PDF later (e.g. add more text).

Some fonts are large (several megabytes) and embedding them without subsetting will result in large output documents.

Aspose.Words might ignore this setting and embed a full font if the font is not subsettable.

Moreover, I would suggest you please read the following article on How Aspose.Words Uses True Type Fonts during rendering/printing:
https://docs.aspose.com/words/net/using-truetype-fonts/

Please let me know if I can be of any further assistance.

Best Regards,

Thanks for Your reply. I’ve tried
EmbedFullFonts property (I’ve used all installed fonts in the document) , but it seems that You are using a different style of saving the PDF file rather than the MS Office 2007 does - the same file has different size and value (viewing by a Notepad). But the appereance of the both files is the same. I need to convert the Your PDF file version using the external application (Nice PDF Converter (I suppose I’m allowed to put this name on the forum)) After that conversion, Your file is successfully rendered by the external online PDF library system (without that manual conversion it fails and I can’t view it on the web). So, is there any possibility to go around - I don’t want to manual convert the PDF’s file version. Or maybe I can set some properties in the code to make this work ? In other words, to change the PDF save method to be similar like the MS Office’s ?

Hi,

Thanks for your inquiry. Please note that Aspose.Words page layout engine tries to mimic the way the Microsoft Word’s page layout engine works. To you, this means that if you convert a Microsoft Word document into PDF, XPS or print it using Aspose.Words, the output will appear almost exactly as if it was done by Microsoft Word.

Regarding the difference in output PDF files sizes, could you please attach your input Word document here for testing? I will investigate the issue on my side and provide you more information.

Moreover, I would suggest you please upgrade to the latest version of Aspose.Words i.e. 11.3.0 and let us know how it goes with your external online PDF library system? I hope, this will help.

Best Regards,

Hi, thanks for Your reply.

Some things:

  1. I’ve included a .NET (C#) code with description

  2. I’ve attached some files:

    1. file_result_16.doc is the file generated by the latest version of the Aspose.Words library
    2. file_result_16_office.doc is from above but it was opened and re-saved using MS Words 2007
  3. Now, using that code (from point #6) I’ve created file_result_16.doc (1) and file_result_16.pdf (3). Then, I’ve opened file_result_16.doc in MS Word 2007 and re-saved it as file_result_16_office.doc (2) and (embedding fonts in the document) as file_result_16_office.pdf (4)

  4. I’ uploaded that files above to issuu.com (the external online PDF library system I was talking about previously is issuu.com*)

    (1)* *issuu.com/tomaszaugustyniak/docs/aspose_doc_1*

    (2) *issuu.com/tomaszaugustyniak/docs/aspose_to_office_1*

    (3) *issuu.com/tomaszaugustyniak/docs/aspose_pdf_1*

    (4) *issuu.com/tomaszaugustyniak/docs/aspose_office_word_pdf**

    You can see that after the conversion that documents looks different, only the 4th file, PDF re-saved using MS Word looks the same. So, something’s wrong with the PDF file generated by the Aspose.Words library. Or maybe I’m doing somenthing wrong

    Here You have the .NET (C#) code which generates some .DOC and .PDF files (simply, it gets the fonts list installed on the computer and then it builds a table where in each row there is font name rendered as the font looks)

private void generate()
{
    Aspose.Words.Document ebook = new Aspose.Words.Document(@"c:\file.doc");
    Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(ebook);

    System.Drawing.Text.InstalledFontCollection fontColl = new System.Drawing.Text.InstalledFontCollection();

    int min = 0;
    int max = 17;

    for (int i = min; i < max; i++)
    {
        Aspose.Words.Font font = builder.Font;
        font.Subscript = true;

        font.Color = System.Drawing.Color.Black;

        font.Name = fontColl.Families[i].Name;
        font.Size = 20;

        Aspose.Words.Tables.Table table = builder.StartTable();

        builder.InsertCell();
        table.AutoFit(Aspose.Words.Tables.AutoFitBehavior.FixedColumnWidths);
        builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;
        builder.Write(fontColl.Families[i].Name);

        builder.EndRow();
        builder.EndTable();
        table.PreferredWidth = Aspose.Words.Tables.PreferredWidth.FromPoints(500);
        if (i == (max - 1))
        {
            ebook.Save(@"c:\file_result_" + i.ToString() + ".doc", Aspose.Words.SaveFormat.Doc);
            Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
            options.EmbedFullFonts = true;
            options.EmbedStandardWindowsFonts = true;
            ebook.Save(@"c:\file_result_" + i.ToString() + ".pdf", options);
        }
    }
}

Hi,

Thanks for your inquiry. First of all, please note that Aspose.Words requires TrueType fonts when rendering documents to fixed-page formats (PDF, XPS or SWF). For more information, I would suggest you please read the following articles:

https://docs.aspose.com/words/net/using-truetype-fonts/
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/

During rendering ‘file_result_16_office.doc’ to PDF format, I found Aspose.Words substitutes the missing fonts, i.e. ‘AmazoneEU’ and ‘AmeriGarmndEU’, with the defaulet font i.e. ‘Times New Roman’. In order to get your document rendered correctly, you need to install these two fonts.

Moreover, the links mentioned in your 4th point seem broken to me. All of them are returning Page Not Found error page.

Best Regards,

Hi, thanks for Your quick reply.

I’ve edited my previous post, all links are a plain text and they’re working now.

That two missing fonts are installed on my computer and I see them rendered properly in the DOC/PDF file.

All fonts used in the DOC/PDF file are installed on my computer (I can see all of them rendered body)

I’ve checked one more thing. I’ve created the same PDF file using the code I’ve posted. I’ve also set that properties before saving.

options.EmbedFullFonts = false;
options.EmbedStandardWindowsFonts = false;

Then, I’ve converted that PDF version (from 1.5 to 1.5 - just for test) using an external software (I don’t know if I’m allowed to post that software name here, so if You want to know its name I can send You a private message. Just say and I’ll send)

After I’ve uploaded the final PDF file, it have been rendered properly (the same like the 4th link have). I’ve attached that two files, the original file that Aspose.Words generated and its converted version by that external software. The file sizes are different but they looks the same.

So, it seems that the way that Your library saves the PDF file is deviated from the PDF file standard ?

The fact is, that PDF generating and uploading will be automated process and there will be no possbility for handy-converting the PDF version to get everything work. I need to use only Your library.

Best regards,
Tomasz

Hi Tomasz,

Thanks for the additional information and sorry for the delayed response. I have uploaded a PDF document, i.e. generated on my side, here for your reference. I have generated this file by using Aspose.Words for .NET v11.4.0 and your code. Please let us know how this PDF goes with your external online PDF library system?

Best Regards,

@Tony66366,
The issues you have found earlier (filed as WORDSNET-4150 and WORDSNET-4151) have been fixed in this Aspose.Words for .NET 17.10 update and this Aspose.Words for Java 17.10 update.