QuickPDF Lite

Started by Douglas McDonald, October 15, 2010, 05:42:31 PM

Previous topic - Next topic

Douglas McDonald

Has anyone here used the QuickPDF. I downloaded the Free Lite version 7.19 and can't find any samples. On the PB forum there are some samples for the full version but I don't think they work the same. Also I'm confused....They say its an ActiveX but enclosed in the download is a .dll not an OCX. Also there is not a header file (.inc)for it even though its supposed to be for PB. There is for the full version.

Any thoughts?
Thank you
Doug
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

José Roca

And who says that an ActiveX has to have an .OCX extension?

There is not header because you have to use it with COM, and you need a COM browser to generate the interface declarations:


' ########################################################################################
' Library name: QuickPDFLite0719
' Version: 7.19, Locale ID = 0
' Documentation string: Quick PDF Library (Lite Edition) 7.19
' Path: C:\Users\Pepe\Downloads\QuickPDFLite0719.dll
' Library GUID: {CAE6AAB8-E630-48B8-9FF2-98A16B67CFBC}
' Code generated by the TypeLib Browser 4.0.14 (c) 2008 by Jose Roca
' Date: 16 oct 2010   Time: 07:39:19
' ########################################################################################

' ========================================================================================
' ClsIDs (Class identifiers)
' ========================================================================================

$CLSID_PDFLibrary = GUID$("{B3037390-E58D-4ABC-9FD6-F0EA1F6394EA}")

' ========================================================================================
' IIDs (Interface identifiers)
' ========================================================================================

$IID_IPDFLibrary = GUID$("{778DFD53-1CA7-4D08-9888-4855A37A4B14}")

' ########################################################################################
' Interface name = IPDFLibrary
' IID = {778DFD53-1CA7-4D08-9888-4855A37A4B14}
' Interface for QuickPDFLite0719.PDFLibrary Object
' Attributes = 4160 [&H1040] [Dual] [Dispatchable]
' Inherited interface = IDispatch
' ########################################################################################

#IF NOT %DEF(%IPDFLibrary_INTERFACE_DEFINED)
    %IPDFLibrary_INTERFACE_DEFINED = 1

INTERFACE IPDFLibrary $IID_IPDFLibrary

   INHERIT IDispatch

   ' =====================================================================================
   METHOD AddImageFromFile <47120384> ( _               ' VTable offset = 28
     BYVAL FileName AS STRING _                         ' [in] FileName VT_BSTR
   , BYVAL Options AS LONG _                            ' [in] Options VT_I4 <Long>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD AddLinkToWeb <47120385> ( _                   ' VTable offset = 32
     BYVAL Left AS DOUBLE _                             ' [in] Left VT_R8 <Double>
   , BYVAL Top AS DOUBLE _                              ' [in] Top VT_R8 <Double>
   , BYVAL Width AS DOUBLE _                            ' [in] Width VT_R8 <Double>
   , BYVAL Height AS DOUBLE _                           ' [in] Height VT_R8 <Double>
   , BYVAL Link AS STRING _                             ' [in] Link VT_BSTR
   , BYVAL Options AS LONG _                            ' [in] Options VT_I4 <Long>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD AddStandardFont <47120386> ( _                ' VTable offset = 36
     BYVAL StandardFontID AS LONG _                     ' [in] StandardFontID VT_I4 <Long>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD DocumentCount <47120387> ( _                  ' VTable offset = 40
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD DrawImage <47120388> ( _                      ' VTable offset = 44
     BYVAL Left AS DOUBLE _                             ' [in] Left VT_R8 <Double>
   , BYVAL Top AS DOUBLE _                              ' [in] Top VT_R8 <Double>
   , BYVAL Width AS DOUBLE _                            ' [in] Width VT_R8 <Double>
   , BYVAL Height AS DOUBLE _                           ' [in] Height VT_R8 <Double>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD DrawText <47120389> ( _                       ' VTable offset = 48
     BYVAL XPos AS DOUBLE _                             ' [in] XPos VT_R8 <Double>
   , BYVAL YPos AS DOUBLE _                             ' [in] YPos VT_R8 <Double>
   , BYVAL Text AS STRING _                             ' [in] Text VT_BSTR
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD FindImages <47120390> ( _                     ' VTable offset = 52
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD GetInformation <47120391> ( _                 ' VTable offset = 56
     BYVAL Key AS LONG _                                ' [in] Key VT_I4 <Long>
   ) AS STRING                                          ' [retval][out] *Value VT_BSTR
   ' =====================================================================================
   METHOD HasFontResources <47120392> ( _               ' VTable offset = 60
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD ImageCount <47120393> ( _                     ' VTable offset = 64
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD ImageHeight <47120394> ( _                    ' VTable offset = 68
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD ImageWidth <47120395> ( _                     ' VTable offset = 72
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD Linearized <47120396> ( _                     ' VTable offset = 76
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD LoadFromFile <47120397> ( _                   ' VTable offset = 80
     BYVAL FileName AS STRING _                         ' [in] FileName VT_BSTR
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD NewDocument <47120398> ( _                    ' VTable offset = 84
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD NewPage <47120399> ( _                        ' VTable offset = 88
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD PageCount <47120400> ( _                      ' VTable offset = 92
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD PageHeight <47120401> ( _                     ' VTable offset = 96
   ) AS DOUBLE                                          ' [retval][out] *Value VT_R8 <Double>
   ' =====================================================================================
   METHOD PageRotation <47120402> ( _                   ' VTable offset = 100
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD PageWidth <47120403> ( _                      ' VTable offset = 104
   ) AS DOUBLE                                          ' [retval][out] *Value VT_R8 <Double>
   ' =====================================================================================
   METHOD RemoveDocument <47120404> ( _                 ' VTable offset = 108
     BYVAL DocumentID AS LONG _                         ' [in] DocumentID VT_I4 <Long>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SaveToFile <47120405> ( _                     ' VTable offset = 112
     BYVAL FileName AS STRING _                         ' [in] FileName VT_BSTR
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SecurityInfo <47120406> ( _                   ' VTable offset = 116
     BYVAL SecurityItem AS LONG _                       ' [in] SecurityItem VT_I4 <Long>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SelectDocument <47120407> ( _                 ' VTable offset = 120
     BYVAL DocumentID AS LONG _                         ' [in] DocumentID VT_I4 <Long>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SelectedDocument <47120408> ( _               ' VTable offset = 124
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SelectFont <47120409> ( _                     ' VTable offset = 128
     BYVAL FontID AS LONG _                             ' [in] FontID VT_I4 <Long>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SelectImage <47120410> ( _                    ' VTable offset = 132
     BYVAL ImageID AS LONG _                            ' [in] ImageID VT_I4 <Long>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SelectPage <47120411> ( _                     ' VTable offset = 136
     BYVAL PageNumber AS LONG _                         ' [in] PageNumber VT_I4 <Long>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SetInformation <47120412> ( _                 ' VTable offset = 140
     BYVAL Key AS LONG _                                ' [in] Key VT_I4 <Long>
   , BYVAL NewValue AS STRING _                         ' [in] NewValue VT_BSTR
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SetOrigin <47120413> ( _                      ' VTable offset = 144
     BYVAL Origin AS LONG _                             ' [in] Origin VT_I4 <Long>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SetPageSize <47120414> ( _                    ' VTable offset = 148
     BYVAL PaperName AS STRING _                        ' [in] PaperName VT_BSTR
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SetPageDimensions <47120415> ( _              ' VTable offset = 152
     BYVAL NewPageWidth AS DOUBLE _                     ' [in] NewPageWidth VT_R8 <Double>
   , BYVAL NewPageHeight AS DOUBLE _                    ' [in] NewPageHeight VT_R8 <Double>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SetTextAlign <47120416> ( _                   ' VTable offset = 156
     BYVAL TextAlign AS LONG _                          ' [in] TextAlign VT_I4 <Long>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SetTextColor <47120417> ( _                   ' VTable offset = 160
     BYVAL Red AS DOUBLE _                              ' [in] Red VT_R8 <Double>
   , BYVAL Green AS DOUBLE _                            ' [in] Green VT_R8 <Double>
   , BYVAL Blue AS DOUBLE _                             ' [in] Blue VT_R8 <Double>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================
   METHOD SetTextSize <47120418> ( _                    ' VTable offset = 164
     BYVAL TextSize AS DOUBLE _                         ' [in] TextSize VT_R8 <Double>
   ) AS LONG                                            ' [retval][out] *Value VT_I4 <Long>
   ' =====================================================================================

END INTERFACE

#ENDIF   ' /* __IPDFLibrary_INTERFACE_DEFINED__ */


José Roca

#2
And please, don't try to use it putting an OCX control in your form. This ActiveX is not a visual control.

Create an instance of it using NEWCOM CLSID $CLSID_PDFLibrary.

Pat Dooley

You mean like I did?  Like Jose said, don't do that Douglas.
And for more Jose wisdom see
http://www.planetsquires.com/protect/forum/index.php?topic=2534.0
for how to use a non-visual ActiveX without registering the control.
I use the full version, but the Lite version is supposed to be a subset
of the full version so the syntax should be the same.
I could get you a sample if you want.

Pat Dooley

If you have registered QuickPDFLite0719.dll then here is a small FF demo project.
If you generate your own include using Jose's TypeLib Browser you will need
to rename one of the methods. Find "SelectFont" and change it to "SelFont"
or any name that doesn't conflict. "SelectFont" is already used in "windowsx.inc".

Douglas McDonald

Thank you thats exactly what I needed to know so I'll head down the right path. I guess I just assumed from my VB days that activeX was always .ocx and ofcourse thats nonsense.

Pat I'll try your sample.

Thank you
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

Douglas McDonald

Jose, Well I guess it had to happen at some point. I've avoided COM like the plague. This may be the perfect project to get my feet wet. I'm sure with a little help here and the PB forum I'll get it work and then say whats the big deal using COM, its easy. Have to take the first step as some point.

Thank you
Doug
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

José Roca

Quote
If you generate your own include using Jose's TypeLib Browser you will need to rename one of the methods. Find "SelectFont" and change it to "SelFont" or any name that doesn't conflict. "SelectFont" is already used in "windowsx.inc".

A future new version will have these macros changed to functions. Macros are a can of worms.

José Roca

#8
Quote
Jose, Well I guess it had to happen at some point. I've avoided COM like the plague.

Your bad. You don't know what you're missing.

Besides allowing you to use third party servers, about two thirds of what Windows offers has been implemented as low-level COM servers. This is why I insisted so much in implementing direct interface call supoport in PB.

When direct interface call support was implemented in PB9, I thought nobody will use Automation again (unless with Automation only servers or Office) because is so close to calling an standard function dynamically that anyone with some expertise using the Windows API should not have big problems to understand how it works and how to use it. Unfortunately, many begin to read books about COM Automation (and even OOP) and end with a serious headache. I like low-level COM because it is fast, lightweight and not much different to the Windows API.

Calling an standard function dynamically:

1. Load the DLL with LoadLibrary

2. Get the address of the function calling GetProcAddress

3. Call the function using CALL DWORD ProcAddress USING <function prototype declaration> (<parameters>)

Calling a COM method:

1. Call CoCreateInstance (PB NEWCOM statement does it for you)

CoCreateInstance loads the COM server (DLL or OCX) with LoadLibrary, and returns the address of a pointer to a virtual table (an array of addresses) for the requested interface (a group of related functions).

So the difference with LoadLibrary/GetProcAddress is that, instead of returning a single address, CoCreateInstance returns a pointer to a pointer to an array of addresses (COM uses double indirection).

2. Call the method using CALL DWORD @@VtableAddress[offset] using <method prototype declaration> (<pthis, parameters>). This is what i used in the wrapper functions generated by pre-PB9 versions of my browser.

There are two differences: 1) The first parameter (pthis) is always the address to the virtual table returned by CoCreateInstance; 2) Instead of using ProcAddress, we have to use @@VtableAddress[offset], @@ because it's a pointer to a pointer, and offset because the virtual table is a zero-based array of 32-bit addresses. It should be clear to anyone with some knowledge of pointers. The offsets are 0 for the first method, 4 for the 2nd, 8 for the 3rd and so on.

Instead of CALL DWORD @@VtableAddress[offset] using <method prototype declaration> (<pthis, parameters>), compilers with direct interface call support allow to use the dotted syntax, i.e. pVtableAddress.<method name> (<parameters>). The pthis parameter is pVtableAddress and the offset is calculated by the compiler by parsing the interface declaration (this is because an interface declaration for direct interface call use needs to have all the methods listed, even if they are flagged as hidden, and in the correct order). With all the needed information in its hands, the compiler pushes the address of the virtual table into the stack, then the parameters and then calls CALL DWORD with the address of the method (@@VtableAddress[offset]).

BTW COM events work in a similar way as a callback function. With the callback mechanism, you pass the address of a single function that will be called back. With COM events, you implement an interface in a class and pass to the COM server the address of a pointer to the virtual table of that interface, i.e. instead of a single address you are passing the address of an array of addreses.

Douglas McDonald

Thank you Jose, you've really motivated me and I know you are correct. Once I get used to it I'll be kicking myself for not doing it sooner.

Thank you again, always a great help.
Doug
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

Douglas McDonald

Pat, thank you. your sample works great. I thought the LoadFromFile would open a .pdf but I get a 0 in the result even though the path is correct. All I need to do is open a .pdf set some print options, restrict any editing and close it. I'm still working through it. If I can't figure it out in a few day I'll post some code.

I've tried other ways to do this and they work great until there is an update to Adobe. With 20 PC's I hate going around putting on an older version if someone updates it

Thank you
Doug
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

Douglas McDonald

I contacted QuickPDF and they said the lite version does not support rendering  to the screen so I guess I want be using it. I don't have enough need to pay the $230 for the full version.

thank you all for your help
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?