How to change dynamically the media using a value in a nested table as a source of condition.

Hi, I need to change the media following the value in a nested table.
I tried to modify the script in the Sheet configuration, but I couldn’t find how to know which page is printing, in order to indicate what record of the nested table I need to use in the condition.(each record in the nested table indicate the media to be used in the current page)

How you are printing the nested table? Each record on a new page?

Yes, The record is a pdf with several pages, in the nested table there is one record per each page of the pdf.

Each record in the nested table has a key used to switch to the right media.

I don’t understand where the nested table comes from, is it part of the input pdf?

If you have the input PDF set to be the background and if it’s possible to extract a page number or any other page specific data from that PDF you should know what PDF page currently is printed, and depending on this you may set the media. Apart from that you don’t have access to the current page number of the output in the context of the Sheet Configuration.

The input file is a PDF file.

The original PDF hasn’t page number in all of his pages. Only the first pages have page’s number.

The others pages have not page number. My datamapper extract a key from the page to know what media should be used. Additionally, count the pages in the pdf.

I’m attaching the datamapper to clarify your doubts

https://learn.objectiflune.com/qa-blobs/4135103762142610184.ol-datamapper

The big problem is that you like to change media for single pages of a document, what means changing the media within a section.

There may be a limited way if you disable the option “Same for all postions” in the Sheet configuration, which lets you assign different medias for single, first, middle and last sheet, so getting dynamic media to work, but only if your document does not have more than 3 pages (or if it has, does not change media for all the middle sheets).

But if a document has 4 or more pages, you will have more than one middle sheet, which you cannot address, as in a section you have no page object available and hence never can know what page currently is printed (except for the first, middle and last sheets) and what detail record of the nested table is assigned.

So for a limited sort of data it would work with scripting in the Sheet configuration.