snipt

Ctrl+h for KB shortcuts

Perl

htacess - force PDF download

1
2
3
4
5
## Force PDF download.
<FilesMatch "\.(pdf|PDF)">
  ForceType application/pdf
  Header set Content-Disposition attachment
</FilesMatch>
https://snipt.net/embed/b19d8abd6d4781b9755e5e04dfcb05bc/
https://snipt.net/raw/b19d8abd6d4781b9755e5e04dfcb05bc/
b19d8abd6d4781b9755e5e04dfcb05bc
perl
Perl
5
2016-09-21T12:22:09
True
False
False
Dec 28, 2012 at 03:18 AM
/api/public/snipt/52456/
htacess-force-pdf-download
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c1">## Force PDF download.</span> </span><span id="L-2"><a name="L-2"></a><span class="o">&lt;</span><span class="n">FilesMatch</span> <span class="s">&quot;\.(pdf|PDF)&quot;</span><span class="o">&gt;</span> </span><span id="L-3"><a name="L-3"></a> <span class="n">ForceType</span> <span class="n">application</span><span class="o">/</span><span class="n">pdf</span> </span><span id="L-4"><a name="L-4"></a> <span class="n">Header</span> <span class="n">set</span> <span class="n">Content</span><span class="o">-</span><span class="n">Disposition</span> <span class="n">attachment</span> </span><span id="L-5"><a name="L-5"></a><span class="sr">&lt;/FilesMatch&gt;</span> </span></pre></div> </td></tr></table>
download, htaccess, pdf

Text only

Reduce weight of pdf files

1
2
3
4
5
6
7
Install the needed packages:

$ sudo apt-get install ghostscript gsfonts

Once it's installed, type:

$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=/home/user/Desktop/Thin.pdf /home/user/Desktop/FAT.pdf
https://snipt.net/embed/c10c965058a0fdce43f79cc975c8c824/
https://snipt.net/raw/c10c965058a0fdce43f79cc975c8c824/
c10c965058a0fdce43f79cc975c8c824
text
Text only
7
2016-09-27T05:22:20
True
False
False
Jul 29, 2013 at 08:44 AM
/api/public/snipt/52295/
reduce-weight-of-pdf-files
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>Install the needed packages: </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>$ sudo apt-get install ghostscript gsfonts </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>Once it&#39;s installed, type: </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a>$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=/home/user/Desktop/Thin.pdf /home/user/Desktop/FAT.pdf </span></pre></div> </td></tr></table>
Debian, Linux, Ubuntu, ghostscript, gs, pdf, reduce

Bash

Cropping pdfs

1
2
3
#Cropping pdf to inner content
#pdfcrop is available from texlive-extra-utils
pdfcrop foo.pdf bar.pdf
https://snipt.net/embed/8c4551c53dd16d13a8f1952296692b3c/
https://snipt.net/raw/8c4551c53dd16d13a8f1952296692b3c/
8c4551c53dd16d13a8f1952296692b3c
bash
Bash
3
2016-09-27T07:57:12
True
False
False
Nov 20, 2012 at 12:13 PM
/api/public/snipt/50516/
cropping-pdfs
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c">#Cropping pdf to inner content</span> </span><span id="L-2"><a name="L-2"></a><span class="c">#pdfcrop is available from texlive-extra-utils</span> </span><span id="L-3"><a name="L-3"></a>pdfcrop foo.pdf bar.pdf </span></pre></div> </td></tr></table>
"crop pdf", bash, crop, pdf, pdfcrop

Text only

Merge PDF files

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf file1.pdf file2.pdf file3.pdf [...] lastfile.pdf
https://snipt.net/embed/34de95a99d306bcc8c980cf3c2b1a62e/
https://snipt.net/raw/34de95a99d306bcc8c980cf3c2b1a62e/
34de95a99d306bcc8c980cf3c2b1a62e
text
Text only
1
2016-09-26T18:22:36
True
False
False
/api/public/snipt/46151/
merge-pdf-files-1
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf file1.pdf file2.pdf file3.pdf [...] lastfile.pdf </span></pre></div> </td></tr></table>
pdf
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.