Page 1 of 1

using PXCp_Placecontents from VB6

Posted: Sun Jul 09, 2006 5:34 pm
by mkrasnohorsky
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

Posted: Tue Jul 11, 2006 2:16 pm
by John - Tracker Supp
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

Posted: Sun Jul 16, 2006 3:38 pm
by mkrasnohorsky
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

Posted: Mon Jul 17, 2006 4:31 pm
by John - Tracker Supp
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.

Posted: Wed Jul 19, 2006 2:15 pm
by mkrasnohorsky
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

Posted: Wed Jul 19, 2006 2:37 pm
by John - Tracker Supp
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 :)

Posted: Sat Jul 22, 2006 1:46 pm
by mkrasnohorsky
Thank you very much.

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

Take care,

Mark

Posted: Mon Jul 24, 2006 8:43 am
by John - Tracker Supp
Pleasure Mark - pleased all is now well :)

Hope all else goes ok for you.