Expand my Community achievements bar.

Insert a Page Using Scripting

Avatar

Level 3
Hi,



I've wondered if there is a possibility to insert a certain page when rendering the PDF using JavaScript.



I've a table that contains n records. If the table reaches for example page five, I want to insert a page (cover sheet) because the following pages should be packed into a separate envelope and then continue with the table.



I solved the problem partially using conditional breaks on table rows when a certain number of rows has been reached. This solution works only when all rows have the same height. If the heights vary the result is not as good as expected.



Can I create nodes and append them to the document-tree?



thanks in advance

Michael
4 Replies

Avatar

Former Community Member
Could you not cause a conditional break when you reach the end of page 5. In the conditional break section you could test to see which page you are on and then if you are on page 5 see where the x,y coordinates are on the row you have added. If you are too close to the bottom of the page force the break.

Avatar

Level 3
Hi Paul,



thanks for your quick answer.



The page number is always -1 and x is "0in". I think the positioning will be done after generating the table rows and cell. The conditional breaks code is called before the layout ready events.



Maybe I should mention, that there is no user interaction. We have the PDF template and XML data. The render PDF operation creates the final document.



I've just tested it with PreviewPDF. I'm going to test it with a real process.



thanks in advance

Michael

Avatar

Level 3
Hello Paul,



I've used the renderPDF operation to merge the PDF template with data. The x-value is always "0in".



kind regards

Michael

Avatar

Former Community Member
I see .....I do not think you will get the info I request until after the script completes (the objects don't really exist until then that is why you are getting the rsult you mentioned). I do not see how you can do this today.