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

Free Support Forum - aspose.com

Convert DOCX with Images to PDF on .NET Core 3.1 over Linux Server | Goelze.SkiaSharp.NativeAssets NuGet

Hello,
we have aspose.total license and using aspose v19.11. Through DotNet Core 3.1 project I am trying to Aspose MailMerge word document and push signatures in it which is working fine. However, when I am saving that file as PDF, signature images are missing in it. please note project is hosted on linux environment.
For your reference I am attaching output document after mail merge for your reference. Which I tried to save as PDF but signature images missing in it.
Application.zip (27.7 KB)
Note, I have implemented WarningCallback() but it did not log anything.

 doc.WarningCallback = new HandleDocumentSubstitutionWarnings();

Code of Adding image to word.

DocumentBuilder mBuilder = new DocumentBuilder(e.Document);
mBuilder.MoveToMergeField(e.FieldName);
byte[] file = Convert.FromBase64String(e.FieldValue.ToString());
WORDS.Drawing.Shape shape = mBuilder.InsertImage(file);
shape.WrapType = WORDS.Drawing.WrapType.None;
if (e.DocumentFieldName.ToLower() == "signature")
{
    shape.Width = 80;
    shape.Height = 40;
    shape.Font.Name = "DejaVuSans";
}
e.Text = "";

This is urgent for me so please revert back with your suggestions.

@sandip.shimpi,

If Aspose.Words for .NET Standard is intended to be used in Linux environment, an additional NuGet package should be referenced to make it work correctly with graphics: SkiaSharp.NativeAssets.Linux for Ubuntu (it also should work on most Debian-based Linux distributions) or Goelze.SkiaSharp.NativeAssets.AlpineLinux for Alpine Linux.

Thanks for your reply Awais. This solved my docx image export issue to PDF.
In document I have used Arial font which is there on linux server but special character like $ showing square symbol. Any idea?

Fyi, we have following packages added to project.

RUN apt-get install -y libfreetype6
RUN apt-get install -y libfontconfig1

please assist. Thanks

@sandip.shimpi,

Please copy the latest versions of required font files from Windows 10 machine into a separate folder inside Linux machine and try running the following C# code of latest 21.3 version of Aspose.Words for .NET:

Document doc = new Document("C:\\Temp\\word.docx");

FontSettings fontSettings = new FontSettings();
AddCustomFontsFolder(fontSettings, @"C:\Temp\Helvetica\Helvetica\");
doc.FontSettings = fontSettings;

doc.Save(@"C:\Temp\31.3.pdf");

private static void AddCustomFontsFolder(FontSettings fontSettings, string folder)
{
    ArrayList fontSources = new ArrayList(fontSettings.GetFontsSources());

    // Add a new folder source which will instruct Aspose.Words to search the following folder for fonts.
    FolderFontSource folderFontSource = new FolderFontSource(folder, true);

    // Add the custom folder which contains our fonts to the list of existing font sources.
    fontSources.Add(folderFontSource);

    // Convert the Arraylist of source back into a primitive array of FontSource objects.
    FontSourceBase[] updatedFontSources = (FontSourceBase[])fontSources.ToArray(typeof(FontSourceBase));

    // Apply the new set of font sources to use.
    fontSettings.SetFontsSources(updatedFontSources);
}

Thanks Awais.

Can we ran macros defined in mailmerge document through aspose library?

@sandip.shimpi,

I am afraid, Aspose.Words cannot execute VBA Macros in Word document. What Aspose.Words currently can do is, if your template Word document has Macros and when you save it using Aspose.Words, those Macros will remain preserved in output Word document.