Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Creating a New page from a portion of a Page
  FAQ FAQ  Forum Search   Register Register  Login Login

Creating a New page from a portion of a Page

 Post Reply Post Reply
HNRSoftware View Drop Down
Senior Member
Senior Member

Joined: 13 Feb 11
Location: Washington, USA
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote HNRSoftware Quote  Post ReplyReply Direct Link To This Post Topic: Creating a New page from a portion of a Page
    Posted: 25 May 18 at 2:07PM
This may just be a vocabulary question - not knowing which family of calls to use.  I have a large 36"x24" architectural file with 70 layers.  I wish to create a new file which is a rectangular area of that page with a certain selection of layers.  At this point, I can successfully use the CropBox and OptionalContentGroup functions to do this particular job, but the resulting file would be the original file with a few things set to limit the display.  The destination file would be virtually identical in size to the original, and actually contain the entirety of the original file, just much of it masked off.

"Rendering" lets me extract that rectangular area to many types of image files/streams, but "PDF" is not a destination type.  "Rendering" is pretty much taking a snapshot picture of a page, or portion of a page.

Can anyone point me to a function area that goes in the direction I'm describing? -- pdf to smaller pdf? (but, not by rendering to an image of the page).

If I use "DeleteOptionalContentGroup", will it completely remove all traces of that content group from the resulting file?  So, will "loadfromfile"/"selectpage"/"DeleteOptionalContentGroup"/"savetofile", result in a smaller file?  with all of the other content groups undisturbed?   (I know I could try this, but I'm getting tired of trial-and-error as a substitute for documentation).  To rephrase the question - Will using "DeleteOptionalContentGroup" on all content groups except one produce a file that just contains that one optional content group (plus fonts and other normal overhead)?

Is there a comparable "crop" operation that will remove internal pdf commands that don't produce any effects within the crop rectangle?  In order to do what I visualize, a line passing through the rectangle would have to be shortened by setting the endpoints to the places where it crosses the rectangle.  I suspect that this is not possible (or at least is not an existing QuickPDF function).  My gut says that it would be extremely hard to apply command-by-command cropping. 

My gut says that "rendering" to a CropBox is actually the rendering of the entire page to a canvas and then cropping the result.  My best evidence for this is that it takes nearly as long to render a 1"x1" square of the page as it does to render the entire page.  This is what I was doing in my own code before I discovered the CropBox (and I still do this to avoid the 3/4 second render of the 36x24 page every time I want to move around in the page image - the 1"x1" extraction from a bitmap takes virtually zero time).

Anyway, I'm just looking for suggestions or areas to explore.

Thanks - Howard
Back to Top
kevindebenu View Drop Down
Moderator Group
Moderator Group

Joined: 16 Apr 12
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote kevindebenu Quote  Post ReplyReply Direct Link To This Post Posted: 17 Jul 18 at 1:33PM
Hello Howard,

Optional Content Groups in a PDF can be implemented in many ways, so it's difficult to say for sure if it would be possible to remove the actual content from a layer. Are you able to send me a copy of the file? It might be possible to do this using the GetPageContentStreamToString/SetPageContentStreamToString functions. My e-mail address is:

The second request, to remove non-visible objects that are outside the crop area, is quite a bit more difficult! It might be possible for us to add such a feature to a future version of Quick PDF Library. It would require a content stream filter operation. During processing of the page content, the byte position of each drawing object command would need to be stored. Then, for each object, the bounds of the object would be checked to see if they are within the crop area. If not, the drawing commands could be removed from the PDF. It's quite a difficult process, but depending on how the input PDF has been put together it might be possible.

Kevin Newman
Foxit Software
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store