Changing page size in runtime

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Stefan - PDF-XChange

guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Changing page size in runtime

Post by guy.marom »

Hello,
I just installed and started testing the PDF-XChange 4 API and I need to be able to change the page size in runtime (And not the sheet size). Is that possible?

Thanks,
Guy Marom
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3603
Joined: Thu Jul 08, 2004 10:36 pm

Re: Changing page size in runtime

Post by Ivan - Tracker Software »

Can you say paper size for any other printer in run-time ? Yes, and you will modify DEVMODE fields to do this. Why you cannot try to do the same with PDF-XChange ?
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Re: Changing page size in runtime

Post by guy.marom »

Could you please direct me to some sample code?
Thanks
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19930
Joined: Mon Jan 12, 2009 8:07 am

Re: Changing page size in runtime

Post by Stefan - PDF-XChange »

Would this help?

MSDN DEVMODE (This structure contains information about a printer environment and device initialization.)

Regards,
Stefan
guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Re: Changing page size in runtime

Post by guy.marom »

No sure how to use this, but thank you very much for the help. I really appreciate it.
guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Re: Changing page size in runtime

Post by guy.marom »

I found this link and it really helped:
http://www.codeproject.com/KB/dotnet/NE ... brary.aspx
User avatar
John - Tracker Supp
Site Admin
Posts: 5225
Joined: Tue Jun 29, 2004 10:34 am

Re: Changing page size in runtime

Post by John - Tracker Supp »

Thanks Guy - will FAQ

appreciated.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Re: Changing page size in runtime

Post by guy.marom »

I'm continuing this thread because I ran into a problem and I think other people might run into the same thing.

I can't seem to find the correct permissions to give the user running my application so that he will be able to change the printer settings. I keep getting a win32exception no. 5 (Access is denied) when I run the win32api method "OpenPrinter".
So far, making the user a local administrator on the machine is the only thing that worked but that's not very good...

Any ideas?
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3603
Joined: Thu Jul 08, 2004 10:36 pm

Re: Changing page size in runtime

Post by Ivan - Tracker Software »

Can you send me you sample code? I will correct it, and send back.
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Re: Changing page size in runtime

Post by guy.marom »

I attached a wrapper class for the WIN32API the problem happens in the function GetPrinterSettings in row no. 184 (The return value in that row is 0, or False).
I attached all of it since it's what I got from the NET, if it's too much I'll try and make a "slimmer" version of the code.
Thanks
You do not have the required permissions to view the files attached to this post.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3603
Joined: Thu Jul 08, 2004 10:36 pm

Re: Changing page size in runtime

Post by Ivan - Tracker Software »

Sorry, I'm not so familiar with .NET, so, code is a bit ugly. By the way, it works.
You do not have the required permissions to view the files attached to this post.
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Re: Changing page size in runtime

Post by guy.marom »

I know it works, that's why I posted it here in the first place. I'm sure more people can use this.
My problem is with permissions, so far we can't figure out what is the minimal set of permissions needed in order to perform these operations.
We prefer not making the user an administrator for obvious reasons (At least they are obvious to our IT manager :)).

I think part of the IT problem is that you printer driver creates temporary printers, so permissions on them cannot be given in advance.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3603
Joined: Thu Jul 08, 2004 10:36 pm

Re: Changing page size in runtime

Post by Ivan - Tracker Software »

Sorry, I didn't understand -- modified example I send you works or not?
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Re: Changing page size in runtime

Post by guy.marom »

Just tested it. It seems to be working fine.
Thank you very much
guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Re: Changing page size in runtime

Post by guy.marom »

I guess I was a bit hasty to rejoice, it doesn't work...
So I dug into the Win32 API (You can find a reference at http://msdn.microsoft.com/en-us/library ... S.85).aspx) and fixed the code.

I used the PRINTER_INFO_9 structure, it is the structure that is used to change user specific printer options.
I noticed that it cannot be populated unless the PDF-XChange printer driver applies settings first - I mean using the ApplyOptions function of the printer driver.

Attached is the final version of the code I am currently using. Enjoy, and again thanks for all the help.
You do not have the required permissions to view the files attached to this post.