Issues with CoPDFXCpreview and CoPDFXCview

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
rkagerer
User
Posts: 1
Joined: Sun Sep 25, 2016 9:51 am

Issues with CoPDFXCpreview and CoPDFXCview

Post by rkagerer »

Hi,

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
- Print
- 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
10. Press F5 to run the project
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”
does not cause it to go to page 2 or to zoom the document (either with file:// or http:// uri's).

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.
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Issues with CoPDFXCpreview and CoPDFXCview

Post by Vasyl-Tracker Dev Team »

Hi, rkagerer.
How do you close the active document in a CoPDFXCpreview control?
Sorry, no way to do it with CoPDFXCpreview object. Its possible only with CoPDFXCview.
I noticed both CoPDFXCpreview and CoPDFXCview temporarily steal the focus when opening a document for the first time.
With CoPDFXCview you are able to use OpenDocument method with PXCVA_NoUI flag that may prevent the focus stealing.
I haven't been able to get either control to work with open parameters described in your documentation, e.g. setting:
Pdfcontrol.Src = “file://c:\test.pdf#page=2?zoom=50”
Currently the additional url-parameters are supported only for non-local urls, i.e its not working for file://... protocols.
What's the pricing if I just want to use the CoPDFXCpreview control, rather than the "full" control?
The CoPDFXCpreview is absolutely free. But using of CoPDFXCview requires setting the valid license code - otherwise it will show special diagonal demo-label on the pages and may place demo-labels on the page-corners when you save changed document.

Also I recommend you try to use our new PDF-XChange Editor SDK:
https://www.pdf-xchange.com/product ... editor-sdk

- that provides tons of features for viewing, creating and editing pdfs.

HTH.
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.
Post Reply