Hi,
I finally found what was the wrong variable name. p have to be changed to paperSize.
Also, I want to note that in a previous post, you gave me an answer that is not correct if I consider your current answer. I mean, I cannot just create a new papersize object with a rawkind but instead I have to find the papersize corresponding to the one of the current document.
https://www.e-iceblue.com/forum/how-to-print-a-document-in-legal-size-t7469.htmlAgain, it's weird that we have to do all these things just to print a document that is already defined with the Legal size.
Now, I have to create a library at my company with a Document object that wrap your Document object just to handle all these cases where the printing is not done correctly.
I would suggest you to add this code directly in the Print function of your library or a sample of code in the how to section just to help other like me. It could be a show stopper for a developer trying your library to evaluate if it's worth to buy it in case where a simple operation like printing a document in legal size have to be done with some weird hacking code.