You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to convert HTML with tables containing uneven row heights to a PDF using Telerik Document Processing. My issue arises when some rows split across pages, even though I need them to stay intact. In my previous implementation using another library, `page-break-inside: avoid` handled this behavior correctly. However, this style does not seem to work with Telerik's methods.
20
+
This article shows how to use [WordsProcessing]({%slug radwordsprocessing-overview%}) and [PdfProcessing]({%slug radpdfprocessing-overview%}) libraries to convert HTML with tables to a PDF, without splitting rows across pages.
32
21
33
22
This knowledge base article also answers the following questions:
34
23
- How can I prevent table rows from splitting across pages during HTML to PDF conversion?
35
24
- How do I handle uneven row heights in tables when exporting to PDF?
36
-
- How can I ensure HTML table rows are preserved on a single page in Telerik Document Processing?
25
+
- How can I ensure HTML table rows are preserved on a single page during HTML to PDF conversion?
37
26
38
27
## Solution
39
28
40
-
To prevent table rows from splitting across pages, manually recreate the PDF table from scratch by copying the HTML table content to a new PDF table. Use the `Measure` method to check whether the table exceeds the page boundary. If it does, create a new page and continue building the table.
29
+
To prevent table rows from splitting across pages, manually recreate the PDF table from scratch by copying the HTML table content to a new PDF table. Use the **Measure** method to check whether the table exceeds the page boundary. If it does, create a new page and continue building the table.
41
30
42
31
### Steps to Implement
43
32
44
-
1.**Set up the HTML import settings:** Use the `HtmlFormatProvider`andimplement the `LoadImageFromUri` event for resolving images in the HTML content.
33
+
1.**Set up the HTML import settings:** Use the [HtmlFormatProvider]({%slug radwordsprocessing-formats-and-conversion-html-htmlformatprovider%}) and implement the [LoadImageFromUri]({%slug radwordsprocessing-formats-and-conversion-html-settings%}#loadimagefromuri-and-loadstylesheetfromuri-events) event for resolving images in the HTML content.
45
34
46
-
2.**Load the HTML document:** Import the HTML content into a `RadFlowDocument` object.
35
+
2.**Load the HTML document:** Import the HTML content into a [RadFlowDocument]({%slug radwordsprocessing-model-radflowdocument%}) object.
47
36
48
37
3.**Extract rows from the HTML table:** Enumerate the rows from the HTML table.
49
38
50
-
4.**Create a new PDF table:** For each page, create a new table and add rows while ensuring they fit within the page boundaries.
39
+
4.**Create and format a new PDF table:** For each page, create a new table and add rows while ensuring they fit within the page boundaries, while also setting the desired formatting.
51
40
52
-
5.**Check row measurements:** After adding each row, use the `Measure` method to verify whether the table exceeds the page height. If it does, move the remaining rows to a new page.
41
+
5.**Check row measurements:** After adding each row, use the **Measure** method to verify whether the table exceeds the page height. If it does, move the remaining rows to a new page.
53
42
54
-
6.**Export the PDF:** Use the `PdfFormatProvider` to save the final PDF document.
43
+
6.**Export the PDF:** Use the [PdfFormatProvider]({%slug radpdfprocessing-formats-and-conversion-pdf-pdfformatprovider%}) to save the final PDF document.
44
+
45
+

0 commit comments