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

Free Support Forum - aspose.com

HTML page table breaking into pages

Hello,


I am using aspose.word to create the pdf.
My procedure is simple to get the html text from a template replace the tags(HTML has the Table which contains the table row.Each table row is considered the objective)
I am able to generate the PDF and problem I am facing now is when content passes to next page my objective (table row data ) gets parted into two pages .

How can I overcome this problem please let me know the solution I have tried below solution from your portals
1.


I have added the text file in which html and generated PDF.

Please let me know solution as soon as possible.



Hi Swapnil,


We see that you’d generated “objective.pdf” file by using evaluation version of Aspose.Words for Java 14.7.0. We suggest you please upgrade to Aspose.Words for Java 16.12.0 and see how it goes on your end:

Aspose.Words for Java 16.12.0

In case the problem still remains, please create a standalone Java application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

Best regards,

Hello I have used version 16.12.0.


Please let me know if you have any more solution

Hi Swapnil,

In case the problem still remains with Aspose.Words for Java 16.12.0, please create a standalone Java application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

Best regards,

Hello,


I have created the standalone appication.Please refer to the file PDFUtilities.
I have tried the option pagesplitter and changing the HTML ("

")


Still my objective are breaking into multiple pages can you please let me know any solution or the mistake I am making.

Thanks and Regards,
Swapnil

Hi Swapnil,


Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Hi,


You can simply insert a PageBreak after the completion of objective table. Please see the following simplified code and attached output PDF:

<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>Document doc = new Document(“D:\temp\the-file-name.html”);

PageSetup ps = doc.getFirstSection().getPageSetup();
ps.setTopMargin(1);
ps.setRightMargin(5);
ps.setBottomMargin (10);
ps.setLeftMargin(5);
ps.setPaperSize(PaperSize.A3);

ps.setOrientation(Orientation.LANDSCAPE);

for (Table table : (Iterable) doc.getFirstSection().getBody().getTables())
{
Paragraph para = (Paragraph)table.getNextSibling();
if (para != null)
{
para.getRuns().add(new Run(doc, ControlChar.PAGE_BREAK));
}
}

doc.save(“D:\temp\awjava-17.1.0.docx”);
doc.save(“D:\temp\awjava-17.1.0.pdf”);

Hope, this helps.

Best regards,