RTF to PDF: Text spans across pages

Technical support for Spire.PDF

Moderator: iceblue support

RTF to PDF: Text spans across pages

Postby ijayaks » Thu Aug 03, 2017 7:49 pm

Can someone help me to understand what is that I am doing wrong? You can see that the text on page 2, page 13...etc are cut off between pages. I have attached the input RTF file and the output PDF document, and the C# code I used.

.NET Code Used (Copied from Sample)
PdfDocument pdf = new PdfDocument();
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();

PdfMargins margin = new PdfMargins();
margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Bottom = margin.Top;
margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Right = margin.Left;

PdfPageBase page = pdf.Pages.Add(PdfPageSize.A4, margin);
var rtf = System.IO.File.ReadAllText(@"C:\Users\Jay\Desktop\United States of America.rtf");
page.LoadFromRTF(rtf, page.Canvas.ClientSize.Width, true);
pdf.SaveToFile(@"C:\Users\Jay\Desktop\DELETE\United States of America.pdf");
You do not have the required permissions to view the files attached to this post.
ijayaks
 
Posts: 3
Joined: Thu Aug 03, 2017 7:24 pm

Re: RTF to PDF: Text spans across pages

Postby Jane.Bai » Fri Aug 04, 2017 3:08 am

Hello,

Thanks for your inquiry.
I have noticed the issue and referred it to our dev team for fixing. Once there's any good news, I will let you know.
In addition, there's a much easier way to convert rtf file to pdf, that is using Spire.Doc. I have tested it and the result is correct. Please download the hotfix(Spire.Doc Pack(hot fix) Version:6.0.5) and use the code below.
Code: Select all
Document doc = new Document();
            doc.LoadFromFile(@"C:\Users\Administrator\Desktop\Files\United States of America.rtf", FileFormat.Rtf);
            doc.SaveToFile(@"C:\Users\Administrator\Desktop\Files\doc.pdf", FileFormat.PDF);

If there's still any doubt, welcome to contact us.

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 430
Joined: Tue Nov 29, 2016 1:47 am

Re: RTF to PDF: Text spans across pages

Postby ijayaks » Wed Aug 16, 2017 4:44 pm

Thanks Jane. Unfortunately we don't have license to Spire.Rtf. Will wait for the hotfix. Fingers crossed.
ijayaks
 
Posts: 3
Joined: Thu Aug 03, 2017 7:24 pm

Re: RTF to PDF: Text spans across pages

Postby Jane.Bai » Thu Aug 17, 2017 2:13 am

Hello Jay,

Thanks for your response.
After a further investigation, the cut-off issue can be avoided by setting the last parameter to be false in the method "LoadFromRTF", it should be like below.
Code: Select all
page.LoadFromRTF(rtf, page.Canvas.ClientSize.Width, false);

But since the Spire.Pdf reads the content of the original rtf file by stream, the typesetting will not be the same as the source file.
Sorry for the inconvenience casued.

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 430
Joined: Tue Nov 29, 2016 1:47 am

Re: RTF to PDF: Text spans across pages

Postby ijayaks » Thu Aug 17, 2017 5:16 pm

Thank you for the quick response, Jane. That worked. Does setting isSplitLine = false cause problems during printing? What is the impact of turning this flag off?

Best,
Jay
ijayaks
 
Posts: 3
Joined: Thu Aug 03, 2017 7:24 pm

Re: RTF to PDF: Text spans across pages

Postby Jane.Bai » Fri Aug 18, 2017 6:20 am

Hello Jay,

Thanks for your response.
Once you set the "isSplitLine = false", that means there is no split line which will cut the content off and all the content will be writen one by one util the page is filled. Theoritically, there's no bad impact of turning this off.
If you encounter any issue, please feel free to contact us.

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 430
Joined: Tue Nov 29, 2016 1:47 am


Return to Spire.PDF

Who is online

Users browsing this forum: No registered users and 0 guests