Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally auto-crop pages #20

Open
robamler opened this issue May 8, 2012 · 1 comment
Open

Optionally auto-crop pages #20

robamler opened this issue May 8, 2012 · 1 comment

Comments

@robamler
Copy link

robamler commented May 8, 2012

There should be an option to auto-crop pages. This would make the use of Texlipse and Pdf4Eclipse even more awesome.

I use a tex editor view and a pdf4eclipse view next to each other so that I have a preview of the document I'm currently editing next to its tex source code. In such a setup, displaying the page margins of the pdf just wastes screen real estate. It would therefore be helpful to have a toolbar button that toggles between displaying the full page and displaying the page without any (automatically detected) white margins. Of course, one can already zoom into the page and fit the relevant part of the page to the screen but this does not play well with scrolling if even and odd pages have alternating left/right margins. I could try to implement this feature myself if you provide me with some hints about where to start.

@Borisvl
Copy link
Owner

Borisvl commented May 9, 2012

Yes, indeed that would be a nice addition and I would be happy if you provide a patch for that.
I see two possible ways how to implement this: Either directly on the pdf level, you can detect where the content is located inside the page and crop the other parts, or --probably easier to implement-- you look at the final rendered page image and detect white borders. For the second approach you can create a filter that provides a new cropped image out of the BufferedImage that is returned by the renderer in the showPage method in PDFPageViewer.

robamler added a commit to robamler/Pdf4Eclipse that referenced this issue May 10, 2012
This implementation follows the second approach outlined
in #issuecomment-5596872 (see issue Borisvl#20 on github.com/Borisvl/
Pdf4Eclipse). Auto-trimming can be turned on and of with the
boolean field PDFPageView.autoTrimOn, which, for now, is just
a static constant.

Things that remain to do:

 - I'm not sure if this implementation is memory efficient.
   Maybe we could do with copying the image one less time.

 - Coordinate transformation for forward/backward search and
   for annotations.

 - Correct handling of the "fit page to screen" and "fit page
   width to screen width" zoom actions.

 - Frontend to turn auto-trimming on and off (toggle button).
robamler added a commit to robamler/Pdf4Eclipse that referenced this issue May 13, 2012
Finish implementation of auto-trimming of page margins.
Detailed list of changes compared to previous commit:

 - Add front end (toolbar button).

 - Fix coordinate transformations for annotations and for
   synctex forward/backward search.

 - Fix behaviour of the "fit page to screen" and "fit page
   width to screen width" commands when auto-trimming is
   activated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants