We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML to PDF Paragraph splitting issue

Hello,

I am having an issue with ensuring that paragraphs do not split across PDF pages. I attach a screenshot of the rendering. The section with the header I need to be able to detect if it will cross from one page to the next, and take appropriate action.

My code:



var documentSection = new Section(pdf);

documentSection.FirstPageInfo = new PageSetup(documentSection);

foreach (var paragraph in metadata.Paragraphs)
{
if (paragraph.PageBreak == PageBreak.Before)
{
documentSection.Paragraphs.Add(new Text(CPAGEBREAK));
}

var documentTextReader = new StringReader(paragraph.Content);
var documentText = new Text(documentTextReader.ReadToEnd());

documentTextReader.Close();
documentTextReader.Dispose();

documentText.IsHtmlTagSupported = true;
documentText.IsKeptTogether = true;

documentSection.Paragraphs.Add(documentText);

if (paragraph.PageBreak == PageBreak.After)
{
documentSection.Paragraphs.Add(new Text(CPAGEBREAK));
}
}

pdf.Sections.Add(documentSection);



I am using v6.3.0.0. I wonder of anyone has had a similar issue?

Best regards
Iain

Do you have the same behavior when setting IsHtmlTagSupported = false? It would isolate the issue. I have logged a problem with the performance with HTML (Performance issue when building PDF with HTML tags) and another with the fact that the underline does not always work with HTML (https://forum.aspose.com/t/85298&Subj=html-underline-does-not-work-when-wrapping-italic-tag-lt-u-gt-lt-i-gt-.lt-i-gt-lt-u-gt).


Have a nice day,

Jean-François Rouleau

Hi Lain,


Thanks for contacting support.

When rendering HTML to PDF format, the paragraph break cannot be controlled. In fact the contents are rendered in Flow layout from Top-Left to Bottom-Right. Furthermore, I am not sure if you need to break the page if contents reach at the end of document.

Can you please share some details about your requirements and if possible, please share the source HTML document. We are sorry for this inconvenience.
jeanfrancoisrouleau:
Do you have the same behavior when setting IsHtmlTagSupported = false? It would isolate the issue. I have logged a problem with the performance with HTML (Performance issue when building PDF with HTML tags) and another with the fact that the underline does not always work with HTML (https://forum.aspose.com/t/85298&Subj=html-underline-does-not-work-when-wrapping-italic-tag-lt-u-gt-lt-i-gt-.lt-i-gt-lt-u-gt).
Hi Jean-François,

Currently the development team is working on resolving some priority issues and as soon as we have made some progress towards the resolution of problems reported on above forum threads, we would be more than happy to update you with the status of correction. The status will be shared on respective forum thread. Please be patient and spare us little time.

Hello,

I have added an image to post 472466. I have also attached the html (htmlSection.txt).

The issue is that I am adding a paragraph in code (as per the post), and there appears not to be a way of determining when a paragraph will split over 2 pages, in this case page 1 of 19 and page 2 of 19.

This seems like it would be a common problem. Is there a solution to this issue, either in code or via e.g. manipulation of the PDF in code?

Best regards
Iain


Hello Nayyer,

Do you have a response to post : 473073
if possible? I have added the information you requested.

Best regards

Iain

Hi Iain,


Thanks for you patience. After initial investigation, we have logged the issue as PDFNEWNET-35450 for further investigation and resolution in our issue tracking system. We will keep you updated about issue progress via this forum thread.

Sorry for the inconvenience faced.

Best Regards,

Hello,

Has there been progress on this issue (PDFNEWNET-35450)?

Best regards
Iain

Hi Iian,


Thanks for your inquiry. I’m afraid your reported issue is still not resolved and Its pending for analysis for investigation in the queue with other priority tasks. We will update you about the ETA via this forum thread as soon as its investigation completes.

Thanks for your patience and cooperation.

Best Regards,

Hello,

Is there any progress on this ticket?

Best regards
Iain

Hi Lian,


Thanks for your inquiry. I’m afraid the reported issue issue is still not resolved. However, I’ve requested our development team to investigate the issue and provide an ETA at their earliest. We will update you as soon as we get a feedback.

We are sorry for the inconvenience caused.

Best Regards,

Hi Lian,


Thanks for your patience.

We have further investigated the issue reported earlier as PDFNEWNET-35450 and I am afraid we cannot resolve this problem. Please note that currently it’s impossible to easily detect via public API whether this or that paragraph has been split on several pages during contents rendering. Furthermore, such feature cannot be implemented in reasonable amount of time. We are sorry for this inconvenience.