We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

.NET Core, DocIO and PDF Conversion - fonts completely messed up

Thread ID:

Created:

Updated:

Platform:

Replies:

141289 Dec 4,2018 02:54 PM UTC Dec 18,2018 06:52 AM UTC ASP.NET Core - EJ 2 13
loading
Tags: DocIO
Paul Kocher
Asked On December 4, 2018 02:54 PM UTC

Hello!
I'm trying to generate a PDF-File -> I use DocIO to execute a MailMerge operation and then convert it to PDF and send it to my client to view it.
The template I'm using has a custom font which is installed on my PC but the result is just a mess. I couldn't find anything about embedding fonts
when using MailMerge / a template file.
This is what the result looks like:

What seems to be the problem here?
This is my code:
[HttpPost] public async Task Arbeitsvertrag([FromBody]CreateArbeitsvertragModel model) { string basePath = _hostingEnvironment.WebRootPath; string template = basePath + @"/Vorlagen/Arbeitsvertrag/Vollzeit/Arbeitsvertrag_VZ.docx"; FileStream fileStream = new FileStream(template, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); WordDocument document = new WordDocument(fileStream, FormatType.Docx); List employeeData = await GetEmployeeDataVZ(model); MailMergeDataTable mailMergeDataTable = new MailMergeDataTable("Mitarbeiter", employeeData); document.MailMerge.ExecuteGroup(mailMergeDataTable); DocIORenderer render = new DocIORenderer(); PdfDocument pdfDocument = render.ConvertToPDF(document); render.Dispose(); document.Dispose(); MemoryStream stream = new MemoryStream(); pdfDocument.Save(stream); stream.Position = 0; pdfDocument.Close(true); string contentType = "application/pdf"; return new FileStreamResult(stream, contentType); }

Prakash Kumar D [Syncfusion]
Replied On December 5, 2018 09:53 AM UTC

Hi Paul, 
 
Thank you for contacting Syncfusion support. Please find the details below 
 
Regarding the mess with resultant document: 
On analysis the given screenshot, we suspect that the issue might be with embed fonts. Kindly share us the input document to analyze further from our side and provide you the prompt solution at earliest. 
 
Note: The documents shared will not be disclosed and is only for the purpose to reproduce the issue. We assure you that the document will be deleted from our side once the issue is resolved. 
 
Regarding the query I couldn't find anything about embedding fonts 
We have already implemented the API to embed fonts in PDF document while converting Word document into Pdf using DocIORenderer. It will be available in our upcoming 2018 Volume 4 release at the mid of December 2018 tentatively.

We suggest you set the below API to embed the fonts in converted PDF which will be available in 2018 Volume 4 release. Please refer the below code snippet: 
 
//Instantiates DocIORenderer instance for Word to PDF conversion  
DocIORenderer renderer = new DocIORenderer();  
//Sets EmbedFonts property as true, to embed fonts in resultant PDF  
renderer.Settings.EmbedFonts = true;  
//Sets EmbedCompleteFonts property as true, to embed complete font information in converted PDF  
renderer.Settings.EmbedCompleteFonts = true;  
  
 
Regards, 
Prakash Kumar 


Paul Kocher
Replied On December 5, 2018 10:44 AM UTC

Hello Prakash,

where can I send the document to? Do you need the font for it, too?

Prakash Kumar D [Syncfusion]
Replied On December 6, 2018 10:14 AM UTC

Hi Paul, 
 
Regarding where can I send the document: 
You can send the document to support@syncfusion.com with the forum Id in subject line.  
 
Regarding Do you need the font for it, too: 
Yes, kindly share the fonts used in the input Word document. It will be more helpful to analyze at our end and provide you the solution at earliest. 
 
Regards, 
Prakash Kumar 


Pieter van Kampen
Replied On December 6, 2018 04:05 PM UTC

Hi Paul, 
 
Thank you for contacting Syncfusion support. Please find the details below 
 
Regarding the mess with resultant document: 
On analysis the given screenshot, we suspect that the issue might be with embed fonts. Kindly share us the input document to analyze further from our side and provide you the prompt solution at earliest. 
 
Note: The documents shared will not be disclosed and is only for the purpose to reproduce the issue. We assure you that the document will be deleted from our side once the issue is resolved. 
 
Regarding the query I couldn't find anything about embedding fonts 
We have already implemented the API to embed fonts in PDF document while converting Word document into Pdf using DocIORenderer. It will be available in our upcoming 2018 Volume 4 release at the mid of December 2018 tentatively.

We suggest you set the below API to embed the fonts in converted PDF which will be available in 2018 Volume 4 release. Please refer the below code snippet: 
 
//Instantiates DocIORenderer instance for Word to PDF conversion  
DocIORenderer renderer = new DocIORenderer();  
//Sets EmbedFonts property as true, to embed fonts in resultant PDF  
renderer.Settings.EmbedFonts = true;  
//Sets EmbedCompleteFonts property as true, to embed complete font information in converted PDF  
renderer.Settings.EmbedCompleteFonts = true;  
  
 
Regards, 
Prakash Kumar 


Hi, I have the same thing when doing the conversation in asp.net core on a Windows Server 2012 R2 machine. Strangely enough, there is a difference when I generate the document and download it, compared to when a customer does it. Mine looks good, the one from the customer is scrambled, see the attached redacted screenshot. The generation is done on the same website in both cases. 
The font of both body and headers is Calibri.


Is there a beta for the Volume 4 so I can try the font embedding?

Attachment: scrambled_calibri_cb0e7682.zip

Pieter van Kampen
Replied On December 7, 2018 08:30 AM UTC

I have sent you a word document (calibri), its converted PDF, and how it looks scrambled at my customers' PC. As my customer stores it for later evidence, I think it is better to always embed the fonts in a PDF document.

Thanks

Pieter

Prakash Kumar D [Syncfusion]
Replied On December 11, 2018 10:52 AM UTC

Hi Paul, 
  
Thank you for updating us.  
  
We can reproduce the reported issue from the shared information and it was fixed in our 2018 volume 4 beta release. We suggest you upgrade to our latest version (16.40.40) of Essential Studio which has more bug fixes and enhancements which is available for download under the following link. 
  
 
 
Kindly try the above and let us know whether the issues are resolved at your end. 
 
Regards, 
Prakash Kumar 


Pieter van Kampen
Replied On December 12, 2018 12:40 AM UTC

Thank you, the conversion works, I am collecting confirmation whether it solves the problem on the customer end. 

Can you point me where I can get the license key for the beta? It is not in my account.

Prakash Kumar D [Syncfusion]
Replied On December 12, 2018 06:41 AM UTC

Hi Paul,  
 
Thank you for your interest in Syncfusion products. Please find the below KB link to get the license key 
 
You can get the license key from following link.  
  
  
  
  
 
 
Regards, 
Prakash Kumar 


Paul Kocher
Replied On December 17, 2018 10:16 AM UTC

Hello Prakash,

I tried the conversion with the beta version. Part of it is ok - the font successfully gets embedded BUT the line-spacing is off. It looks like there's no space between the lines at all plus there are some characters like parenthesis which look odd.

Is there a setting or anything? Also I sent my original document via email. The person you were replying to is someone else so maybe check the email you received with my doc/font.

This is how it is supposed to look (my original .docx):




This is how it looks:



I wouldn't really care about that but the problem is I'm using lines to place data on it. After conversion this is what it looks like:





Any idea?

Pieter van Kampen
Replied On December 17, 2018 10:21 AM UTC

Just wanted to confirm that for me the beta works fine. I don't have the line issue @Paul Kocher has described in the previous post. 

I used this for the conversion

            DocIORenderer render = new DocIORenderer();
            
            render.Settings.EmbedFonts = true;
            render.Settings.PdfConformanceLevel = PdfConformanceLevel.Pdf_A1B;
            render.Settings.AutoTag = true;
            PdfDocument pdfDocument = render.ConvertToPDF(doc);

Prakash Kumar D [Syncfusion]
Replied On December 17, 2018 04:50 PM UTC

Hi Pieter, 
 
Thank you for updating us. We glad that the issue is resolved at your end.  
 
Regards, 
Prakash Kumar 
 
Hi Paul, 
 
Thank you for using Syncfusion products. 
 
We are using SkiaSharp Graphics library to layout and render the content in Word to PDF conversion in ASP.NET Core. The text height calculation of SkiaSharp is not exactly equal to GDI+ library (.Net Framework), so that line spacing is not proper in generated PDF. Already, we have planned to enhance the Word to PDF conversion in portable platforms for 2019 Volume 1 main release which will be available by March 2019 tentatively. 
 
Regards, 
Prakash Kumar

Paul Kocher
Replied On December 18, 2018 06:22 AM UTC

Hello Prakash,

thanks for your answer. That's no problem. I will be using plain .docx until this is fixed.

Also thanks to you Pieter for sharing your settings - didn't work but still

Paul

Prakash Kumar D [Syncfusion]
Replied On December 18, 2018 06:52 AM UTC

Hi Paul, 
 
Thank you for updating us. We will let you know once the 2019 volume 1 main release is rolled out.   
 
Regards, 
Prakash Kumar 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;