How can i store some metadata about a page along with page object

Is there a way I can store some metadata about a page along with page object

  • like page number should be shown or not

  • page header/footer should be added or not

@anujshukla

Thank you for contacting support.

Please note that Aspose.PDF API mimics the behavior of Adobe Acrobat so please elaborate further if you are able to achieve the same requirements with it, or how would you expect Aspose.PDF for .NET API to offer such a feature, so that we may investigate further and help you out.

I’m not able to achieve this. I was expecting some solution from you guys.

@anujshukla

We are afraid such requirements may not be met because page object does not contain such flags. In case you are able to achieve this with Adobe Acrobat then feel free to let us know.

We are trying to stitch a PDF dynamically from various contents provided by user, so there is no relation of it with acrobat(static tool). Could you suggest some other solution to achieve this?

One more question is: If i am adding rows to a table and then adding images/text in row (read cells) then behind the scene it adds new page as content grows. How can i determine the page object in which current row is being added dynamically. I don’t see that there is any parent table property in row which can give me reference of parent table, similarly i can go to parent page from the table.

Please suggest.

@anujshukla

Based on the details of your use case that we know, and Document Object Model (DOM) of Aspose.PDF for .NET API; we are afraid these requirements may not be met.

Moreover, Table, Row or Cell class does not expose any property which holds reference to parent table or page in case of content overflow. Would you please share a code snippet to elaborate your requirements and expected behavior so that we may log a feature request for further investigations.

As you are saying we can not determine parent page then can i apply margins to page after adding text or image? Or can margin be applied at the document level for all pages added dynamically (as part of adding rows to a table which will create pages behind the scene)

My requirements are quite complex and I don’t think it is easy to write the work that we are trying to do here.

I was expecting Aspose to support these things but since we have invested so much time and energy on this, its difficult to switch to some other solution hence i will keep on bothering you.

@anujshukla

Thanks for getting back to us.

You can set page margins before adding dynamic table into it and those margin settings will retain for automatically added subsequent pages. For example, please check following code snippet and attached sample output generated by it:

Document doc = new Document();
Page page = doc.Pages.Add();
page.PageInfo.Margin = new MarginInfo(10, 10, 10, 10);

Table table = new Table();
for (int i = 0; i < 300; i++)
{
 Row row = table.Rows.Add();
 row.Cells.Add(i.ToString());
}

page.Paragraphs.Add(table);
doc.Save(dataDir + "Table.pdf");

table.pdf (5.6 KB)

Thanks for the code.