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

Free Support Forum - aspose.com

How to get current page number and Y-position after inserting a TextFragment


Is there a way to retrieve both the current page number and the Y-position of the newly inserted TextFragment? E.g. :

var hh = new TextFragment(headerText);
int page = doc.Pages.Count; // This seems to work.
int pgn = hh.Page.Number; // This has Page=null
var y = hh.Position.YIndent; // Now working.

Perhaps I want too much and this is not possible.
Is that the case?
Or I need to save the document and reload it?


Hi there,

Thanks for your inquiry. Yes you are right you need to save document and reload it for page numbers. As please note PDF document is created dynamically by API and in order to get real PDF document it needs to render its programming/dynamic model. So we can render PDF document model by calling save() method. You can save your document to stream and reload from that stream for further processing.

Please feel free to contact us for any further assistance.

Best Regards,