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

Free Support Forum - aspose.com

IsKeptWithNext not working


I seem to be having problems with IsKeptWithNext, it doesn’t do anything (in some situations at least).

I am generating the pdf from xml
using Aspose.Pdf 6.4 .NET 4 version, test sample xml & pdf are
attached, code is as follows:

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

string xmlFile = HttpContext.Server.MapPath("~/App_Data/Test" + id + “.xml”);

pdf.BindXML(xmlFile, null);

System.IO.MemoryStream ms = new System.IO.MemoryStream();


return new FileContentResult(ms.ToArray(), “application/pdf”) { FileDownloadName = “Test” + id + “.pdf” };



Hi Patrick,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the XML and resultant PDF documents.

I am afraid using IsKeptTogether in a table will not affect anything. IsKeptTogether Property indicates whether all lines in the paragraph are to remain on the same page. This property only affects paragraphs in section (but not in table).

Thank You & Best Regards,


I’m not sure I understand you here. IsKeptTogether actually does work on a table, but the problem I’m having is with IsKeptWithNext. If I replace the table below the text paragraph with an image, it also does not stay together.


Hi Patrick,

Sorry for the confusion.

I am afraid IsKeptWithNext affects the paragraph in the section and not in the table. You may check the documentation link regarding IsKeptWithNext property.


Thank You & Best Regards,

Nausherwan Aslam

The description says that it should work on paragraphs within a section, but not paragraphs within a table (my interpretation is that this refers to the paragraphs within the table). Also, I can reproduce the same problem with an Image (see attached xml) and that isn’t mentioned at all.

I see no reason why this shouldn’t work, it’s either a bug or a feature that should be implemented.

Hi Patrick,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your feedback.

I have shared this issue with our development team and they will investigate this issue and share further details. I also asked them to check for the support of this feature. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-31999. We will update you via this forum thread regarding any update against your issue.

Sorry for the inconvenience,

Thanks, hopefully it’s possible to implement this.

In the mean time I’ll just use the workaround of putting the content that needs to stay together within a table with IsKeptTogether. Or is there an easier workaround for this?

Hi Patrick,

Thanks for your patience.

I am pleased to share that the issue reported earlier is fixed in latest release of Aspose.Pdf for .NET 9.2.1. When using the attached XML file, the text object Test appears with table on subsequent page. For your reference, I have also attached the resultant PDF generated over my end.

In case you still face the same issue or you have any further query, please feel free to contact.