using PXCp_Placecontents from VB6

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software, Andrew - Tracker Support, Tracker - Clarion Support, John - Tracker Supp, Support Staff, moderators

Post Reply
mkrasnohorsky
User
Posts: 4
Joined: Sun Jul 09, 2006 5:15 pm

using PXCp_Placecontents from VB6

Post by mkrasnohorsky » Sun Jul 09, 2006 5:34 pm

Hi,

I am trying to use PXCp_PlaceContents from VB6, the demo VB project does not contain a declaration for this function, so here I created one (not sure if it is correct):

Code: Select all

'For Document Overlay
Public Declare Function PXCp_PlaceContents Lib "xcpro35" (ByVal destDoc As Long, ByVal sourceDoc As Long, ByVal OverLayCount As Long, ByRef placeInfo As PXCp_ContentPlaceInfo)

Type PXCp_ContentPlaceInfo
   DestPage As Long
   SrcPage As Long
   Alignment As PXCp_ContentPlaceInfo_Allignment
End Type

Enum PXCp_ContentPlaceInfo_Allignment
   CPA_HorLeft = &H0 'Align placed content to the left.
   CPA_HorCenter = &H1 'Center placed content.
   CPA_HorRigth = &H2 'Align placed content to the right.
   CPA_HorFit = &H3 'Fit source page width to destination page width.
   CPA_VerBottom = &H0 'Align placed content to the bottom.
   CPA_VerCenter = &H10 'Center placed content.
   CPA_VerTop = &H20 'Align placed content to the top.
   CPA_VerFit = &H30 'Fit source page height to destination page height.
   CPA_Foreground = &H100 'Place source page content as foreground if set, otherwise placed as background
   CPA_KeepAspect = &H200 'Keep source page aspect ratio.
End Enum
This is the VB code I use to call the function:

Code: Select all

Private mSource As Long
Private mDestination As Long

Private Sub Command1_Click()
   Dim lReturn As Long
   
   lReturn = PXCp_Init(mSource, g_initstr, g_initDevCode)
   lReturn = PXCpVB_ReadDocumentW(mSource, "d:\z_Temp\WaterMark1.pdf", 0)

   lReturn = PXCp_Init(mDestination, g_initstr, g_initDevCode)
   lReturn = PXCpVB_ReadDocumentW(mDestination, "d:\z_Temp\WaterMark2.pdf", 0)
   
   Dim lTemp As PXCp_ContentPlaceInfo
   lTemp.SrcPage = 1
   lTemp.DestPage = 1
   lTemp.Alignment = CPA_HorFit Or CPA_VerFit
   
   lReturn = PXCp_PlaceContents(mDestination, mSource, 1, lTemp)
   
   If IS_DS_SUCCESSFUL(lReturn) Then
      lReturn = PXCpVB_WriteDocumentW(mDestination, "d:\z_Temp\output.pdf", PXCp_CreationDisposition_Overwrite, PXCp_Write_Release)
   Else
      lReturn = PXCp_Delete(mDestination)
   End If
   
   lReturn = PXCp_Delete(mSource)
End Sub
The behaviour I get is an output.pdf file is created with the exact contents of Watermark1.pdf (Watermark2.PDF is not present as an underlay).

I have also attached the 2 source PDF files (they are very simple PDF files with only 1 page each). I also tested doing an overlay with Adobe Acrobat to make sure it works between the two files.

Thanks

Mark
Attachments
WaterMark.zip
(4.98 KiB) Downloaded 167 times

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Tue Jul 11, 2006 2:16 pm

Hi,

Some comments that may help:


a) Please be advised that DestPage & SrcPage fields in type PXCp_ContentPlaceInfo are zero based.

This may be one possible cause for the function call failing.

You can check the result after calling the PXCp_PlaceContents function.

b) Function declaration.

Another possible cause could be you have defined only 4 parameter's whereas there are in fact 5 required as the function isdoccumented.

i.e. the declaration should be :

Public Declare Function PXCp_PlaceContents Lib "xcpro35" (ByVal destDoc As Long, ByVal sourceDoc As Long, _
ByVal OverLayCount As Long, placeInfo As PXCp_ContentPlaceInfo, ByVal flags as Long)


HTH
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

mkrasnohorsky
User
Posts: 4
Joined: Sun Jul 09, 2006 5:15 pm

Post by mkrasnohorsky » Sun Jul 16, 2006 3:38 pm

I made the changes as per the suggestion.

Now I get a "Bad DLL calling convention" error.

This is the revised declaration:

Code: Select all

'For Document Overlay
Public Declare Function PXCp_PlaceContents Lib "xcpro35" (ByVal destDoc As Long, ByVal sourceDoc As Long, ByVal OverLayCount As Long, ByRef placeInfo As PXCp_ContentPlaceInfo, ByVal flags As Long)
Any other suggestions?

Take care,

Mark

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Mon Jul 17, 2006 4:31 pm

Hi Mark,

we are going to need a simple sample application (source and compiled) to allow us to debug and test and if necessary correct - and return.

Please zip any files posted/sent - thanks.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

mkrasnohorsky
User
Posts: 4
Joined: Sun Jul 09, 2006 5:15 pm

Post by mkrasnohorsky » Wed Jul 19, 2006 2:15 pm

Hi,

Please see attached. I just added a form (form1.frm) to the XCPro_35_Demo project, the code is in Command1_Click.

I also included the 2 PDF files I use for testing with.

Thanks,

Mark
Attachments
XCPro35_Demo.zip
(60.27 KiB) Downloaded 153 times

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Wed Jul 19, 2006 2:37 pm

Hi

Thanks - please change the prototype as follows :

Public Declare Function PXCp_PlaceContents Lib "xcpro35" (ByVal destDoc As Long, ByVal sourceDoc As Long, ByVal OverLayCount As Long, ByRef placeInfo As PXCp_ContentPlaceInfo, ByVal flags As Long) as Long

and all should be well :)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

mkrasnohorsky
User
Posts: 4
Joined: Sun Jul 09, 2006 5:15 pm

Post by mkrasnohorsky » Sat Jul 22, 2006 1:46 pm

Thank you very much.

I guess I was so concerned about the forest, I didn't notice the trees.

Take care,

Mark

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Mon Jul 24, 2006 8:43 am

Pleasure Mark - pleased all is now well :)

Hope all else goes ok for you.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

Post Reply