How to do page break while converting HTML to PDF


We are having dynamic html and in html we are passing page break like below

<div style="page-break-after: always">Casey</div>

but when we convert into pdf page break is not coming ,

so can you please suggest what is best way to do page break while converting html to pdf , or if we have any other way please suggest us .


We have tested your scenario with the latest version 17.11 of Aspose.Pdf for .NET API and works fine. Please refer to these input and output documents: (24.4 KB)


string dataDir = @"C:\Pdf\test492\";
Document document = new Document(dataDir + "input.html", new HtmlLoadOptions());
document.Save(dataDir + "output.pdf", SaveFormat.Pdf);


Please use following link to download files. Also, in case you face any issue or have any other query, please feel free to create a new topic. We will surely assist you accordingly.


It seems like you are using Aspose.Words API. We request you to please share complete code snippet which you are using in your environment. We will test the scenario in our environment and address it accordingly.


Thanks for sharing the code snippet. In your code, you are saving document to PDF and returning it as Aspose.Pdf.Document. It should be Aspose.Words.Document.

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word/PDF file that shows the undesired behavior.
  • Please attach the expected output Word/PDF file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.