How can we read contents of the pdf file using vim command in the terminal? I have tried using pdftk by uncompressing it but still its not working for me. Is there any other way to decrypt or decode the pdf so that we can read by the terminal in any Linux flavour using vim.
If you want to read the pdf as text you can try the pdftotext
command, though it won't always be beautiful. If you'd like vim to open pdf files in a pdf reader you can use something in your .vimrc like
au BufRead *.pdf sil exe "!xdg-open " . shellescape(expand("%:p")) | bd | let &ft=&ft | redraw!
This question is more or less a duplicate of this one.
However, following the answers of @Conner and @Eric, the pdftotext
utility is a recommended approach if you are only interested in the text content.
A possible approach to pdftotext
can be found e.g. here.
There also exists a rather new Vim plugin to simplify these steps.
This plugin can be found here or here
You might also write some ftplugin acting as a preprocessor to extract the text of a given pdf. Nevertheless, you won"t be able to change anything in the pdf with the proposed tools.
Some pdf text contents can be extracted with pdf2txt, then fed to vim. Of course, you will lose most of the formatting, graphics, etc.
© 2022 - 2024 — McMap. All rights reserved.
vim the editor
It is not pdf reader, it is not MS-Word reader. You can of course write a pdf reader with other language, e.g. Java with itext lib. and in vim call that tool. but this is not the right way to use vim. my 2 cents. – BarnstormASCII85Encode
) binary streams like images, fonts etc. Unfortunately. Therefore, most PDF files after un-compression still contain binary data and are not suitable for text editor. Maybe you want have a look at COS-structure editors/explorers (PoDoFo browser, Enfocus PDF browser, iText RUPS (they are all free) etc.). – Pinyless
can read PDFs.less file.pdf
. – Attrition