PDF-XChange - Tracker PDF Viewer - TIFF-XChange - Image-XChange - XMF-XChange - Raster-XChange - Support

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

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
 
whoit
User
Topic Author
Posts: 143
Joined: Tue Jul 07, 2015 3:30 pm

How to remove the content outside a CropBox?

Wed Sep 27, 2017 7:29 pm

Hi -

I'm currently trying to take a PDF which has a Crop Box, scale it, and remove any content outside the Crop Box.
I am working with the Crop Box and the Media Box to scale documents and maintain aspect ratios.
If my Crop Box scale smaller than my intended page size, I'd like to remove all content outside of the Crop Box.

This would be similar to using the Editor Feature "Remove the content outside of the crop area" (Document>Crop Pages>Crop Pages).
Can this be done with the CoreAPI ?
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2658
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to remove the content outside a CropBox?

Thu Sep 28, 2017 8:32 am

Hello whoit,

This can be done through the Core API - though there is no method that you can use directly for that. What you should do is take the IPXC_Content from the page and remove all of the items that are outside of the crop box area - that's all.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 143
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to remove the content outside a CropBox?

Thu Sep 28, 2017 12:25 pm

Hi Alex -

Can you be more specific about the process you refer to?

Do you have an example, or some lines of code or pseudo-code?

Thanks,
Wayne
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2658
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to remove the content outside a CropBox?

Thu Sep 28, 2017 12:56 pm

Hello Wayne,

Well there is not much to tell. You will have to extract a content (full clone) from each page and run through it's content items. Then you will have to get each item's bound box (BBox) and see whether it is inside/outside of the page's crop box. Then when you have the needed items, use IPXC_ContentItems::DeleteItems to remove the needed items from the content. Then you will have to set the page with the new changed content that you have.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 143
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to remove the content outside a CropBox?

Thu Sep 28, 2017 1:09 pm

What happens to an item that is partially in the crop box?
I assume you wouldn't remove it - correct?

Sorry - one more thing - what is the difference between a weak and full clone? (It's not in the docs).
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2658
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to remove the content outside a CropBox?

Thu Sep 28, 2017 1:44 pm

If the part is partially in the crop box - we would cut it.
Weak clone does not duplicate the content items, full clone does thus the weak clone is cheaper to use. Basically the weak clone would work in your case as you are modifying the item list, not the items themselves.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 143
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to remove the content outside a CropBox?

Thu Sep 28, 2017 2:01 pm

Maybe this is just a language thing but when you say "If the part is partially in the crop box - we would cut it."
do you mean that the Crop Box would cut the item (as expected)
or do you mean you would 'cut out' (delete) the item from the content?
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2658
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to remove the content outside a CropBox?

Sat Sep 30, 2017 7:20 am

Hello Wayne,

By cut, I meant that we are changing the content items by removing a part of them. If you want the same behavior - not just removing the content items entirely, then you can use the Redaction annotations as the Crop operation uses them. What you will need to do is to create a RedactInfo via IPXC_Inst::CreateRedactInfo, set that it's a CropMode to true. Then create a PXC_QuadF structure and fill it with 4 Crop Box points. Then use the IPXC_RedactInfo::InsertNew method to insert the quad into it. Also, what is being done in the operation is that the IPXC_RedactOverlayParams are being created and the FColor property is being set to ColorType_None from here http://sdkhelp.tracker-software.com/view/PXV:ColorType. Then you should set those overlay parameters to RedactInfo and then use the IPXC_Page::Redact method to apply the redaction to the content that is not in the Crop's margins.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 143
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to remove the content outside a CropBox?

Thu Oct 05, 2017 2:52 pm

Hi Alex -

I wanted to post some images to indicate what I'm trying to accomplish.

I want to:
1) Eliminate all of the contents outside of the crop area.
2) Scale the crop area to fit (aspect) the page.

I can do step 2 by scaling the CropBox and MediaBox, but step 1 is my issue.

Starting with this - an 17x11 inch page and an 11x8.5 inch crop area:

Image

I'd like to end up with this - an 11x17 inch page:

Image

To do what I show in the images I used this function in the Editor:

Image

Does this help clarify what I need to accomplish?
Can you provide steps to do this?
(Any sample could would help too)

Thanks,
Wayne
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2658
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to remove the content outside a CropBox?

Mon Oct 09, 2017 8:24 am

Hello Wayne,

Here's how this command works in the End-User Editor:
viewtopic.php?f=67&t=29628#p117006

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 143
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to remove the content outside a CropBox?

Mon Oct 09, 2017 12:36 pm

Hi Alex -

I read that and in fact have tried implementing it.
(Well, Mohsin has tried - we work together)

We're having a problem with data types since we have to use VB6 for this code.

I'll have Mohsin post the code and show you the issue.

Thanks,
Wayne
 
mmasood
User
Posts: 81
Joined: Fri Sep 18, 2015 9:49 pm

Re: How to remove the content outside a CropBox?

Mon Oct 09, 2017 1:40 pm

Hi Alex,

Following is the code that I wrote from your post above:

        Dim oRedactInfo As IPXC_RedactInfo
        Set oRedactInfo = pInst.CreateRedactInfo
       
        oRedactInfo.SetCropMode True
       
        Dim oQuad As PXC_QuadF
        Dim oEntry As IPXC_RedactEntry
        Dim lIndex As Integer
       
        oQuad.pt(0).x = LC
        oQuad.pt(0).y = BC
        oQuad.pt(1).x = LC
        oQuad.pt(1).y = TC
        oQuad.pt(2).x = RC
        oQuad.pt(2).y = TC
        oQuad.pt(3).x = RC
        oQuad.pt(3).y = BC
        lIndex = -1
               
        oRedactInfo.Clear
        oRedactInfo.InsertNew oQuad, llIndex
       
        Dim oRedactParams As IPXC_RedactOverlayParams
        oRedactParams.FColor = ColorType_None
       
        oRedactInfo.SetOverlayParams oRedactParams
       
        currentPage.Redact oRedactInfo


I am having an issue when compiling on the following line:

oRedactInfo.InsertNew oQuad, llIndex


The error is "Invalid Optional parameter type".

I check the help site and there was nothing there. Can you take a look and let me know what is wrong with the code?

Regards,
M
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2658
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to remove the content outside a CropBox?

Mon Oct 09, 2017 1:43 pm

Hello guys,

Can you please make this a small vb6 project that my colleague can use to recreate this behavior? We don't use the VB6 as our coding language though we can try investigating if we have a complete project.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
mmasood
User
Posts: 81
Joined: Fri Sep 18, 2015 9:49 pm

Re: How to remove the content outside a CropBox?

Mon Oct 09, 2017 3:02 pm

Hi Alex,

I have attached a small demo for you to look at.

Regards,
M
Attachments
CROP-Demo.rar
(4.49 KiB) Downloaded 13 times
 
whoit
User
Topic Author
Posts: 143
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to remove the content outside a CropBox?

Fri Oct 13, 2017 1:54 pm

Hi Alex -

Has there been any movement on this?

Have you been able to try the sample code that Mohsin uploaded?

Thanks,
Wayne
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2658
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to remove the content outside a CropBox?

Fri Oct 13, 2017 5:12 pm

Hello Wayne,

Yes, my colleague has been searching for a solution for two days now, though still no luck with this one.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 143
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to remove the content outside a CropBox?

Fri Oct 13, 2017 5:15 pm

Wow....I thought for sure it was just an issue with the declaration of a var or something....
 
mmasood
User
Posts: 81
Joined: Fri Sep 18, 2015 9:49 pm

Re: How to remove the content outside a CropBox?

Tue Oct 17, 2017 2:42 pm

Hi Alex,

Any update on this?

Regards,
M
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2658
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to remove the content outside a CropBox?

Tue Oct 17, 2017 3:03 pm

Hello guys,

Sadly we did not find a solution yet.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 143
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to remove the content outside a CropBox?

Fri Oct 20, 2017 2:43 pm

Hi Alex -

Is this because it is VB6 ?

Does this occur in .NET too?

I think we need to escalate this as it is preventing us from finishing our client's project.
What can we do from here to move this forward?
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2658
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to remove the content outside a CropBox?

Sat Oct 21, 2017 7:52 am

Hello whoit,

Well I just tried doing this on .Net - everything worked though be sure to create a new PXC_QuadF and new PXC_PointF[4] - had problem with those. Hopefully translating this to VB6 will work:
private void CropWithRedactionCoreLevel(IPXC_Document doc, IPXC_Inst coreInst)
{
   IPXC_RedactInfo redactInfo = coreInst.CreateRedactInfo();
   redactInfo.SetCropMode(true);
   coreInst.CreateQuads();
   PXC_QuadF q = new PXC_QuadF();
   q.pt = new PXC_PointF[4];
   //top>bottom
   q.pt[0].x = 100; q.pt[0].y = 100; //lb
   q.pt[1].x = 300; q.pt[1].y = 100; //rb
   q.pt[2].x = 300; q.pt[2].y = 400; //rt
   q.pt[3].x = 100; q.pt[3].y = 400; //lt

   redactInfo.InsertNew(ref q);
   IPXC_Page page = doc.Pages[0];
   IPXC_UndoRedoData data;
   page.Redact(redactInfo, out data);
}


Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
mmasood
User
Posts: 81
Joined: Fri Sep 18, 2015 9:49 pm

Re: How to remove the content outside a CropBox?

Mon Oct 23, 2017 2:06 pm

Hi Alex,

I tried implementing the code that you provided but was not able to run it in VB6. Can you please translate this code in VB6 so that I can give it a try?

Regards,
M
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2658
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to remove the content outside a CropBox?

Mon Oct 23, 2017 3:16 pm

Hello mmasood,

We will try to write this in VB6.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
mmasood
User
Posts: 81
Joined: Fri Sep 18, 2015 9:49 pm

Re: How to remove the content outside a CropBox?

Wed Oct 25, 2017 5:37 pm

Hi Alex,

Any luck with this so far?

Regards,
M
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2658
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to remove the content outside a CropBox?

Thu Oct 26, 2017 7:26 am

Hello mmasood,

Well we tried with our VB6 knowledge - no luck with this one. As you are a VB6 expert it would be easier for you to translate this code as this C# sample works correctly. I'm afraid that's pretty much all we can help with on this matter.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Who is online

Users browsing this forum: No registered users and 1 guest