Error when adding ExportPDF endpoint on Document server

Hi, I am using Syncfusion's React Document Editor for my application and Document Server with docker-compose,

My application needs a feature for exporting the document in Docx and PDF format, but as far as i know, there's no built-in support in the document server for this

https://ej2.syncfusion.com/react/documentation/document-editor/how-to/export-document-as-pdf#export-document-as-pdf-in-server-side-using-syncfusion-docio


So following the documentation, i've modified the document server code and include the new endpoint:

```

[AcceptVerbs("Post")]
[HttpPost]
[Route("ExportPdf")]
public FileStreamResult ExportPdf([FromBody] SaveParameter data)
{
// Converts the sfdt to stream
Stream document = Syncfusion.EJ2.DocumentEditor.WordDocument.Save(data.Content, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);
SfDLS.WordDocument doc = new SfDLS.WordDocument(document, Syncfusion.DocIO.FormatType.Docx);
//Instantiation of DocIORenderer for Word to PDF conversion
DocIORenderer render = new DocIORenderer();
//Converts Word document into PDF document
PdfDocument pdfDocument = render.ConvertToPDF(doc);
Stream stream = new MemoryStream();
//Saves the PDF file
pdfDocument.Save(stream);
stream.Position = 0;
pdfDocument.Close();
document.Close();
return new FileStreamResult(stream, "application/pdf")
{
FileDownloadName = data.FileName
};
}

```

However this API only works for docx document with little to no content at all (and all text contents are removed in the resulting document), when called with almost any docx document, it will throw the following error:

"

System.ArgumentNullException: Value cannot be null. (Parameter 'asset')
   at SkiaSharp.HarfBuzz.BlobExtensions.ToHarfBuzzBlob(SKStreamAsset asset)
   at Syncfusion.Drawing.SkiaSharpHelper.FontExtension.MeasureText(String text, FontScriptType scriptType)

"


I don't know which part i should edit since i dont control the calls to the SkiaSharp library.


1 Reply

DS Dhanush Sekar Syncfusion Team April 16, 2024 01:05 PM UTC

Hi Salman,


Based on the details provided, it seems that your requirement is to convert a Word document to PDF using Docker. In order to resolve this issue, we recommend checking for the following packages are installed while using Docker for the Word to PDF conversion:
1. SkiaSharp.NativeAssets.Linux v2.88.6
2. HarfBuzzSharp.NativeAssets.Linux v7.3.0

You can refer to the below UG documentation
Word document to PDF Conversion in Linux Docker | DocIO | Syncfusion

If you are still experiencing issues after installing those packages, the problem may be specific to the input Word document. Please share the input Word document and a sample that reproduces the issue with us. Therefore, we will further analyze and provide appropriate details as soon as possible.


Regards,

Dhanush Sekar


Loader.
Up arrow icon