Angular (Document Editor) + Net Core (Doc IO) + Docx To PDF

Implement the
 option to export from word to pdf with the Document Editor

The user opens a word document.

It gives you export to pdf, angular sends the blog to the server and with DocIO it exports to PDF.

In this case, take the example document that has some images.

Attached I send the word document of the server generated correctly and the exported pdf document. Some additional lines are presented that do not comply with the correct format.


Attached word document and pdf, as well as the image of the pdf



Attachment: WordToPdf_d63573cd.zip

4 Replies 1 reply marked as answer

BO Boris replied to Boris November 4, 2020 03:00 AM UTC

Implement the
 option to export from word to pdf with the Document Editor

The user opens a word document.

It gives you export to pdf, angular sends the blog to the server and with DocIO it exports to PDF.

In this case, take the example document that has some images.

Attached I send the word document of the server generated correctly and the exported pdf document. Some additional lines are presented that do not comply with the correct format.


Attached word document and pdf, as well as the image of the pdf



Attachment: WordToPdf_d63573cd.zip


I do not understand

From a unit test it works fine, but from an api it doesn't work correct.


//API controller for the conversion. (it does not work)
[AcceptVerbs("Post")]
[HttpPost]
[EnableCors("AllowAllOrigins")]
[Route("ExportPdf")]
public void ExportAsPdfSinPost()
{
//Open the file as Stream
var docStream = new FileStream(@"G:\2019\Ejemplo.docx", FileMode.Open, FileAccess.Read);
//Loads file stream into Word document
var wordDocument = new WDocument(docStream, Syncfusion.DocIO.FormatType.Automatic);
//Instantiation of DocIORenderer for Word to PDF conversion
var render = new DocIORenderer();
//Sets Chart rendering Options.
render.Settings.ChartRenderingOptions.ImageFormat = ExportImageFormat.Jpeg;
//Converts Word document into PDF document
var pdfDocument = render.ConvertToPDF(wordDocument);
//Releases all resources used by the Word document and DocIO Renderer objects
render.Dispose();
wordDocument.Dispose();
//Saves the PDF file
var outputStream = new MemoryStream();
pdfDocument.Save(outputStream);
//Closes the instance of PDF document object
pdfDocument.Close();

System.IO.File.WriteAllBytes(@"G:\2019\EjemploVoid.pdf",outputStream.ToArray());
}

it works
[Test]
public void TestToPdfejemploAngular()
{
//Open the file as Stream
var docStream = new FileStream(@".\Archivos\ejemploAngular.docx", FileMode.Open, FileAccess.Read);
//Loads file stream into Word document
var wordDocument = new WordDocument(docStream, Syncfusion.DocIO.FormatType.Automatic);
//Instantiation of DocIORenderer for Word to PDF conversion
var render = new DocIORenderer();
//Sets Chart rendering Options.
render.Settings.ChartRenderingOptions.ImageFormat = ExportImageFormat.Jpeg;
//Converts Word document into PDF document
var pdfDocument = render.ConvertToPDF(wordDocument);
//Releases all resources used by the Word document and DocIO Renderer objects
render.Dispose();
wordDocument.Dispose();
//Saves the PDF file
var outputStream = new MemoryStream();
pdfDocument.Save(outputStream);
//Closes the instance of PDF document object
pdfDocument.Close();

File.WriteAllBytes(@".\Archivos\ejemploAngular.pdf",outputStream.ToArray());

Assert.IsTrue(File.Exists(@".\Archivos\ejemploAngular.pdf"));
}


HC Hemalatha Chiranjeevulu Syncfusion Team November 4, 2020 06:38 PM UTC

Hi Boris,

Thank you for contacting Syncfusion support.

We can reproduce the reported issue in our end, and we suspect it to be a defect. We will validate this issue and update you with more details on 6th November 2020.

Please let us know if you have any other questions.

Regards,
Hemalatha C.
 



MJ Mohanaselvam Jothi Syncfusion Team November 6, 2020 06:36 PM UTC

Hi Boris,

Thank you for your patience.

We have confirmed that the reported issue with “Image not preserved properly when converting Word document to PDF” is a defect and we have logged a defect report. Since you have been using our weekly release (v18.3.0.44), we will include the fix for this defect in our weekly NuGet release which is estimated to be available on 24th November 2020. 
 

Regards,
Mohanaselvam J
 



MJ Mohanaselvam Jothi Syncfusion Team November 25, 2020 03:43 AM UTC

Hi Boris,

Thank you for your patience.

We have included the fix in our latest Weekly NuGet v18.3.0.51. Kindly use our latest NuGet package to check the fix at your end.

Note: This fix will be included in our 2020 Volume 4 main release.

Regards,
Mohanaselvam J 


Marked as answer
Loader.
Up arrow icon