Version: SVN (using KDE 3.5.9) Installed from: RedHat RPMs Many PDF files have wide margins that, while suitable for printing on paper, are very wasteful of screen resources. This problem is especially grave with some academic publications that use enormous margins in their standard stylesheets. Implications include: * In Fit to Page zoom, wide vertical margins cause the real content of the page to be unnecessarily small (and at other zoom levels page flipping is messy) * In Continous mode, wide vertical margins necessitate a lot of scrolling between pages, and you can see less content simultaneously at page borders * In Two Pages mode, wide horizontal margins cause the real content to be unnecessarily small (often making this important mode useless) It would be great if Okular had an option to automatically detect margins and to subtract them from the image, prior to calculation of zoom level and rendering. To cover the overwhelming majority of cases, it would suffice to just have a simple heuristic which identifies the maximal white strip at each of the 4 edges of the paper. Related bugs: - Bug 115557 for the same feature in KPDF. - Bug 136695 for stripping whitespace when printing, as opposed to viewing.
Created attachment 24624 [details] Proposed patch for trimming whitespace borders Here's a rough patch that implements a "Trim Borders" mode for Okular, where most of the white borders are stripped from every page. This patch does the following: - Add a "bounding box" property to Okular::Page - Teach most of the generators to compute the page's bounding box when the page is first rendered, by scanning the rendered image (pixel-by-pixel) for white borders. - Add a "crop" property to PageViewItem - Add support for rendering cropped pages to PageView, PagePainter and PageViewAnnotator. - Add a "Trim Borders" mode to PageView, with a menu item under View and a config item. - When "Trim Borders" is enabled, set PageViewItem's crop according to the page's bounding box. - A few local comments/cleanups to help the next guy looking at this code. Open issues: - All the things pointed out in the new "TODO" comments. - Add "native" bounding box computation (instead of pixel scanning) to generators, where possible. - Since we only scan pixels after pixmaps are generated, the layout of far-away parts of the document will not reflect the cropped geometry. This causes the layout to jump around annoyingly as more pages become visible and are cropped. - Maybe there be a mode where all pages are cropped identically, so that displayed text sizes are uniform. - Needs testing and performance profiling.
Created attachment 24673 [details] Proposed patch for trimming whitespace borders Revised patch for trimming whitespace borders: same as the previous patch, except for improved calculation of crop area. (Can someone fix the typo in the bug's name?)
Created attachment 24825 [details] Proposed patch for trimming whitespace borders Revised version addressing Pino's comments. Same functionality, better implementation.
SVN commit 809496 by pino: Make it possible to draw just sections (crops within bounding boxes) of pages. Separated normal & cropped geometries in page items; made the page painter able to draw based on a crop section; add a config + menu option for turning the white borders removal. Based on a patch by the Mr. anonymous kde2eran@tromer.org, thanks. BUG: 161599 M +3 -0 conf/okular.kcfg M +2 -1 part.rc M +33 -17 ui/pagepainter.cpp M +11 -0 ui/pagepainter.h M +163 -75 ui/pageview.cpp M +1 -0 ui/pageview.h M +13 -14 ui/pageviewannotator.cpp M +57 -20 ui/pageviewutils.cpp M +28 -6 ui/pageviewutils.h WebSVN link: http://websvn.kde.org/?view=rev&revision=809496
SVN commit 809593 by pino: Make the poppler(pdf), spectre(ps), dvi and chm backend calculate and set bounding box of pages. CCBUG: 161599 M +3 -0 chm/generator_chm.cpp M +3 -0 dvi/generator_dvi.cpp M +11 -2 poppler/generator_pdf.cpp M +4 -0 spectre/generator_ghostview.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=809593