Problem with Transformpage function

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 or PDF-XChange Viewer SDK if appropriate.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
wesallen
User
Posts: 19
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Problem with Transformpage function

Post 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)
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: Problem with Transformpage function

Post 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
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
wesallen
User
Posts: 19
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post 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.
Attachments
testtrackpdf.zip
(4.19 MiB) Downloaded 182 times
User avatar
Paul - Tracker Supp
Site Admin
Posts: 6830
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: Problem with Transformpage function

Post 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
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
wesallen
User
Posts: 19
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post 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
Attachments
testtrackpdf.zip
(4.23 MiB) Downloaded 193 times
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Problem with Transformpage function

Post 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
wesallen
User
Posts: 19
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post by wesallen »

Are there any other declarations that need to change?

Thanks
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Problem with Transformpage function

Post by Corwin - Tracker Sup »

Hi wesallen,

We are planing an update for most functions declaration, in next few days.
wesallen
User
Posts: 19
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post 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.
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Problem with Transformpage function

Post by Corwin - Tracker Sup »

Hi wesallen,

Here are some fixes to your code
Attachments
testtrackpdf.zip
(9.13 KiB) Downloaded 206 times
wesallen
User
Posts: 19
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post 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
Attachments
testtrackpdf.zip
(4.23 MiB) Downloaded 212 times
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17823
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Problem with Transformpage function

Post 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
);
wesallen
User
Posts: 19
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post 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.
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Problem with Transformpage function

Post 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.
wesallen
User
Posts: 19
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post by wesallen »

Everything looks like it is working now. Thanks for all the help.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17823
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Problem with Transformpage function

Post by Tracker Supp-Stefan »

Glad we could help wesallen!

Best,
Stefan
Post Reply