Page 1 of 1

PXCp_TransformPage equivalent in Core API

Posted: Thu Mar 31, 2016 10:38 pm
by mmasood
Hi,

I am converting an application from PDF Tools to Core API and could not find a function/group of functions that I should be using to achieve the same functionality. I looked into the forum and the help site but could not find anything. Can you please guide me on this?

Regards,
M

Re: PXCp_TransformPage equivalent in Core API

Posted: Fri Apr 01, 2016 12:41 pm
by Sasha - Tracker Dev Team
Hello mmasood,

This piece of code will do the same thing:
https://gist.github.com/Polaringu/1a7f9 ... f0498d2622

Cheers,
Alex

Re: PXCp_TransformPage equivalent in Core API

Posted: Fri Apr 01, 2016 9:12 pm
by mmasood
Hi Alex,

I tried the method that you posted and following are my observations:

1. It only works if you have very few (i believe < 10) GStates on the page
2. If we have placed a watermark on the page, it gets messed up (instead of going across the page from bottom-left to top-right, it goes from bottom-left to bottom-right)
3. If there are any images on the page, they disappear
4. If there are many GStates on the page, the result is a mess

Here are a few questions:

1. What exactly are the GStates?
2. What are CStates, EStates and TStates?
3. I want to transform everything in the page's Media Box in one go (like PXCp_TransformPage did) and do not want to transform every GState one by one. How can I do that?

Regards,
M

Re: PXCp_TransformPage equivalent in Core API

Posted: Sat Apr 02, 2016 11:58 am
by Sasha - Tracker Dev Team
Hello mmasood,
1. What exactly are the GStates?
2. What are CStates, EStates and TStates?
You can read about this in the PDF specification.
3. I want to transform everything in the page's Media Box in one go (like PXCp_TransformPage did) and do not want to transform every GState one by one. How can I do that?
Currently there is no other way of doing that. The only way is to implement your method that would do this (similar to the one I gave as an example).
1. It only works if you have very few (i believe < 10) GStates on the page
2. If we have placed a watermark on the page, it gets messed up (instead of going across the page from bottom-left to top-right, it goes from bottom-left to bottom-right)
3. If there are any images on the page, they disappear
4. If there are many GStates on the page, the result is a mess
The method that I gave illustrates the overall algorithm of what should be done. The problems could occur when the same GState was modified several times - you'll need to take that into account.

Also a small working sample that illustrates all of your problems would be preferable.

Cheers,
Alex

Re: PXCp_TransformPage equivalent in Core API

Posted: Fri Sep 16, 2016 8:37 pm
by mmasood
Hi Alex,

Just wanted to know if there has been any development in the recent version of the Core API regarding the PXCp_TransformPage function in V5? I am using the version 6.0.317 of Core API. If there is, can you please post some sample code?

Also if this functionality is not available in Core API, do you have some function in Editor SDK that can achieve the same functionality i.e. resize the contents of the page and redraw then at specific coordinates?

Regards,
M

Re: PXCp_TransformPage equivalent in Core API

Posted: Mon Sep 19, 2016 5:22 am
by Sasha - Tracker Dev Team
Hello mmasood,

All of this is possible on the Core API level. Please provide a piece of code that is not working for you and also a sample document so that we can advice further.

Cheers,
Alex

Re: PXCp_TransformPage equivalent in Core API

Posted: Mon Oct 10, 2016 7:45 pm
by mmasood
Hi Alex,

I am trying with the code that you posted above and getting the same results. Is the code that you post the only way to do this?

Regards,
M

Re: PXCp_TransformPage equivalent in Core API

Posted: Tue Oct 11, 2016 8:48 am
by Sasha - Tracker Dev Team
Hello mmasood,

Please provide a small sample project with your code that is not working and a file sample that you test on and we can assist further.

Cheers,
Alex

Re: PXCp_TransformPage equivalent in Core API

Posted: Thu Oct 13, 2016 8:33 pm
by mmasood
Hi Alex,

Attached is a small sample application in VB6 along with some sample files. Please let me know if you find anything in the sample that should be changed.

Regards,
M

Re: PXCp_TransformPage equivalent in Core API

Posted: Fri Oct 14, 2016 8:54 am
by Sasha - Tracker Dev Team
Hello mmasood,

The files that you've attached contained a valid licence key.
Please do NOT post your license information on the forums, or we will be forced to deactivate it!

As for the issue - we will investigate it and write back with the results.

Chees,
Alex

Re: PXCp_TransformPage equivalent in Core API

Posted: Mon Oct 17, 2016 8:35 pm
by mmasood
Hi Alex,

Is there any update on this? I also downloaded the latest version of the Core API (6.0.318.1) and had the same results.

Thanks for pointing out the license key mistake. I will be more careful in future.

Regards,
M

Re: PXCp_TransformPage equivalent in Core API

Posted: Tue Oct 18, 2016 6:02 am
by Sasha - Tracker Dev Team
Hello mmasood,

We are still testing (as this is VB6 that is problematic to use on modern environments), but from what I have seen - you are not doing what I gave you as a sample. If you would look carefully, you would see that you need to multiply the CTM with your matrix.

Code: Select all

PDFXEdit.PXC_Matrix mCtm = gState.get_CTM();
mCtm = Multiply(mCtm, m);
gState.set_CTM(mCtm);
Please update the code with the correct one and try whether everything works for you.
Also, we have updated the library with the MathHelper that has the operations with matrices included. So you can use this method instead of the hand-written Multiply method that I wrote in the sample:

Code: Select all

PDFXEdit.PXC_Matrix mCtm = gState.get_CTM();
mCtm = auxInst.MathHelper.Matrix_Multiply(mCtm, m);
gState.set_CTM(mCtm);
Where the auxInst is the IAUX_Inst.

Cheers,
Alex

Re: PXCp_TransformPage equivalent in Core API

Posted: Wed Oct 26, 2016 9:22 pm
by mmasood
Hi Alex,

The problem was solved by adding the multiply function. Thanks for pointing that out.

I have another issue that I am running into; i want to resize the PDF pages to a predefined page size. With the old library this is what I was doing:

1. Create an new PDF
2. Add empty pages of the desired size to the new PDF
3. Place the content of the existing PDF page by page on the new file using the following code:

Code: Select all

    For i = 0 To (num_pages - 1)
        ' Prepare information for placing the contents
        pci.Alignment = &H3 Or &H30 Or &H100 & &H200
        ' Destination page in the target document
        pci.DestPage = i
        ' Source page (first one) from the source document
        pci.SrcPage = i
        
        res = PXCp_PlaceContents(newPdf, pdf, 1, pci, 0)
        If IS_DS_FAILED(res) Then
            sError = "Failed to copy content into new pdf document: " & ReturnDSErrorString(res)
            GoTo badpdf:
        End If
    Next
I can achieve 1 and 2 with the Core API but not 3. What are the proper function calls that I need?

Regards,
M

Re: PXCp_TransformPage equivalent in Core API

Posted: Thu Oct 27, 2016 5:10 am
by Sasha - Tracker Dev Team

Re: PXCp_TransformPage equivalent in Core API

Posted: Thu Oct 27, 2016 1:25 pm
by mmasood
Hi Alex,

Following is the code that I have:

Code: Select all

Set oPageContent = currentPage.GetContent(PXC_ContentAccessMode.CAccessMode_WeakClone)
where 'currentPage' is the page of the existing document.

Code: Select all

pDocNew.Pages.Item(i).PlaceContent oPageContent, PXC_PlaceContentFlags.PlaceContent_Replace
and 'pDocNew' is the new PDF file that I created and added an empty page to that document. This outputs an empty page in the new PDF file and no content is added to that page even though there is no crash.

Q. Can I export content from one document to another using this code?

Regards,
M

Re: PXCp_TransformPage equivalent in Core API

Posted: Thu Oct 27, 2016 2:07 pm
by Sasha - Tracker Dev Team
Well, you can copy the entire pages from one document to another using this method:
http://sdkhelp.tracker-software.com/vie ... gesFromDoc

Cheers,
Alex

Re: PXCp_TransformPage equivalent in Core API

Posted: Thu Oct 27, 2016 3:19 pm
by mmasood
Hi Alex,

I have tried that but then I cannot extend the page size to the custom page size. So if I do that, how can I extend the page size?

I tried setting the Box property to an updated rectangle of the custom size but that does not extend/shrink the page size.

How can I achieve this?

Regards,
M

Re: PXCp_TransformPage equivalent in Core API

Posted: Fri Oct 28, 2016 9:19 am
by Sasha - Tracker Dev Team
You will need to change the PBox_MediaBox.

Cheers,
Alex

Re: PXCp_TransformPage equivalent in Core API

Posted: Fri Oct 28, 2016 1:32 pm
by mmasood
Hi Alex,

Yes I am already changing the Media Box.

Regards,
M

Re: PXCp_TransformPage equivalent in Core API

Posted: Fri Oct 28, 2016 1:47 pm
by Sasha - Tracker Dev Team
Please provide a piece of code that you change the page's size with so I can assist you further.

Cheers,
Alex