Expand my Community achievements bar.

xfa.host.numPages still contains old values after form rendering

Avatar

Level 2
I have developed a pdf that needs further rendering after user fill in the form, I simply create a button called "Print_A" that will run scripts to render the form, print it out (I use app.execMenuItem(Print) instead of xfa.host.print) and finally revert the rendered look back to the original look as user press the button before.



However, problem comes if I want to print a saved pdf without opening Acrobat (ie. from Window Explorer), I work it out by adding scripts to render the form at the forms prePrint event, the form did rendered and printed but only for the 1st page.



I have tried putting the script at the form's "docReady" event, the result is the same, only 1st rendered page got printed.



I have debugged and it seems that xfa.host.numPages still remains 1 after form rendering (that is why only 1st page is printed), however, xfa.layout.pageCount() shows the correct no. of pages afer rendering.



I explicity assign the correct value to xfa.host.numPages but it doesn't work, it is still equal to 1.



Any idea?
3 Replies

Avatar

Level 4
I've encountered this problem also.



I worked it out as being the print command is sent before the form has finished rendering, so even though you are telling it to print say 5 pages, it can only see 1 so it passes that number through.



I haven't worked out a solution yet.



Tom

Avatar

Former Community Member
If Thomas is correct you should be able to proove it by adding a second button to do the print. Hit the first button to fix up the rendering then hit the second button to do the print. Does it still happen?

Avatar

Level 2
If the actions are separated by two buttons, one for rendering pages and the other for printing by 'xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0)', then all rendered pages got printed, but if two actions are combined within one button, only 1st rendered page is printed.



However I solve the above case by using app.execMenuItem(Print) instead of xfa.host.print, now all rendered pages got printed.



But if I print the pdf from Windows Explorer without opening Acrobat application, I can't manipulate the print action after rendering the form on DocReady or prePrint event, and so only 1st rendered page is printed.