PXCp_TransformPage throws an exception

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
relapse
User
Posts: 167
Joined: Wed Jan 18, 2012 11:10 am

PXCp_TransformPage throws an exception

Post by relapse » Mon Jan 23, 2012 4:17 pm

Hello, I've found the following function to scale page contents:

Code: Select all

HRESULT PXCp_TransformPage (PDFDocument pDocument, DWORD PageNumber, LPCPXC_Matrix matrix, DWORD flags);
The matrix structure is defined like this:

Code: Select all

public struct PXC_Matrix
    {
      public double  a;  //      | a b 0 |
      public double  b;  //      | c d 0 |
      public double  c;  //      | e f 1 |
      public double  d;  //
      public double  e;  // dx
      public double  f;  // dy
    };
I declare the API function as follows:

Code: Select all

[DllImport("xcpro40")]
public static extern int PXCp_TransformPage(int pDocument, int iPageNumber, ref PXC_Matrix pMatrix, int iFlags);
The function call in C#:

Code: Select all

            var TransformMatrix = new PdfXchangePro.PXC_Matrix() { a = 0.0, b = 0.0, c = 0.0, d = 0.0, e = 2.0, f = 3.0 };
            if (_documentId != 0)
            {
                int res = PdfXchangePro.PXCp_TransformPage(_documentId, 0, ref TransformMatrix, 0x0001);
            }
This call ends with an AccesViolatioException ("Attempted to read or write protected memory. This is often an indication that other memory is corrupt.")

What is wrong? The memory for the matrix object is reserved with the new() operator. I see no reason for the exception to be thrown except of the calling parameters in C++ and C# which don't match each other (LPCPXC_Matrix matrix vs. ref PXC_Matrix pMatrix).


Thanx
Last edited by relapse on Wed Feb 15, 2012 7:20 am, edited 1 time in total.

Ivan - Tracker Software
Site Admin
Posts: 3611
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: PXCp_TransformPage throws an exception

Post by Ivan - Tracker Software » Tue Jan 24, 2012 11:25 pm

Just tried your code and it works without problems.
Can you send me the PDF where problem is reproduced?

By the way, the matrix you made is invalid (singular matrix) - it transforms everything to single point (2, 3);
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.

relapse
User
Posts: 167
Joined: Wed Jan 18, 2012 11:10 am

Re: PXCp_TransformPage throws an exception

Post by relapse » Wed Jan 25, 2012 10:09 am

Hello, in the attachment you can find the PDF file I'm trying to resize. What other values do I need to manipulate the size (you say with those 2 values I have only an access to a single point)?

In the docs (PDF-ToolsV4SDK.pdf) in the information regarding PXCp_TransformPage function I've found the following reference "See PDF Reference 1.6, section 4.2.2 for Common Transformations for more detailed information." What docs are meant there?
Attachments
High.pdf
(103.43 KiB) Downloaded 321 times

Ivan - Tracker Software
Site Admin
Posts: 3611
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: PXCp_TransformPage throws an exception

Post by Ivan - Tracker Software » Thu Jan 26, 2012 8:50 pm

Here is the link to PDF references: http://www.adobe.com/devnet/pdf.html
Also, what is the matrix as how it should be used, you can find on the Wikipedia: http://en.wikipedia.org/wiki/Transforma ... formations
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.

relapse
User
Posts: 167
Joined: Wed Jan 18, 2012 11:10 am

Re: PXCp_TransformPage throws an exception

Post by relapse » Fri Jan 27, 2012 7:02 am

Can you advise me a JavaScript function to manipulate width/height values of a PDF page/doc?

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

Re: PXCp_TransformPage throws an exception

Post by Tracker Supp-Stefan » Fri Jan 27, 2012 2:57 pm

Hello relapse,

You will need to use the PDF Tools functions discussed above in this topic to physically change a page's dimensions and perform a proper rotation, but if you want - you should also be able to use the setPageBoxes JS method to change the visible dimensions of a document's page(s).

For more information on this function - please refer to the JS for Acrobat API reference.

Best,
Stefan

relapse
User
Posts: 167
Joined: Wed Jan 18, 2012 11:10 am

Re: PXCp_TransformPage throws an exception

Post by relapse » Tue Jan 31, 2012 11:34 am

I've tried to execute this JavaScript code with your sample program for testing JS:

Code: Select all

var rCrop = this.getPageBox("Crop",this.pageNum);
rCrop[1] -= 50; // top
rCrop[2] -= 50; // right
this.setPageBoxes("Crop",this.pageNum,this.pageNum,rCrop);
I get the error message: "An error occured in java script".

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

Re: PXCp_TransformPage throws an exception

Post by Tracker Supp-Stefan » Tue Jan 31, 2012 5:45 pm

Hello relapse,

After checkign this with our Viewer Project Leader, he confirmed that this method is not yet supported in our Viewer - so I have created a ticket in our internal system:
#1421: Viewer 2.5.201: Implement support for setPageBoxes JS
And this will be fixed for the next build of the Viewer.

Best,
Stefan

relapse
User
Posts: 167
Joined: Wed Jan 18, 2012 11:10 am

Re: PXCp_TransformPage throws an exception

Post by relapse » Wed Feb 01, 2012 6:56 am

Thanks for your answer. Back to PXCp_TransformPage function: I have a suggestion it's a problem with the document ID that I'm using. I suppose it's wrong because it should be a document handle.
Last edited by relapse on Wed Feb 01, 2012 11:01 am, edited 1 time in total.

relapse
User
Posts: 167
Joined: Wed Jan 18, 2012 11:10 am

Re: PXCp_TransformPage throws an exception

Post by relapse » Wed Feb 01, 2012 10:59 am

My suggestion was correct. I used document id provided by Viewer and not the document handle provided by PXCp_Init function. 8) But the PXCp_TransformPage function expects a handle!

The document is transformed, I only have to alter the boxes (crop box etc.).

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

Re: PXCp_TransformPage throws an exception

Post by John - Tracker Supp » Wed Feb 01, 2012 6:44 pm

So - unless otherwise we can assume this is resolved ?

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

relapse
User
Posts: 167
Joined: Wed Jan 18, 2012 11:10 am

Re: PXCp_TransformPage throws an exception

Post by relapse » Thu Feb 02, 2012 7:07 am

Not yet :(

After the transformation I get the PDF file where the outer border keeps its original size (see the attached file). I tried to alter the size of the boxes (crop, media and trim) either before transformation or after it but without any success. Do you have any idea what fails?



Thanks
Attachments
file.zip
(75.48 KiB) Downloaded 211 times

relapse
User
Posts: 167
Joined: Wed Jan 18, 2012 11:10 am

Re: PXCp_TransformPage throws an exception

Post by relapse » Thu Feb 02, 2012 12:55 pm

Sorry, my fault - I used false values resizing the boxes. And surely altering the boxes is to be done BEFORE file resizing. The problem is resolved. Thanks for all who helped me!

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

Re: PXCp_TransformPage throws an exception

Post by John - Tracker Supp » Thu Feb 02, 2012 1:32 pm

Excellent news - thanks Relapse :)
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

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

Re: PXCp_TransformPage throws an exception

Post by Paul - Tracker Supp » Thu Jun 14, 2012 12:29 am

Hi relapse

The "setPageBoxes" JS method that was not yet implemented in our Viewer has been added to the new build. It should be available for download around the 18th.

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

Post Reply