Problem with Transformpage function
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
-
- User
- Posts: 19
- Joined: Wed Oct 03, 2007 9:15 pm
- Location: Georgia
Problem with Transformpage function
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)
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)
-
- Site Admin
- Posts: 5219
- Joined: Tue Jun 29, 2004 10:34 am
- Location: United Kingdom
Re: Problem with Transformpage function
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
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
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 19
- Joined: Wed Oct 03, 2007 9:15 pm
- Location: Georgia
Re: Problem with Transformpage function
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.
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.
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 6901
- Joined: Wed Mar 25, 2009 10:37 pm
- Location: Chemainus, Canada
Re: Problem with Transformpage function
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
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
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
-
- User
- Posts: 19
- Joined: Wed Oct 03, 2007 9:15 pm
- Location: Georgia
Re: Problem with Transformpage function
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
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
You do not have the required permissions to view the files attached to this post.
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Problem with Transformpage function
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
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
-
- User
- Posts: 19
- Joined: Wed Oct 03, 2007 9:15 pm
- Location: Georgia
Re: Problem with Transformpage function
Are there any other declarations that need to change?
Thanks
Thanks
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Problem with Transformpage function
Hi wesallen,
We are planing an update for most functions declaration, in next few days.
We are planing an update for most functions declaration, in next few days.
-
- User
- Posts: 19
- Joined: Wed Oct 03, 2007 9:15 pm
- Location: Georgia
Re: Problem with Transformpage function
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.
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.
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Problem with Transformpage function
Hi wesallen,
Here are some fixes to your code
Here are some fixes to your code
You do not have the required permissions to view the files attached to this post.
-
- User
- Posts: 19
- Joined: Wed Oct 03, 2007 9:15 pm
- Location: Georgia
Re: Problem with Transformpage function
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
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 17949
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
Re: Problem with Transformpage function
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
);
-
- User
- Posts: 19
- Joined: Wed Oct 03, 2007 9:15 pm
- Location: Georgia
Re: Problem with Transformpage function
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.
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Problem with Transformpage function
Hi wesallen,
You should replace your PXCp_ContentPlaceInfo declaration by this:
Also it will be better to use dynamic array:
HTH.
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
Code: Select all
Dim placeInfo() As XCPro40_Defs.PXCp_ContentPlaceInfo
ReDim placeInfo(PagesCount.ToInt32)
-
- User
- Posts: 19
- Joined: Wed Oct 03, 2007 9:15 pm
- Location: Georgia
Re: Problem with Transformpage function
Everything looks like it is working now. Thanks for all the help.
-
- Site Admin
- Posts: 17949
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
Re: Problem with Transformpage function
Glad we could help wesallen!
Best,
Stefan
Best,
Stefan