Print Page | Close Window

Remove white spaces

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=2792
Printed Date: 20 Jul 25 at 11:20AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Remove white spaces
Posted By: kk aw
Subject: Remove white spaces
Date Posted: 01 Dec 13 at 12:19PM
Is it possible to remove the white spaces (along the borders) of the PDF document using the QuickPDF library?



Replies:
Posted By: AndrewC
Date Posted: 03 Dec 13 at 6:22AM
kk,

You could always adjust the CropBox and make it smaller.  Technically it doesn't remove any content from the PDF file but it adjusts the visiblee rectangle that is used for displaying the PDF in Acrobat and other viewers.

This would assume you know how big the borders are in the first place.  Depending on the PDF there could be ways to determine this programmatically.

  QP.LoadFromFile ....
  QP.SetPageBox(2, left, top, width, height);  // 2 = CropBox.
  QP.SaveToFile ..

Andrew.


Posted By: kk aw
Date Posted: 03 Dec 13 at 10:32AM
Andrew,

Thanks for the response.  I need to determine this programmatically.  How would I do that?

KK Aw


Posted By: AndrewC
Date Posted: 04 Dec 13 at 8:05AM
kk,

There is no simple solution as it depends on your PDF file.

One option would be to call QP.RenderPageToFile with a low DPI value to a Bitmap and then use code to read the pixels line by line searching for the 1st non white pixel.  You would need to search from 4 different directions to detect the top, left, right and bottom margins.  You then convert this pixel position back to points.  If you render at 72dpi then pixels = points.

Andrew.



Posted By: kk aw
Date Posted: 04 Dec 13 at 10:39AM
Thanks.  



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