Font style is changed and number of pages are increased in deploy version of linux

I am able to get the expected converted version of the given document in my local which is windows. And when I am trying to do the same thing on the deploy version the generated file is not expected like it changes font style as well as increase the page count like i have 2 pages docx file that i want to convert in pdf it will be converted successfully but it expand upto 3 pages.

I use this code for converison:

Aspose.Words.License wordslic = new Aspose.Words.License();
wordslic.SetLicense("Aspose.Totalfor.NET.lic");

using (var docStream = new MemoryStream(inputBytes))
{
    using (var saveStream = new MemoryStream())
    {
        var document = new Aspose.Words.Document(docStream);
        Aspose.Words.Saving.PdfSaveOptions saveOptions = new Aspose.Words.Saving.PdfSaveOptions();
        saveOptions.EmbedFullFonts = true;
        document.Save(saveStream, saveOptions);
        return saveStream.ToArray();
    }
}

Is there any other solution that resolve this without installing the required fonts into server.
Thanks

@cdayalal

The issue you’re experiencing with font style changes and an increased page count when converting documents from DOCX to PDF on a Linux deployment could be related to font availability and rendering differences between your local Windows environment and the Linux server.

Possible Solutions:

  1. Install Required Fonts:
    Ensure that the necessary TrueType fonts are installed on your Linux server. Aspose.Words requires access to the fonts used in your documents to render them accurately. If the fonts are not available, Aspose.Words will substitute them with similar fonts, which can lead to changes in appearance and layout, including page count.

  2. Embed Fonts:
    You are already using the EmbedFullFonts option in your PdfSaveOptions, which is good. This setting ensures that all font glyphs used in the document are embedded in the PDF. However, if the original fonts are not available on the server, this will not resolve the issue.

  3. Font Settings Configuration:
    You can configure the FontSettings class to specify the folder where Aspose.Words should look for fonts. This can help in ensuring that the correct fonts are used during the conversion process. Here’s an example of how to set it up:

    FontSettings fontSettings = new FontSettings();
    fontSettings.SetFontsFolder("/path/to/fonts", true); // Specify the path to your fonts
    document.FontSettings = fontSettings;
    
  4. Check Document Layout:
    Sometimes, differences in page layout can occur due to varying default settings for margins, page size, or other layout properties. Ensure that the document’s layout settings are consistent across environments.

  5. Testing with Different PDF Save Options:
    Experiment with different settings in PdfSaveOptions to see if they affect the output. For example, you might want to try adjusting the PdfCompliance level or other properties that control how the document is rendered.

Conclusion:

By ensuring that the required fonts are installed on your Linux server and properly configuring the font settings in your code, you should be able to achieve consistent results between your local and deployed environments. If the problem persists, consider reviewing the document’s layout settings and experimenting with different PDF save options.

If you need further assistance, feel free to ask!

Sources:
[1]: Manipulate and Substitute TrueType Fonts - Aspose Documentation
[2]: Options When Converting to PDF|Aspose.Words for .NET

Hi,

I installed the fonts into the deployed server and Use the below code for making document EmbededFonts true

var wordDoc = new Aspose.Words.Document(inputStream);
var pdfSaveOptions = new Aspose.Words.Saving.PdfSaveOptions
{
    EmbedFullFonts = true
};
wordDoc.Save(outputStream, pdfSaveOptions);

but it increase the size of generated pdf file more than the size of the requested document like it increase upto 50% size of pdf file

Thanks

@cdayalal When you enable PdfSaveOptions.EmbedFullFonts option, the whole font files are embedded into the output document. Usually this might be required if the PDF document will be edited. If it is not the case, you can safely disable this option, in this case Aspose.Words will embed subset of fonts, i.e. only glyphs used in the document. This is the common scenario and allows significantly reduce the output document size.