response exported pdf

Hello

I need to export the document to pdf for the user to download it, the examples that I have found always save the pdf on the server, the idea is that the user can download it when exporting.



5 Replies 1 reply marked as answer

SM Suriya Murugan Syncfusion Team October 4, 2021 04:52 AM UTC

Hi Yosviel, 

Syncfusion Greetings! 

## Save document in client side as Pdf 

In client side using pdf-export component (works like print as PDF) – all pages will be converted to image and inserted as pdf pages. (can’t search the text) 

We have provided client side export pdf as image from version 19.1.67. To use this feature, Kindly install below package for Pdf export    


Please check below sample  


In this sample,   
  
1. The document content in the exported pdf is preserved as image.    
2. You can directly download the pdf file using download option.   

    
   

## Save as pdf to server  

We have support for converting Docx to PDF in server side by using “Syncfusion.DocIORenderer.Net.Core” library.  
We have prepared a sample to save the document as PDF in server side in ASP.NET Core. please find the sample from following link.  
In above sample, on Save as Pdf button click, document will save in wwwroot/files folder.  

You can customize it based on your requirement.  
   


Regards, 
Suriya M. 



YO Yosviel October 5, 2021 08:09 PM UTC

Thanks

I am exporting to pdf from another system, which has the document's json stored, and when the pdf that it exports, the page break does not match the document that is displayed in the visual component. This is my code:


public JsonResult ToPdf(ExportData data)
{
var wordDocument = WordDocument.Save(data.DocumentData, FormatType.Docx);

var render = new DocIORenderer
{
Settings =
{
AutoTag = true,
EmbedCompleteFonts = true,
OptimizeIdenticalImages = true,
AutoDetectComplexScript = true,
ExportBookmarks = Syncfusion.DocIO.ExportBookmarkType.Headings |
Syncfusion.DocIO.ExportBookmarkType.Bookmarks
}
};

//Converts Word document into PDF document
var pdfDocument = render.ConvertToPDF(wordDocument);
render.Dispose();
wordDocument.Dispose();

//Saves the PDF file
var outputStream = new MemoryStream();
pdfDocument.Save(outputStream);
pdfDocument.Close();

//Save the PDF stream in folder
var path = GetPathToExport(data);
var fileStream = new FileStream(path, FileMode.OpenOrCreate,
FileAccess.ReadWrite);
outputStream.Position = 0;
outputStream.CopyTo(fileStream);
outputStream.Close();
fileStream.Close();

return Json(new { fileName = path });
}



YO Yosviel replied to Lokesh Baskar October 6, 2021 02:32 PM UTC

Hello

Here I attach the document and the exported pdf, a capture of the document editor implemented with version 19.2.60, and the api I am using version 19.3.0.43 in net5.0.

This problem happens to me with all documents, not just this one.

Thanks for your time

Greetings


Attachment: resource_6e0ac2ba.rar


SM Suriya Murugan Syncfusion Team October 7, 2021 10:35 AM UTC

Hi Yosviel, 


Please upgrade your Document editor version to latest 19.3.0.44. We have added some improvements for text measuring. 


Please check in below screenshot: 

 



Note: Staring from v19.3.0.x, we have optimized the accuracy of text size measurements such as to match Microsoft Word pagination for most Word documents. This improvement is included as default behavior along with an optional API to disable it and retain the document pagination behavior of older versions. 
 

Regards, 
Suriya M. 


Marked as answer
Loader.
Up arrow icon