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

Free Support Forum - aspose.com

Images are blank when converting to PDF

We are converting a Word document with images to a PDF, which seems to run fine on my Windows PC as well as my Macbook. However, with the code executing on our Linux server, the PDF rendered does not have the images; or they appear blank. The code we are using is, approximately, the following:

var bytes = Convert.FromBase64String(base64data);
var fieldRefs = JsonConvert.DeserializeObject<DocumentHelper.FieldReferenceInfo[]>(fieldRefData);
var document = new Aspose.Words.Document(new MemoryStream(bytes));
var docStream = new MemoryStream();
PdfSaveOptions options = new PdfSaveOptions();
options.EmbedFullFonts = true;
document.Save(docStream, options);

I added some test code to see if the image nodes are detected in the document, and Aspose still has Shape nodes that contain the images, but the final document is blank.

I should note, this is a C# application running in .NET Core.

Note that when I observe the Aspose.Words.Document object, I can find in the ChildNodes that there are Shape nodes that have ImageData corresponding to the images included in the document. However, the PDF generated from saving is only 2 Kb, and definitely doesn’t have the images in any form.

@bkane521 Aspose.Words for .NET Standard uses SkiaSharp to work with graphics. To make it work properly on Linux you should add reference to SkiaSharp.NativeAssets.Linux or to SkiaSharp.NativeAssets.Linux.NoDependencies. In case of using SkiaSharp.NativeAssets.Linux you should also install libfontconfig1.

apt-get update && apt-get install -y libfontconfig1

On Windows and on Mac no additional packages are required because native assets for these platforms are included into SkiaSharp package.

We did have SkiaSharp installed, but it must have been an incompatible version because we updated the library and now everything seems to be working correctly. Is there a reason SkiaSharp isn’t packaged as a dependency for Aspose so that it is automatically installed alongside?

@bkane521 SkiaSharp is packaged as a dependency of Aspose.Words (please see Dependencies section in the Aspose.Words Nuget package.), but SkiaSharp.NativeAssets.Linux is not, because it is only required when you run on Linux. Because of this reason skia Linux native assets are not included into SkiaSharp package and not listed in its dependencies.