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, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan

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

Problem with Transformpage function

Post by wesallen » Tue Sep 14, 2010 3:18 pm

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)

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

Re: Problem with Transformpage function

Post by John - Tracker Supp » Tue Sep 14, 2010 4:13 pm

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: 32
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post by wesallen » Fri Sep 17, 2010 2:28 pm

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 114 times

User avatar
Paul - Tracker Supp
Site Admin
Posts: 4951
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: Problem with Transformpage function

Post by Paul - Tracker Supp » Mon Sep 20, 2010 6:08 pm

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
_________________
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

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com

wesallen
User
Posts: 32
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post by wesallen » Mon Sep 20, 2010 7:13 pm

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 119 times

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

Re: Problem with Transformpage function

Post by Corwin - Tracker Sup » Tue Sep 21, 2010 1:34 pm

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: 32
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post by wesallen » Tue Sep 21, 2010 6:39 pm

Are there any other declarations that need to change?

Thanks

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

Re: Problem with Transformpage function

Post by Corwin - Tracker Sup » Wed Sep 22, 2010 12:33 pm

Hi wesallen,

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

wesallen
User
Posts: 32
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post by wesallen » Thu Sep 23, 2010 1:23 pm

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: 670
Joined: Tue Nov 14, 2006 12:23 pm

Re: Problem with Transformpage function

Post by Corwin - Tracker Sup » Fri Sep 24, 2010 2:25 pm

Hi wesallen,

Here are some fixes to your code
Attachments
testtrackpdf.zip
(9.13 KiB) Downloaded 128 times

wesallen
User
Posts: 32
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post by wesallen » Tue Sep 28, 2010 7:29 pm

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 129 times

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13591
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Problem with Transformpage function

Post by Tracker Supp-Stefan » Wed Sep 29, 2010 12:27 pm

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: 32
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post by wesallen » Wed Sep 29, 2010 1:05 pm

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: 670
Joined: Tue Nov 14, 2006 12:23 pm

Re: Problem with Transformpage function

Post by Corwin - Tracker Sup » Wed Sep 29, 2010 1:22 pm

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: 32
Joined: Wed Oct 03, 2007 9:15 pm
Location: Georgia

Re: Problem with Transformpage function

Post by wesallen » Wed Sep 29, 2010 1:56 pm

Everything looks like it is working now. Thanks for all the help.

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13591
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Problem with Transformpage function

Post by Tracker Supp-Stefan » Wed Sep 29, 2010 3:03 pm

Glad we could help wesallen!

Best,
Stefan

Post Reply