XML - GetObjectByID & new Page


#1

Hi there,

after you helped so fast last time, here another shot…

I am using an XML which defines pretty much IDs, which I fill in the code. I need to be able to provide different templates wich contain all the same IDs but in different locations.

This works very well in one page documents. Now I have the need to print several of these pages into one pdf-document. So effectively I need to reuse the IDs of the XML for each page to print…

I have no idea how to do this after several hours of studying the documentation and the xsd…

Glad for any help…
Timo


#2

Dear Timo,

Thank you for considering Aspose.

If different objects have same ID, how can Aspose.Pdf know which object do you want when you call GetObjectByID()? So if you want to reuse the IDs in XML, you can define paragraphs in defferent sections and make sure there is no same ID in a section. Then you can get the object by calling the section’s GetObjectByID() method. How do you think of this idea?


#3

Hi Tommy,

maybe I was a bit unprecise about my problem.

There are no identical IDs in the XML.

What I want to do is the following:

Define a page using XML with unique IDs and use this ‘template’ for every page in the document. Consider the Invoice-Demo and think about an ID for the orders-table which you would like to fill using an ID.

I thought about a workaround like this:

Create 2 PDF objects. Bind one with my XML and fill it using GetObjectByID. When ready get the section and add it to the other PDF-Object using Sections.Add and iterate this process.

I think there is no currrent way to do this with your component - this would be a great extension to your component in my opinion. English is not my native, so if you cannot follow my thoughts feel free to inquire.

Cheers
Timo


#4

Dear Timo,

Thank you for considering Aspose.

I think I know what you want now. I have added a new section Using XML as Template in the programmer’s guide. Can this help you?


#5

Hi Tommy,

thanks for your answer. This helps, even if I would like to do it a bit different. I would like to use one clone of the segment to reuse.

In the iteration the first thing to do is to clone the saved section, fill the clone using the given IDs and add this cloned section into the PDF object. IMO I don’t have the need to change the IDs then.

I will try this out today and provide you with feedback about it. I really appreciate your component. Thanks

Timo