How to remove the content outside a CropBox?
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, 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.
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.
-
- User
- Posts: 269
- Joined: Tue Jul 07, 2015 3:30 pm
How to remove the content outside a CropBox?
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 ?
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
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: How to remove the content outside a CropBox?
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
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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 269
- Joined: Tue Jul 07, 2015 3:30 pm
Re: How to remove the content outside a CropBox?
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
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
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: How to remove the content outside a CropBox?
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
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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 269
- Joined: Tue Jul 07, 2015 3:30 pm
Re: How to remove the content outside a CropBox?
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).
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
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: How to remove the content outside a CropBox?
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
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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 269
- Joined: Tue Jul 07, 2015 3:30 pm
Re: How to remove the content outside a CropBox?
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?
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
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: How to remove the content outside a CropBox?
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 https://sdkhelp.pdf-xchange.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
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 https://sdkhelp.pdf-xchange.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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 269
- Joined: Tue Jul 07, 2015 3:30 pm
Re: How to remove the content outside a CropBox?
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:
I'd like to end up with this - an 11x17 inch page:
To do what I show in the images I used this function in the Editor:
Does this help clarify what I need to accomplish?
Can you provide steps to do this?
(Any sample could would help too)
Thanks,
Wayne
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:
I'd like to end up with this - an 11x17 inch page:
To do what I show in the images I used this function in the Editor:
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
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: How to remove the content outside a CropBox?
Hello Wayne,
Here's how this command works in the End-User Editor:
https://www.pdf-xchange.com/forum3 ... 28#p117006
Cheers,
Alex
Here's how this command works in the End-User Editor:
https://www.pdf-xchange.com/forum3 ... 28#p117006
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 269
- Joined: Tue Jul 07, 2015 3:30 pm
Re: How to remove the content outside a CropBox?
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
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
-
- User
- Posts: 101
- Joined: Fri Sep 18, 2015 9:49 pm
Re: How to remove the content outside a CropBox?
Hi Alex,
Following is the code that I wrote from your post above:
I am having an issue when compiling on the following line:
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
Following is the code that I wrote from your post above:
Code: Select all
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
Code: Select all
oRedactInfo.InsertNew oQuad, llIndex
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
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: How to remove the content outside a CropBox?
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
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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 101
- Joined: Fri Sep 18, 2015 9:49 pm
Re: How to remove the content outside a CropBox?
Hi Alex,
I have attached a small demo for you to look at.
Regards,
M
I have attached a small demo for you to look at.
Regards,
M
You do not have the required permissions to view the files attached to this post.
-
- User
- Posts: 269
- Joined: Tue Jul 07, 2015 3:30 pm
Re: How to remove the content outside a CropBox?
Hi Alex -
Has there been any movement on this?
Have you been able to try the sample code that Mohsin uploaded?
Thanks,
Wayne
Has there been any movement on this?
Have you been able to try the sample code that Mohsin uploaded?
Thanks,
Wayne
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: How to remove the content outside a CropBox?
Hello Wayne,
Yes, my colleague has been searching for a solution for two days now, though still no luck with this one.
Cheers,
Alex
Yes, my colleague has been searching for a solution for two days now, though still no luck with this one.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 269
- Joined: Tue Jul 07, 2015 3:30 pm
Re: How to remove the content outside a CropBox?
Wow....I thought for sure it was just an issue with the declaration of a var or something....
-
- User
- Posts: 101
- Joined: Fri Sep 18, 2015 9:49 pm
Re: How to remove the content outside a CropBox?
Hi Alex,
Any update on this?
Regards,
M
Any update on this?
Regards,
M
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: How to remove the content outside a CropBox?
Hello guys,
Sadly we did not find a solution yet.
Cheers,
Alex
Sadly we did not find a solution yet.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 269
- Joined: Tue Jul 07, 2015 3:30 pm
Re: How to remove the content outside a CropBox?
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?
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
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: How to remove the content outside a CropBox?
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:
Cheers,
Alex
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:
Code: Select all
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);
}
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 101
- Joined: Fri Sep 18, 2015 9:49 pm
Re: How to remove the content outside a CropBox?
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
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
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: How to remove the content outside a CropBox?
Hello mmasood,
We will try to write this in VB6.
Cheers,
Alex
We will try to write this in VB6.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 101
- Joined: Fri Sep 18, 2015 9:49 pm
Re: How to remove the content outside a CropBox?
Hi Alex,
Any luck with this so far?
Regards,
M
Any luck with this so far?
Regards,
M
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: How to remove the content outside a CropBox?
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
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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ