Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Printer Properties - settings |
Post Reply ![]() |
Author | |
ibigon ![]() Beginner ![]() Joined: 01 Sep 13 Location: SF Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() Posted: 01 Sep 13 at 12:55PM |
Hi,
is there any API to show the printers default properties dialog in DLL version? I tried: GetPrinterDevModeFromString SetPrinterDevModeFromString None of them showed the the standard properties dialog. I can show it with the win system call: DocumentProperties with flag DM_IN_PROMPT but how can I then pass the filled DEVMODE struct to QuickPDF lib? Is there any conversion from DEVMODE to a correctly formatted string for SetPrinterDevModeFromString Thanks, Ian |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
Ian, In C#, VB.NET it just needs to be a byte[] the same length as the DEVMODE structure. In Delphi it is an AnsiString. In other languages you need to call CreateBuffer, AddToBuffer and ReleaseBuffer functions to create the required string. Andrew. |
|
![]() |
|
ibigon ![]() Beginner ![]() Joined: 01 Sep 13 Location: SF Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
Hi, Thanks for your help.
I am using c++. So finally I was able to correctly cast the std::string to DEVMODE and vice versa, but unfortunatelly the QPL SetPrinterDevModeFromString function is not working for me, and the PrintPages and PrintDocument functions prints always with default printer settings. Here is my pseudo code: std::string lOrigDevStr = GetPrinterDevModeToString(lSelPrinter); //get the default DEVMODE via QPL LPDEVMODE lDevModeP; //declare and allocate memory for the lDevModeP data ... //open printer, etc. DocumentProperties(hWnd, hPrinter, lSelPrinter, lDevModeP, NULL, DM_OUT_BUFFER|DM_IN_PROMPT); /*Show the Printer Properties Dialog and get the the modified DEVMODE into lDevModeP output buffer */ std::string lModifiedDevStr (lDevModeP, lReqSize); //it is converted well to std::string SetPrinterDevModeFromString(lModifiedDevStr ); //return value is 1, unfortunately undocumented std::string lNewDevStr = GetPrinterDevModeToString(lSelPrinter); ... the read lNewDevStr is equal to initial lOrigDevStr, but it should be equal to lModifiedDevStr! The SetPrinterDevModeFromString function does not really changes the printer properties for me. Any help would be appreciated, Thanks, Ian Edited by ibigon - 19 Sep 13 at 11:00PM |
|
![]() |
|
ibigon ![]() Beginner ![]() Joined: 01 Sep 13 Location: SF Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
Guys,
finally I was able to fix the problem. I did not call the "NewCustomPrinter" function before calling "SetPrinterDevModeFromString" - that was the problem. After this fix the printer accepts the passed DEVMODE. Unfortunatelly the documentation is very poor, and does not mention this fact. The function GetPrinterDevModeToString is buggy, while it returns the default DEVMODE for my custom printer instead of the modified one. std::wstring lMyPrinter = NewCustomPrinter(lSelPrinter); int lRetVal = SetPrinterDevModeFromString(lMyDevModeStr); std::string lTmpDevStr = GetPrinterDevModeToString(lMyPrinter); BUG: lTmptDevStr is not equal to lMyDevModeStr, but the printer prints with using lMyDevModeStr Thanks, Ian |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
Ian,
Which version of Quick PDF Library are you using. 9.15 and 9.16 should work reasonably well with DEVMODE. I will make sure we review the documentation and add some sample code. I suspect it is not a bug but is based on how the code is implemented. The GetPrinterDevModeToString function returns the currently active DEVMODE string for the custom printer. Calling SetPrinterDevModeFromString doesn't actually update the DEVMODE until the actual call to PrintDocument. SetPrinterDevModeFromString will save the string to a temporary buffer until the call to PrintDocument. Again some better documentation would help here. I would need to review the code full to determine why it is working this way and determine if it makes sense to update the DEVMODE straight away or not. There must be some reason it was done this way in the first place. Andrew.
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store