Print Page | Close Window

Creating a New page from a portion of a Page

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3574
Printed Date: 20 Apr 24 at 3:14AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Creating a New page from a portion of a Page
Posted By: HNRSoftware
Subject: Creating a New page from a portion of a Page
Date 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



Replies:
Posted By: kevindebenu
Date 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: kevin_newman@foxitsoftware.com

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.

Regards,
Kevin Newman
Foxit Software



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk