Hot answers tagged

135

Install the package pdfgrep, then use the command: find /path -iname '*.pdf' -exec pdfgrep pattern {} + —————— Simpliest way is pdfgrep 'pattern' *.pdf pdfgrep 'pattern' file.pdf


84

convert, the ImageMagick utility used in Ketan's answer, also allows you to write something like convert xc:none -page Letter a.pdf or convert xc:none -page A4 a.pdf or (for horizontal A4 paper) convert xc:none -page 842x595 a.pdf etc., without creating an empty text file. @chbrown noticed that this creates a smaller pdf file. "xc:" means "X Constant ...


82

Using Xournal you can annotate PDFs and add custom images (e.g. a transparent PNG). Although it is used for taking freehand notes and drawing, it can also annotate PDFs. On Ubuntu: Install Xournal through the Ubuntu Software Center Open Xournal Select "Annotate PDF" from the File menu and select your PDF file to be signed. Click the "Image" button in the ...


66

One solution that usually works is to use pdfjam from the texlive distribution > pdfinfo in.pdf ... Producer: Acrobat Distiller 6.0.1 (Windows) ... Page size: 612 x 792 pts (letter) Page rot: 0 File size: 66676 bytes Optimized: yes PDF version: 1.4 > pdfjam --outfile out.pdf --paper a4paper in.pdf > pdfinfo out.pdf ...


60

Last time I used convert for such a task I explicitly specified the size of the destination via resizing: $ i=150; convert a.png b.png -compress jpeg -quality 70 \ -density ${i}x${i} -units PixelsPerInch \ -resize $((i*827/100))x$((i*1169/100)) \ -repage $((i*827/100))x$((i*1169/100)) multipage.pdf The convert command doesn't always use ...


53

In many systems less uses lesspipe, which can handle pdftotext automatically. Therefore, you can immediately try less file.pdf which will show the output of pdftotext in less.


52

Just an addition since I had issues with the python script (and several other solutions): for me mutool worked great. It's a simple and small addition shipped with the elegant mupdf reader. So you can try: mutool poster -y 2 input.pdf output.pdf For horizontal splits, replace y with x. And you can, of course, combine the two for more complex solutions. ...


48

Just use pdftk. For rotating clockwise: pdftk input.pdf cat 1-endeast output output.pdf For rotating anti-clockwise: pdftk input.pdf cat 1-endwest output output.pdf Regarding the installation of pdftk on Fedora, I found this link.


42

I just stumbled upon this thread and saw that there is no good solution mentioned yet. I found that (at least on Debian and Ubuntu) pdfjam comes with the following commands: pdf90 input.pdf pdf180 input.pdf pdf270 input.pdf I think that is the easiest and fastest approach. These are scripts using the pdfjam command properly. Btw. the pdfjam is a virtual ...


39

One of the canonical tools for this is pdfinfo, which comes with xpdf, if I recall. Example output: [0 1017 17:10:17] ~/temp % pdfinfo test.pdf Creator: TeX Producer: pdfTeX-1.40.14 CreationDate: Sun May 18 09:53:06 2014 ModDate: Sun May 18 09:53:06 2014 Tagged: no Form: none Pages: 1 Encrypted: no Page ...


34

pandoc can do this. It's more focused on converting marked-up text to various formats, but it should have no problems with simple plaintext. pandoc input.txt -o output.pdf


34

Like the smallest possible GIF, the smallest possible blank-page PDF needs to be worked out by hand, because it's so small that unnecessary-but-harmless bits of metadata become a significant part of the file size, and compression actually makes things bigger. It also requires careful attention to the rules in the PDF specification about what bits of the ...


30

With pdftk version 1.45 (6 December 2012) or later, use: pdftk A=MyPdfFile.pdf shuffle AoddWest AevenEast output MyRotatedFile.pdf If you have pdftk version 1.44 (thanks to Gilles for pointing that out!), you can use: pdftk A=MyPdfFile.pdf shuffle AoddL AevenR output MyRotatedFile.pdf Some similar example cases are described in man pdftk (at least in ...


30

The 'pts' unit used by pdfinfo denotes a PostScript point. A PostScript point is defined in terms of an inch and a resolution of 72 dots per inch: In the late 1980s to the 1990s, the traditional point was supplanted by the desktop publishing point (also called the PostScript point), which was defined as 72 points to the inch (1 point = 1⁄72 inches = 25.4⁄...


29

Add set selection-clipboard clipboard in the config file ~/.config/zathura/zathurarc or /etc/zathurarc.


26

I guess, it is not possible to see PDF file in terminal but you can check it's content by converting PDF file to text. You can do this as: pdftotext a.pdf It will produce a.txt file which you can read into VIM. For ubuntu-variant, this binary is available in following package. poppler-utils


24

Not a real viewer, but as first aid a converter may also help: pdftotext file.pdf - | less pdftohtml -stdout -i file.pdf | lynx -stdin pdftotext and pdftohtml are part of the Poppler package.


24

I found these 2 method via Google, in this thread titled: Re: Flattening PDF Files at the UNIX Command Line. Method #1 - using Imagemagick's convert: $ convert orig.pdf flattened.pdf NOTE: The quality is reported to be so so with this approach. Method #2 - Using pdf2ps -> ps2pdf: $ pdf2ps orig.pdf - | ps2pdf - flattened.pdf NOTE: This method is ...


24

You can use the program pdftk to set both the owner and/or user password pdftk input.pdf output output.pdf owner_pw xyz user_pw abc where owner_pw and user_pw are the commands to add the passwords xyz and abc respectively (you can also specify one or the other but the user_pw is necessary in order to prohibit opening). You also might want to override the ...


23

What you really want to use is: $ convert a.png b.png -compress jpeg -resize 1240x1753 \ -extent 1240x1753 -gravity center \ -units PixelsPerInch -density 150x150 multipage.pdf -extent actually extends the image to be 1240x1753, while -resize keeps the image's ratio, fitting it into either 1240x... or ...x1753. ...


23

If you have convert (an ImageMagick utility) installed, you could do this: touch a.txt && convert a.txt -page Letter a.pdf


23

pandoc is a great command-line tool for file format conversion. The disadvantage is for PDF output, you’ll need LaTeX. The usage is pandoc test.html -t latex -o test.pdf If you don't have LaTeX installed, then I recommend htmldoc. Cited from Creating a PDF By default, pandoc will use LaTeX to create the PDF, which requires that a LaTeX engine be ...


22

Best and easyest way out there is to use pypdfocr it doesn't change the pdf. pypdfocr is a python module link here. pypdfocr your_document.pdf At the end you will have another your_document_ocr.pdf the way you want it with searchable text. The app doesn't change the quality of the image. Increases the size of the file a bit by adding the overlay text. I ...


21

NOTE: The 9.x branch of reader has been EOL'd as of June 26, 2013. If you need native Adobe Reader support on Linux, 9.x is your only option! 10 doesn't list Linux as being supported, and likely never will. More on it too here: Adobe abandons Linux. Many may question the relevance of needing Adobe Reader but there are several use cases that the open source ...


21

The gs example The gs command you're running above has a trailing $1 which is typically meant for passing command line arguments into a script. So I'm not sure what you actually tried but I'm guessing that you tried to put that command into a script, script.sh: #!/bin/bash gs -sOutputFile=output.pdf \ -q -dNOPAUSE -dBATCH -dSAFER \ -...


18

Ghostscript (gs) worked better than pdf2ps and convert for me. Quality was hardly degraded and file size is small. gs -dSAFER -dBATCH -dNOPAUSE -dNOCACHE -sDEVICE=pdfwrite \ -sColorConversionStrategy=/LeaveColorUnchanged \ -dAutoFilterColorImages=true \ -dAutoFilterGrayImages=true \ -dDownsampleMonoImages=true \ -dDownsampleGrayImages=true \ -...


18

Yes this is possible, it's just not well documented. Or documented at all for that matter. The only reference I found was in an issue report. Once a file is opened, you can change the first page location by running :set first-page-column 2 from the command line. This same line can be added to the rc file at ~/.config/zathura/zathurarc to make it the default....


18

This is not a PDF file. This is a Word document. (Well, it's an “Office Open XML” document, but it's Microsoft's format.) These files are zip files under the hood, but the individual files contained in the zip don't make sense on their own. The person who sent it probably made a mistake when they tried to save it as a PDF, and just renamed the file instead ...


16

You can use ImageMagick: display or convert - e.g. to rotate it clockwise use convert -rotate 90 <file>.pdf <rotated-file>.pdf Use -90 for a counterclockwise rotation. N.B. Only use this method when the original image is a bitmap (e.g. produced by scanning). If the original image is not a bitmap, this method will convert it to one and quality ...


Only top voted, non community-wiki answers of a minimum length are eligible