Saving settings from SDK Print Dialog
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
-
- User
- Posts: 11
- Joined: Tue Aug 30, 2011 8:06 pm
Saving settings from SDK Print Dialog
We have integrated your PDF viewer SDK into our application and it is working very well when it comes to document viewing. I have defined a limited toolbar that allows the user to request the print function from the viewer. When a user chooses the print button from the toolbar in the PDF viewer they have the option to set the page scaling type. When the user leaves viewer and tries to print another document the Page scaling value defaults to none. Is is possible allow the users specific print settings to be persistent. I'm not concerned about the printer properties, just the preferences that relate to how the Viewer SDK prints.
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Saving settings from SDK Print Dialog
Hello,cbunn wrote:We have integrated your PDF viewer SDK into our application and it is working very well when it comes to document viewing. I have defined a limited toolbar that allows the user to request the print function from the viewer. When a user chooses the print button from the toolbar in the PDF viewer they have the option to set the page scaling type. When the user leaves viewer and tries to print another document the Page scaling value defaults to none. Is is possible allow the users specific print settings to be persistent. I'm not concerned about the printer properties, just the preferences that relate to how the Viewer SDK prints.
Are you using the ActiveX Viewer SDK or the Simple SDK? If the ActiveX, you can save settings with IPDFXCview::DoVerb(). This lets you pick specific objects to save settings from. See the Named Objects list (section 2.2.2, table "Top-Level Objects"). For example you could save the settings for "Print" or even narrow it down to "Print.ScaleType". You can save to a file specified by name (e.g. "tmp\settings.dat") or to an IStream interface.
For example:
DoVerb("Print.ScaleType", "SaveSettings", "tmp\\settings.dat",NULL,0);
See also IPDFXCview::SaveSettings and and IPDFXCview::LoadSettings methods which save all control settings.
Walter Ash
Tracker Software Support
-
- User
- Posts: 11
- Joined: Tue Aug 30, 2011 8:06 pm
Re: Saving settings from SDK Print Dialog
Thank you Walter for the quick response.
We are using the ActiveX Viewer SDK. I can save the Viewer settings from my application whenever the viewer is closed out. I just need to setup a structure to save them in a user specific location.
Chris
We are using the ActiveX Viewer SDK. I can save the Viewer settings from my application whenever the viewer is closed out. I just need to setup a structure to save them in a user specific location.
Chris
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Saving settings from SDK Print Dialog
I'm a little confused about what you mean. Do you just want it to persist while the user is using the application (e.g. store the settings in memory and retrieve them again later?), or do you want to save user-specific settings to a file that will be loaded everytime that user uses the application?cbunn wrote:Thank you Walter for the quick response.
We are using the ActiveX Viewer SDK. I can save the Viewer settings from my application whenever the viewer is closed out. I just need to setup a structure to save them in a user specific location.
Chris
-
- User
- Posts: 11
- Joined: Tue Aug 30, 2011 8:06 pm
Re: Saving settings from SDK Print Dialog
I would like to have the settings persist across application sessions. At the moment every time a user wants to print something (and have it look proper) they need to set the "Scaling type field" to "Fit to printer margins". I think the problem can be partially resolved by changing the default settings that I am loading in from the settings file that I deliver with the application. A better solution would be to save the settings after the user makes a change and then load them as the default the next the viewer is launched. The settings would need to be stored separately for each user.
-Chris
-Chris
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Saving settings from SDK Print Dialog
Can't you define a unique file for the user (for example using the %APPDATA% system path, grabbed by SHGetFolderPath or more recent equivalent functions) and pass the name of it to DoVerb with the SaveSettings or LoadSettings command? Or alternatively, do a global save of all options to this same path with the SaveSettings or LoadSettings methods themselves?cbunn wrote:I would like to have the settings persist across application sessions. At the moment every time a user wants to print something (and have it look proper) they need to set the "Scaling type field" to "Fit to printer margins". I think the problem can be partially resolved by changing the default settings that I am loading in from the settings file that I deliver with the application. A better solution would be to save the settings after the user makes a change and then load them as the default the next the viewer is launched. The settings would need to be stored separately for each user.
-Chris
For example, something like this (in C++ - if you are using a different language the same methods apply though of course syntax will differ):
Code: Select all
LPTSTR appdata = new TCHAR[MAX_PATH];
SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdata);
CComBSTR path = appdata;
path += BSTR(L"\\myprintsettings.dat");
MessageBox(path,L"Saving settings",0);
CComVariant UniqueUserFilename = path;
BSTR namedobject = SysAllocString(L"Print");
BSTR command = SysAllocString(L"SaveSettings");
HRESULT hr = m_spView->DoVerb(namedobject,command,UniqueUserFilename,NULL,0);
You would replace the definition of BSTR command = ... with L"LoadSettings" to load the settings file.
Note that this is just a quick example - my string manipulation might be a bit clumsy there. You'll probably also want to stick it in an application specific folder instead of just the %APPDATA% root like I did there.
Walter Ash
Tracker Support
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Saving settings from SDK Print Dialog
If you have any trouble with this, you can also retrieve the print settings directly and manipulate them as you wish (for example, save them into a custom file), using the "Get" method. You can of course use "Set" to do the inverse when the application loads.
This returns either an integer or a string; you can see the values these may take on page 262 of the current PDF-XChange Viewer ActiveX SDK manual (table 2.2.3.44 Print Scale Types). You can then save this single integer somewhere as you wish.
For example:
This returns either an integer or a string; you can see the values these may take on page 262 of the current PDF-XChange Viewer ActiveX SDK manual (table 2.2.3.44 Print Scale Types). You can then save this single integer somewhere as you wish.
For example:
Code: Select all
BSTR namedobject = SysAllocString(L"Print.ScaleType");
BSTR command = SysAllocString(L"Get");
CComVariant printScaleSetting;
HRESULT hr = m_spView->DoVerb(namedobject,command,printScaleSetting,&printScaleSetting,0);
wchar_t out[100];
wsprintf(out,L"%i",scaletype.intVal);
MessageBox(out,L"Scale type",0); // print scaletype setting as an integer value
-
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Saving settings from SDK Print Dialog
Hi, Chris and Walter.
There is more simple variant (C++, ATL):
Best
Regards.
There is more simple variant (C++, ATL):
Code: Select all
CComBSTR propName(L"Print.ScaleType");
CComVariant propValue;
HRESULT hr = m_spView->GetProperty(propName, &propValue, 0); // to obtain the index of print-scale mode
// or to obtain the simple named value:
// HRESULT hr = m_spView->GetProperty(propName, &propValue, PXCVA_GetNamed); // will return string like "FitToMargins" or other...
Regards.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 11
- Joined: Tue Aug 30, 2011 8:06 pm
Re: Saving settings from SDK Print Dialog
Thank you for explaining the flexibility of the SDK.
-Chris
-Chris
-
- Site Admin
- Posts: 17960
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
Re: Saving settings from SDK Print Dialog
Pleasure we could help Chris!
Cheers,
Stefan
Cheers,
Stefan