# Create a single pdf from multiple text, images or pdf files

I have a bunch of text files, images and pdf files which I want to convert into a single pdf file. How do I do it?

-
Well, you can do convert image1.jpg image2.png text.txt PDFfile.pdf outputFileName.pdf. It worked for me, but the problem is it converts the text.txt file into an image, so you can't highlight the text in the resulting pdf. – Alaa Ali Jun 4 '13 at 8:46
@Alaa you should post this as an answer rather than a comment. Simple, concise and on the money. – LIttle Ancient Forest Kami Dec 14 '13 at 2:10
gscan2pdf Is a GUI version also in case the command 'convert' fails and worked for me. (from ifoss.com): Once gscan2pdf is opened, you can select all the required files in it by clicking on the Open Files. By default it is arranged in alphabetical order but you can drag and drop to reorder the images as per your choice. then click on the Save icon to save the files to PDF. if you just want a PDF file, hit the save . Since by default the output file is PDF, you don’t need to bother a lot here. Just choose where to save the converted file. Save the converted images to pdf, That’s it. – Bran Sep 8 '14 at 0:05
See also How to generate a PDF from a series of images? on superuser. – zrajm Jan 20 '15 at 12:47

If you're willing to use a terminal, you can do:

convert image1.jpg image2.png text.txt PDFfile.pdf outputFileName.pdf


It worked for me, but the problem is it converts the text.txt file into an image, so you can't highlight the text in the resulting pdf.

(this is @Alaa's comment converted to a Community Wiki answer)

-
ImageMagic convert reduces quality and increases size in my experience. Try pdftk. But not sure how you add images there. – akostadinov Sep 22 '14 at 12:22
You can tweak with -quality flag to increase or decrease the resulting PDF file size. Example: convert -quality 50 image1.jpeg image2.jpeg image3.jpeg outputFileName.pdf – RajaRaviVarma Feb 4 '15 at 18:36
Be aware that convert uses ghostscript under the hood and gs will decode and reencode JPEGs which result in a loss of quality, even if speciiy a high quality. – tobltobs May 4 '15 at 9:28

Install pdftk

sudo apt-get install pdftk


Pdftk

If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a simple tool for doing everyday things with PDF documents.

You can create pdf files from text or images with Libre Office then to stitch these togeter with other pdf files

pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf


It can also

• Split PDF Pages into a New Document

• Rotate PDF Pages or Documents

and a lot more besides

More details here: Ubuntu Geek: List of PDF Editing tools

-
There is a GUI for pdftk. See my answer. – landroni Mar 26 '14 at 9:23
This doesn't work for concatenating images with PDFs though, right? – Garrett May 28 '14 at 21:52
@Garret. No but there are several ways of converting an image to pdf, using covert for example or just print to pdf from many programs. Once the image is a pdf then you can use pdftk to join them together. – Warren Hill May 29 '14 at 7:22
Works like a charm and keeps the vectorial text in pdf. – conualfy Jan 10 at 22:32

Try PDF Chain:

PDF Chain is a graphical user interface for the PDF Toolkit (PDFtk). The GUI supports all common features of the command line tool in a comfortable way.

You can install it either from the default repos, or get the latest and greatest from PDF Chain PPA.

sudo apt-get install pdfchain


Or PDF Mod:

PDF Mod is a simple application for modifying PDF documents.

You can reorder, rotate, and remove pages, export images from a document, edit the title, subject, author, and keywords, and combine documents via drag and drop.

sudo apt-get install pdfmod


-
But can this concatenate text files, images and PDF files, as in the question? – Garrett May 28 '14 at 21:35
You can convert the text files (say, Print to PDF) or the images (via convert) to PDF, and then use that. – landroni May 29 '14 at 4:53
@Garrett - just tried PDF Chain and it works to concatenate pdf files. – conualfy Jan 10 at 22:37

Install Master PDF editor. The tool offers creating, merging and extracting PDF files. Check here for details about master PDF editor and installing it on Ubuntu

-
Master PDF Editor is not free. – Force Nov 18 '13 at 9:20
@Force From their site: The Linux-based version is free for non-commercial use. – janot Mar 19 '15 at 13:59

I use PDF-Shuffler for this kind of use, it works great.

sudo apt-get install pdfshuffler


It is a graphical tool. You simply load all the pdf files you want to fuse. You can change the page order as you wish.

-
Can you include instructions on how to do what the OP wants? – Seth Jan 6 '14 at 4:12
It is done. :-) – cochisebt Jan 6 '14 at 4:24
I would downvote, but have not enough rep. PDF-Shuffler accepts only PDF files. Question also included image files and text files. – borisdiakur Jan 31 '14 at 12:17
With Libreoffice you can convert text files to pdf. As it is also possible to insert image files in Libreoffice, then convert in pdf. Once everything is in pdf, Pdf-Shuffler can do the job. But I don't think one software can do all the job at once. – cochisebt Jan 31 '14 at 15:24

I can't believe nobody has mentioned latex (tex) yet. It is specifically designed for producing documents, and can combine text, images, and PDFs into a 'master' document (without any degradation of quality). It is a full suite of libraries and an extensible markup language, basically - it's been around since forever and highly used in the scientific community, still.

Technically, it's a typesetting language.

-

Try LaTeX with pdflatex.

I had never used it before but it took me about 10 minutes to start making .PDFs with it and about 40 minutes to get them customized exactly as I wanted. I included the best formatting guides I found, at the end.

sudo apt-get install pdflatex && sudo apt-get install texlive

Basically you create one .tex file - for example hello.tex - with the LaTeX language, then run pdflatex hello.tex on that file. The basics of the language can be found here: http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/

Here is a barebones example .tex file:

 \documentclass[a4paper,10pt]{article}

\begin{document}

{\footnotesize

}

\end{document}


Optional extra formatting:

To change page size and margins when using pdflatex: \usepackage[pass,paperwidth=148mm,paperheight=210mm,margin=5mm]{geometry}