Combining Images on PDF Page

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, 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.
Post Reply
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Combining Images on PDF Page

Post by jeffp »

Some programs when creating an image PDF or partial image PDF break up the image into multiple images before placing them on the page.

I'm looking for a way in the PDF Editor SDK to combine or stitch together all the smaller images into one image. And then eventually present that one image to the user to edit (in a separate image editor) and then to place the one image back into the page while removing all the smaller images.

I need to pull the image out this way instead of rasterizing the entire page because some times the page contains text as well as images and the text needs to be preserved.

If the page contains just one image, I know how to pull it out, edit it, and put it back. I just don't know how to pull out multiple images and turn then into one image.

Can you point me in the right direction. Would prefer to use IPXC_ procedures.

Thanks.

--Jeff
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8371
Joined: Wed Jan 03, 2018 6:52 pm

Re: Combining Images on PDF Page

Post by TrackerSupp-Daniel »

Hello, jeffp

Thank you for the inquiry, To my knowledge, this is not something that we offer innately, so I am uncertain if it can be done, even with the SDK products, but I have asked our Dev team to take a look and see what they think. Hopefully one of them will get back to you soon with their input on the situation.

Kind regards,
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2351
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Combining Images on PDF Page

Post by Vasyl-Tracker Dev Team »

Hi Jeff.

The possible way is:

1. Firstly you need to collect info about all images on the page: IPXC_ContentItem - Type, BBox, GetCTM..., Image_Object...
2. Lookup for groups of images that need to be merged(rasterized) together. For that you may analyze their 'proximity' having the image's actual rectangle on the page:

PXC_Rect rectOnPage = { 0,0,1,1};
IMathHelper::Rect_Transform(CTM, rectOnPage);

Also you may try to calculate the best rasterization-DPI for such group as:

dpiX = Image_Object.Width * 72.0 / rectOnPage.width
dpiY = Image_Object.Height * 72.0 / rectOnPage.height
imgDpi = max(dpiX, dpiY);
bestGroupDpi = max(imgDpi[1..N])

3. calc bounding GroupBBox for each group of small images. Create new image(IIXC_Page) with a size corresponding to GroupBBox and bestGroupDpi.

4. use IPXC_Page::DrawToIXCPage to draw this GroupBBox-part of the page to that new image, also with special additional IPXC_OCContext object (CreateStdOCCtx) that must have specified your own IPXC_CIVisibilityCallback to exclude all unnecessary content items (which are not from a current group). The DrawToIXCPage will call IPXC_CIVisibilityCallback::IsCIVisible for each content item to get permission to render it. The nCIPath parameter is the array of indexes that contains:
[PageIndex, ContentItemIndex]
(This array can be longer in case when ContentItemIndex pointing the non-empy ContentItem-XForm:
[PageIndex, ContentItemXFormIndex, IndexOfContentItemInsideThatXForm ...])
and the Draw-matrix you may get using this calculation:

m.a = newImageWidth / (GroupBBox.right - GroupBBox.left);
m.b = 0;
m.c = 0;
m.d = -newImageHeight / (GroupBBox.top - GroupBBox.bottom);
m.e = -GroupBBox.left * m.a;
m.f = -GroupBBox.bottom * m.d + H - 1;

5. Then you need to remove all group's images and replace them with this new one, and with the following CTM:

PXC_Rect imageRect = { 0,0,1,1 };
IMathHelper::Matrix_RectToRect(imageRect, GroupBBox, newImageCTM);

Do the same work for each group of images detected on the page...

HTH
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: Combining Images on PDF Page

Post by jeffp »

I'll give it a try. Thanks.

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

Re: Combining Images on PDF Page

Post by Paul - Tracker Supp »

Do let us know how that goes?
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: Combining Images on PDF Page

Post by jeffp »

m.f = -GroupBBox.bottom * m.d + H - 1;

What does the "H" refer to above?
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2351
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Combining Images on PDF Page

Post by Vasyl-Tracker Dev Team »

H == newImageHeight

mistyped, sorry.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Post Reply