Page 1 of 1

Problem with Transformpage function

Posted: Tue Sep 14, 2010 3:18 pm
by wesallen
I am getting an error every time I make a call the the Transformpage function. The error is: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I am developing in Visual Basic .Net using Visual Studio 2008. I use the same function in VB6 and do not have any problems. We are upgrading the program to the .Net platform. Below is the code that is causing the error.

Dim ptrpdf as Long
Dim res As Long
Dim TransMatrix As XCPro40_Defs.PXC_Matrix
Dim fname As String

res = XCPro40_Defs.PXCp_Init(ptrpdf, InitPDF, InitPDFDevCode)
If IS_DS_FAILED(res) Then GoTo Error_Renamed
res = XCPro40_Defs.PXCp_ReadDocumentW(ptrpdf, fname, 0)
If IS_DS_FAILED(res) Then GoTo Error_Renamed

TransMatrix.a = 0.9
TransMatrix.b = 0
TransMatrix.c = 0
TransMatrix.d = 0.9
TransMatrix.e = 0
TransMatrix.f = 0

res = XCPro40_Defs.PXCp_TransformPage(ptrpdf, 0, TransMatrix, 0)

Re: Problem with Transformpage function

Posted: Tue Sep 14, 2010 4:13 pm
by John - Tracker Supp
Hi,

I am afraid we are going to need a small application sample (both source code and ready to run) with any required supporting files (with the exception of our own dll's etc) - once we have this we can check and advise - without I am afraid it is not possible and we are not aware of any issues with transformations.

Please zip any files sent and remove any licnese details if posting to the forums.

Thanks

Re: Problem with Transformpage function

Posted: Fri Sep 17, 2010 2:28 pm
by wesallen
I was trying to make a project to show the example of my problem, now I have a new error in my test project.

when the programs gets to the
res = XCPro40_Defs.PXCp_Init(ptrpdf, InitPDF, InitPDFDevCode)

I get the error
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

the project is attached.

Re: Problem with Transformpage function

Posted: Mon Sep 20, 2010 6:08 pm
by Paul - Tracker Supp
Hi wesallen

the team have taken a look at this and responded that you should use native code from the .NET framework (do not use Any CPU settings in project).

It is a typical problem in .NET framework - projects, created with "Any CPU" setting (default) will work with 32-bit DLLs on 32-bit OS and 64-bit DLLs on 64-bit OS. In most cases users create projects and use 32-bit DLLs, which will not work on 64-bit OS - because 64-bit is required.

hth

Re: Problem with Transformpage function

Posted: Mon Sep 20, 2010 7:13 pm
by wesallen
I now get past the PXCp_Init error, but still get the error from my first post when I get to the

res = XCPro40_Defs.PXCp_TransformPage(ptrpdf, 0, TransMatrix, 0)

The error is: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

A copy of the new project is attached.

Thanks

Re: Problem with Transformpage function

Posted: Tue Sep 21, 2010 1:34 pm
by Corwin - Tracker Sup
Hi wesallen,

Try to use this declaration:
<DllImport("xcpro40")> Public Shared Function PXCp_TransformPage(ByVal ptrdoc As IntPtr, ByVal PageNumber As Integer, ByRef matrix As PXC_Matrix, ByVal flags As Integer) As Integer

HTH

Re: Problem with Transformpage function

Posted: Tue Sep 21, 2010 6:39 pm
by wesallen
Are there any other declarations that need to change?

Thanks

Re: Problem with Transformpage function

Posted: Wed Sep 22, 2010 12:33 pm
by Corwin - Tracker Sup
Hi wesallen,

We are planing an update for most functions declaration, in next few days.

Re: Problem with Transformpage function

Posted: Thu Sep 23, 2010 1:23 pm
by wesallen
I am now having a problem with the PXCp_PlaceContents function. The following code throws the error: Arithmetic operation resulted in an overflow.

res = XCPro40_Defs.PXCp_PlaceContents(NewPDF, ptrpdf, PagesCount, placeInfo(0), 0)
If IS_DS_FAILED(res) Then GoTo Error_Renamed ********error is on this line*********

attached is a sample program.

Thanks

Attachment removed because it contain SDK serial. Please do not post serials on forum!
Lzcat - Tracker Supp.

Re: Problem with Transformpage function

Posted: Fri Sep 24, 2010 2:25 pm
by Corwin - Tracker Sup
Hi wesallen,

Here are some fixes to your code

Re: Problem with Transformpage function

Posted: Tue Sep 28, 2010 7:29 pm
by wesallen
One last problem with this program. On a multiple page pdf only the first page is being inserted. How can I get multiple pages to insert into the document. Thanks

Re: Problem with Transformpage function

Posted: Wed Sep 29, 2010 12:27 pm
by Tracker Supp-Stefan
Just make sure to be passing a range of pages instead of a single one:

Code: Select all

PXCp_InsertPagesTo makes a copy of a page from one PDF document and inserts this page into
another. Pages to copy may also be specified by a range of required pages to copy/insert in one
action or a single page may be copied/inserted several times - within the target document. The
position within the target document may be specified for each page.
The page inserted within the target document may also be empty (simply created by the PXCp_Init
function). 
HRESULT  PXCp_InsertPagesTo(
     PDFDocument pSrcObject,
     PDFDocument pDestObject,
     LPPXCp_CopyPageRange PageRanges,
     DWORD RangesCount,
     DWORD Flags
);

Re: Problem with Transformpage function

Posted: Wed Sep 29, 2010 1:05 pm
by wesallen
I thought that the PXCp_PlaceContents function should insert the contents of the old document into the new document. It works fine in my old vb6 program. The function copies the first page, but the second page and after do not get copied to the new document.

Re: Problem with Transformpage function

Posted: Wed Sep 29, 2010 1:22 pm
by Corwin - Tracker Sup
Hi wesallen,

You should replace your PXCp_ContentPlaceInfo declaration by this:

Code: Select all

Public Structure PXCp_ContentPlaceInfo
	Public DestPage As Integer
	Public SrcPage As Integer
	Public Alignment As Integer
End Structure
Also it will be better to use dynamic array:

Code: Select all

Dim placeInfo() As XCPro40_Defs.PXCp_ContentPlaceInfo
ReDim placeInfo(PagesCount.ToInt32)
HTH.

Re: Problem with Transformpage function

Posted: Wed Sep 29, 2010 1:56 pm
by wesallen
Everything looks like it is working now. Thanks for all the help.

Re: Problem with Transformpage function

Posted: Wed Sep 29, 2010 3:03 pm
by Tracker Supp-Stefan
Glad we could help wesallen!

Best,
Stefan