Get property

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
moke@napconet.com
User
Posts: 60
Joined: Fri Oct 24, 2008 5:17 pm

Get property

Post by moke@napconet.com »

I am having a lot of trouble capturing when a user prints more than 1 copy of a document. When a print job is started I would like to see how many copies the user selected. I've been banging my head with various methods of trying to do this but, keep missing something. Any help would be appreciated.

Below is the code I am using...

To capture print notifications

Code: Select all

Call CoPDFXCview1.SetProperty("Notifications.Print.Filter", -1, 0)
Look for events

Code: Select all

Private Sub CoPDFXCview1_OnEvent(ByVal nType As Long, ByVal Name As String, ByVal DataIn As Variant, DataOut As Variant, ByVal Flags As Long)
Check to see if event is a print notification. If it is check that it is a BeginDocument event and getproperty of Print.copies.

Code: Select all

If nType = 4 And Name = "Notifications.Print" 
Call CoPDFXCview1.GetProperty("Notifications.Print.Type", DataOut, PXCVA_GetNamed)
    If DataOut = "BeginDocument" Then
        Call CoPDFXCview1.GetProperty("Print.Copies", copies, 0)
        MsgBox "copies = " & copies
    End If
End If
The result of this copde returns "0"... And sometimes it seems a print job does not even have a "BeginDocument" notification so the getproperty never fires. I've been on this too long and confusing myself...
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Get property

Post by Vasyl-Tracker Dev Team »

Hi, Moke.

The printing module at start creates full copy of the global 'Print' section and works with it during the display of the print-dialog, the printing-process and destroys this copy after it is finished. You cannot access to this copy. So, you can read/write the global 'Print' section only, and make changes here before starting the process of printing.
When a print job is started I would like to see how many copies the user selected.
In next build we can add simple property like this:

Code: Select all

Notifications
   Print
      Copies : int // read-only
Best
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.
moke@napconet.com
User
Posts: 60
Joined: Fri Oct 24, 2008 5:17 pm

Re: Get property

Post by moke@napconet.com »

oooohhhhh....

No wonder it seemed so difficult. :(

How about can I use "onproperty changed"? I played with it and didn't get any results? The event never fired when the copies setting changed... Is it possible to read the print settings from the print dialog and do some math when the user clicks the print button?

like (SheetsCount / PagesCount) = Copies ...? or do I have the same issue because the print process starts when the print "menu" button is clicked and the data is unavailable?

I wonder if I should just use WMI or access print spooler directly. It'll definately be harder that way (at least it'll be harder for me)... :cry:
How close is the next build?
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Get property

Post by Vasyl-Tracker Dev Team »

Hi, Moke.
The event never fired when the copies setting changed... Is it possible to read the print settings from the print dialog and do some math when the user clicks the print button?
As I say - we use internal copy of global 'Print' section during displaying print-dialog and all printing-process. You don't have any methods to access to it. You cannot get any notifications about changing (by end-user) of this internal/temporary copy. Currently I can suggest only one way: in the next build we can implement additional print event that you can use to change some(not all) options before printing but after closing a print-dialog:

Code: Select all

youreventhandler OnEvent(type, name..)
{
    if ((type == PXCVA_OnNamedNotify) AND (name == "Notifications.Print"))
    {
         int nType = 0;
         pdfViewer.GetProperty(name + ".Type", out nType);
         if (nType == 64) // "Prepare"
         {
             pdfViewer.GetProperty(name + ".Copies"...); // here pdfViewer.SetProperty will be available also
         }
    }
}
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.
moke@napconet.com
User
Posts: 60
Joined: Fri Oct 24, 2008 5:17 pm

Re: Get property

Post by moke@napconet.com »

ok. Thank you :)
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17889
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Get property

Post by Tracker Supp-Stefan »

:)
Post Reply