Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Dec 03, 2024 7:00 pm

.Net8
Windows 64
Spire.Doc 12.10.13
Spire.pdf 10.11.1
c# Console App

When I convert a word doc to a pdf, it does not look like it is respecting the CR LF in the word doc.

Attached are 3 files.

The word doc.
The pdf doc before we upgraded.
the pdf after we upgraded.

Code: Select all
private static void SaveToStream(Spire.Doc.Document wordDocument, string reportName, Stream stream)
{
   var mStream = new MemoryStream();
   var pdfParams = GetPdfParameterList(reportName);
   wordDocument.BookmarkLayout += document_BookmarkLayout;
   wordDocument.SaveToStream(mStream, pdfParams);

   //now opend it backup and enable the bookmarks to be visible in the browser.
   var pdfdoc = new PdfDocument();
   pdfdoc.LoadFromStream(mStream);
   pdfdoc.ViewerPreferences.FitWindow = true;
   pdfdoc.ViewerPreferences.PageMode = PdfPageMode.UseOutlines;
   pdfdoc.SaveToStream(stream);

   stream.Flush();

   wordDocument.Close();
}



private static ToPdfParameterList GetPdfParameterList(string reportName)
{
   var pdfParams = new ToPdfParameterList();
//         pdfParams.EmbeddedFontNameList.Add("Letter Gothic");

   //This works.  When testing remember we have a Group policy that installs the font to your fonts folder every 30 min or so.
   //pdfParams.PrivateFontPaths = new List<PrivateFontPath>() { new PrivateFontPath("LetGoth", @"c:\temp\_fonts\LETGOT.TTF") };

   //TPS - The font is added to the project and marked as "Content" and Always copy.  Shooting for the font to land in the final deployed bin/exe folder.
   pdfParams.PrivateFontPaths = new List<PrivateFontPath>() { new PrivateFontPath("LetGoth", "LETGOT.TTF") };


   //toPdf.UsePSCoversion = true; //added at suggestion of spire tech support to fix website gdi error. Adding this causes the below font additions to fail.
   //can't use PSConversion on web per this tech support forum.
   //https://www.e-iceblue.com/forum/topdf-usepscoversion-true-causes-font-issue-t7016.html
   //pdfParams.PrivateFontPaths.Add(new PrivateFontPath("Letter Gothic", FontStyle.Regular, "LETGOT.TTF"));
   //pdfParams.PrivateFontPaths.Add(new PrivateFontPath("Letter Gothic", FontStyle.Bold, "LETGOTB.TTF"));

   pdfParams.CreateWordBookmarks = true;
   pdfParams.WordBookmarksTitle = reportName;
   pdfParams.WordBookmarksColor = Color.Red;
   pdfParams.WordBookmarksTextStyle = BookmarkTextStyle.Bold;
   return pdfParams;
}



[email protected]
 
Posts: 106
Joined: Tue May 19, 2015 8:09 pm

Wed Dec 04, 2024 7:50 am

Hello,

Thank you for your feedback.

It appears that the Report_AfterUpgrade.pdf file you uploaded is incorrect, as its contents do not match those of your Word document.

I used Spire.Doc 12.10.13 to convert your Word document to PDF and was able to reproduce the issue where images in the header is covered up, as shown below. I have logged this issue in our system with the tracking number SPIREDOC-10992.
screenshot-1.png


Regarding the CR LF inconsistency issue you mentioned, I did not seem to notice it. I have attached the PDF file(PDF.zip) that I converted. Could you please assist me by pointing out where this issue occurs? Your help is greatly appreciated.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2908
Joined: Wed Jun 27, 2012 8:50 am

Wed Dec 04, 2024 4:06 pm

Yes, I see that you were able to convert the word document to pdf perfectly.

Could you post the code you used to do this?

Or could you determine what I did wrong in my code (I posted code in original post)?

Thank you.

[email protected]
 
Posts: 106
Joined: Tue May 19, 2015 8:09 pm

Wed Dec 04, 2024 4:28 pm

This screenshot shows before conversion - Perfect

PdfCRLF_BeforeUpgrade.png



This screenshot shows after conversion - Bad

PdfCRLF_AfterUpgrade.png

[email protected]
 
Posts: 106
Joined: Tue May 19, 2015 8:09 pm

Thu Dec 05, 2024 2:08 am

Hello,

Thank you for your response.

I tested using the code you provided. Here is my test code:
Code: Select all
Document document = new Document();
document.LoadFromFile(path + "Report.doc");
ToPdfParameterList pdfParams = new ToPdfParameterList();
pdfParams.CreateWordBookmarks = true;
pdfParams.WordBookmarksColor = Color.Red;
pdfParams.WordBookmarksTextStyle = BookmarkTextStyle.Bold;
document.SaveToFile(path + "NETCore6.0-Report.pdf", pdfParams);


I installed Spire.Doc via NuGet in my NET8.0 console app and am using the Spire.Doc.dll for NET6.0. The complete version number is 12.10.13.3360 (as seen in the properties of the Spire.Doc.dll file).

Could the difference be due to the Letter Gothic font we are using? The size of the font file I am using is 82KB. Could you please send me your Letter Gothic font file so that I can test with it?

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2908
Joined: Wed Jun 27, 2012 8:50 am

Thu Dec 05, 2024 6:46 pm

I got the cr lf working with your code.

Attached is the LetterGothic font we are using.

[email protected]
 
Posts: 106
Joined: Tue May 19, 2015 8:09 pm

Fri Dec 06, 2024 2:45 am

Hello,

Thank you for your feedback and for sharing your font files.

When the issue SPIREDOC-10992 is resolved, I will notify you accordingly.

If you have any further questions, please do not hesitate to contact us.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2908
Joined: Wed Jun 27, 2012 8:50 am

Fri Dec 06, 2024 6:57 pm

I have come up with a test that isolates the problem.

Code: Select all
ToPdfParameterList pdfParams = new ToPdfParameterList();
pdfParams.CreateWordBookmarks = true;
pdfParams.WordBookmarksColor = Color.Red;
pdfParams.WordBookmarksTextStyle = BookmarkTextStyle.Bold;


--This works

Code: Select all
Spire.Doc.Document documentFromCode = TmrWordUtil.TMRToWordDocument(tmrData, string.Empty, false);
documentFromCode.SaveToFile(docPath); //word document

Spire.Doc.Document documentFromFile = new();
documentFromFile.LoadFromFile(docPath);
documentFromFile.SaveToFile(pdfPath2, pdfParams); //pdf document


This does not work

Code: Select all
Spire.Doc.Document documentFromCode = TmrWordUtil.TMRToWordDocument(tmrData, string.Empty, false);
documentFromCode .SaveToFile(pdfPath2, pdfParams); //pdf document


If we convert the doc file that was generated and saved to disk, then loaded from disk, the header is ok.
If we convert the doc file that was generated, Without saving to disk, the header is bad.

[email protected]
 
Posts: 106
Joined: Tue May 19, 2015 8:09 pm

Mon Dec 09, 2024 2:24 am

Hello,

Thank you for sharing your findings. I will forward them to our development team.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2908
Joined: Wed Jun 27, 2012 8:50 am

Mon Dec 16, 2024 3:54 pm

>> I will forward them to our development team.

Any update on this topic?

We are dead in the water and cannot upgrade until the issues is resolved.

Thank you.

[email protected]
 
Posts: 106
Joined: Tue May 19, 2015 8:09 pm

Tue Dec 17, 2024 2:49 am

Hi,

We sincerely apologize for any inconvenience caused.

Given the urgency of your situation, our developers have prioritized and are expediting the handling of your issue. I will provide you with timely updates on the progress.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2908
Joined: Wed Jun 27, 2012 8:50 am

Mon Jan 06, 2025 6:30 pm

Any update on a fix for this issue?

[email protected]
 
Posts: 106
Joined: Tue May 19, 2015 8:09 pm

Tue Jan 07, 2025 4:02 am

Hello,

Thank you for your inquiry.

I apologize for the inconvenience. Our developers completed the first round of fixes on December 23rd. However, during the testing phase, it was discovered that this fix had an impact on other documents. The development team is now conducting a thorough investigation and making new adjustments. They have indicated that the previous modifications were extensive and will require some time to properly adjust.
I have communicated your urgent situation to the developers, and they are doing their best to complete the necessary work as quickly as possible.

We appreciate your patience and understanding.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2908
Joined: Wed Jun 27, 2012 8:50 am

Mon Jan 13, 2025 8:15 pm

Any update this week Amy?

Thank you.

[email protected]
 
Posts: 106
Joined: Tue May 19, 2015 8:09 pm

Tue Jan 14, 2025 2:16 am

Hello,

Thank you for your inquiry.

I'm sorry that this issue has not been resolved yet. The developers are still working on it.


Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2908
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF