Fellow Canadian here interested in the PDF-XChange Viewer SDK. I've been experimenting with CoPDFXCpreview (lightweight) and CoPDFXCview. I'm using them in a VBA application under Excel.
I noticed a few issues:
A) How do you close the active document in a CoPDFXCpreview control? It only seems to expose a handful of members:
- AllowAccelerators
- LockedView
- ReadOnly
- SettingsURL
- Src
I tried setting Src to a zero length string, but that had no effect. The only way I've found to close the document and release the open file handle is to make the control invisible (set Visible = false).
B) I noticed both CoPDFXCpreview and CoPDFXCview temporarily steal the focus when opening a document for the first time. To reproduce this behavior:
1. Open a new, blank Excel Document (I tested under Excel 2003, Excel 2010 and Excel 2016 ewith identical results)
2. Press Alt+F11 to bring up the Microsoft Visual Basic for Applications editor
3. Insert | UserForm
4. Right-click the form, click Properties, and set its ShowModal property to False.
5. Click the form, then click View | Toolbox if it isn't already shown
6. Right click the toolbox, click Additional Controls, browse to "PDF-XChange Viewer Simple ActiveX", checkmark it and press OK to add it to the toolbox (note picking "PDF-XChange Viewer ActiveX Control" instead will yield identical results).
7. Place a CoPDFXpreview (or CoPDFXview) control onto the form, and set its (Name) property to "pdf".
8. Place a command button on the form
9. Double-click the form, delete all the code, and paste this in:
Code: Select all
Option Explicit
Private Sub Wait(ByVal ms As Long)
Dim endAfter As Single
endAfter = Timer + CSng(ms) / 1000!
Do
DoEvents
Loop Until Timer > endAfter
End Sub
Private Sub CommandButton1_Click()
Wait 4000
Me.pdf.Src = "http://downloads.pdf-xchange.com/PDFV_AX.pdf"
Wait 4000
End Sub
11. Drag the form to position it somewhere on top of the spreadsheet
12. Press the button
13. Within 4 seconds, click a cell in the spreadsheet, and start rapidly pressing the up / down keys to start moving moving the cursor around.
14. You will notice that once the PDF is loaded, focus will jump to the PDF control. This happens even if using a local PDF file instead of an HTTP one.
Although the above example is artificially fabricated, it isolates behavior that occurs in more complex scenarios (which don't involve DoEvents). My actual application is a simple "PDF Previewer" that looks for PDF filenames in a particular column of the spreadsheet and opens up the corresponding PDF as you move around the different rows. The behavior above creates a problem for me - I can't have the focus jumping back and forth interrupting the user's workflow.
I noticed it doesn't occur when switching directly from one PDF document to another. However, sometimes a row will not have an associated PDF and I don't want the viewer to show any document (i.e. either by closing the document or hiding the control). When the next document opens up from such a state, the behavior occurs.
I could use a dummy "nothing to see here" placeholder, but that's not the behavior I want and I don't want to have to distribute more files with my application.
I tried different strategies to work around (hiding the control, manually putting the focus back) but nothing works well enough to provide a clean user experience.
What I'm really looking for is a way to abolish the errant behavior and make the custom control load documents in the background without grabbing focus.
C) I haven't been able to get either control to work with open parameters described in your documentation, e.g. setting:
Code: Select all
Pdfcontrol.Src = “file://c:\test.pdf#page=2?zoom=50”
The CoPDFXCview control has mechanisms for adjusting zoom after the fact, but the CoPDFXCpreview control does not, and I've had to resort to the ugly hack of simulating keyboard input using the keybd_event API (which is further complicated by the fact you guys appear to use GetAsyncKeyState in your event loop leading to timing issues with the approach).
Is there a means to set the zoom level when opening a document with the CoPDFXCpreview control?
D) What's the pricing if I just want to use the CoPDFXCpreview control, rather than the "full" control?
Thanks, I appreciate your help.