-
-
Notifications
You must be signed in to change notification settings - Fork 238
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
Use mutool draw for previewing PDFs #494
Comments
PDF previews would allow me to use broot as my main file browser, I hope it can be added! In addition to mutool, the Kitty icat method may be of interest. It uses ImageMagick to open both images and pdfs. (For a pdf, one generally needs a white background.) |
Just discovered Broot. Amazing application. PDF previews are literately the only missing feature. |
@xxyxxyxyx1 @mizlan @andrej1919 Feedback on #898 would be welcome |
This allows defining file transformations that are applied to files before preview. The default conf has 2 examples: previewing PDF and beautifying JSON: ```Hjson preview_transformers: [ # Use mutool to render any PDF file as an image # In this example we use placeholders for the input and output files { input_extensions: [ "pdf" ] // case doesn't matter output_extension: png mode: image command: [ "mutool", "draw", "-o", "{output-path}", "{input-path}" ] } # Use jq to beautify JSON # In this example, the command refers to neither the input nor the output, # so broot pipes them to the stdin and stdout of the jq process { input_extensions: [ "json" ] output_extension: json mode: text command: [ "jq" ] } ] ``` PDF preview: ![image](https://github.com/Canop/broot/assets/617006/4c140060-573f-4368-b98b-61443f2f56c9) JSON beautification (the original file has no space nor new line): ![image](https://github.com/Canop/broot/assets/617006/9363bd0e-0ad4-43cc-956d-6d807e40d11c) Fix #494
MuPDF's
mutool draw
command produces a decently high-resolution image form of a PDF. It can be specified to only produce an image of the first page, which would be nice for previewing PDFs.Quick demo (after installing MuPDF):
$ mutool draw -o pdf-preview.png julia-1.5.0.pdf 1 # can add 2>/dev/null page julia-1.5.0.pdf 1 $ kitty +kitten icat pdf-preview.png
Or directly through stdout:
The text was updated successfully, but these errors were encountered: