Skip to content

Instantly share code, notes, and snippets.

@ppanyukov
Created June 20, 2011 12:30
Show Gist options
  • Save ppanyukov/1035536 to your computer and use it in GitHub Desktop.
Save ppanyukov/1035536 to your computer and use it in GitHub Desktop.
Combine several PDF files into one using LaTeX
% Many a time we have HTML articles published across multiple pages.
% And sometimes we want to print all those pages as one PDF.
% Here is how to do it:
% - Print into PDF from the browser into files like p01.pdf, p02.pdf etc
% - Use LaTeX to assemble these into one PDF.
%
% Here is the example. The \includepdf command supports scaling too,
% and I'm sure some other interesting commands as well.
%
% [copylifted from: http://yusung.blogspot.com/2007/02/combine-several-pdf-files-using-latex.html]
% thanks!
%
\documentclass[a4paper]{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-, scale=0.9]{p01.pdf}
\includepdf[pages=-, scale=0.9]{p02.pdf}
\includepdf[pages=-, scale=0.9]{p03.pdf}
\includepdf[pages=-, scale=0.9]{p04.pdf}
\end{document}
@sant527
Copy link

sant527 commented Sep 15, 2020

The drawback here is if the pdf contains pages with different sizes then it will not consider that

@ruzito
Copy link

ruzito commented Jun 26, 2021

use this then:

% this sets global options for each \includepdf call
% (altho only options specific to pdfpages package can be made global by \includepdfset.)
\includepdfset{pages=-,fitpaper}
% include each document
\includepdf{p01.pdf}
\includepdf{p02.pdf}
% you could add document specific options as well i did here
\includepdf[pages=5-]{p03.pdf}
\includepdf{p04.pdf}
% reset default global settings
\includepdfset{}

@ruzito
Copy link

ruzito commented Jun 26, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment