SelectPdf for .NET - Control Page Breaks with Html to Pdf Converter - VB.NET / ASP.NET Sample This sample shows how to use SelectPdf html to pdf converter to convert a raw html code to pdf and also how to control the page breaks from the html code. To insert a page break in pdf, the html code must have an element with the style page-break-before: always or page-break-after: always. Before or after that specific element, a page break will be inserted into the generated pdf document. The element can be anything (image, table, table row, div, text, etc). To instruct a certain section from the content to remain on the same page in the generated pdf document, an element with the style page-break-inside: avoid must be used. Html Code: <html> <body> <div style="font-size: 28px; page-break-after: always"> This is a short paragraph of text. After it, a page break will be inserted. <br/> This is a short paragraph of text. After it, a page break will be inserted. <br/> This is a short paragraph of text. After it, a page break will be inserted. <br/> This is a short paragraph of text. After it, a page break will be inserted. <br/> </div> <div style="font-size: 28px; "> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> This paragraph should appear in the second page (the first paragraph inserted a page break after it). <br/> </div> <div style="font-size: 28px; page-break-inside: avoid; "> This paragraph should all be displayed in the same page (contains page-break-inside: avoid). Since it's too large to appear in the second page, it will all appear in the third page. <br/> This paragraph should all be displayed in the same page (contains page-break-inside: avoid). Since it's too large to appear in the second page, it will all appear in the third page. <br/> This paragraph should all be displayed in the same page (contains page-break-inside: avoid). Since it's too large to appear in the second page, it will all appear in the third page. <br/> This paragraph should all be displayed in the same page (contains page-break-inside: avoid). Since it's too large to appear in the second page, it will all appear in the third page. <br/> This paragraph should all be displayed in the same page (contains page-break-inside: avoid). Since it's too large to appear in the second page, it will all appear in the third page. <br/> This paragraph should all be displayed in the same page (contains page-break-inside: avoid). Since it's too large to appear in the second page, it will all appear in the third page. <br/> This paragraph should all be displayed in the same page (contains page-break-inside: avoid). Since it's too large to appear in the second page, it will all appear in the third page. <br/> This paragraph should all be displayed in the same page (contains page-break-inside: avoid). Since it's too large to appear in the second page, it will all appear in the third page. <br/> This paragraph should all be displayed in the same page (contains page-break-inside: avoid). Since it's too large to appear in the second page, it will all appear in the third page. <br/> This paragraph should all be displayed in the same page (contains page-break-inside: avoid). Since it's too large to appear in the second page, it will all appear in the third page. <br/> </div> </body> </html> Base Url: