0

I have a directory named Titlepage where the files(minimum 10 pdf) are titlepage_1.pdf,titlepage_2.pdf,titlepage_3.pdf... . Each are one page pdf.

This directory also hosted in Github so that people can download the title pages easily. The Github directory contains corresponding LaTeX file also.

I want to make a combined pdf using these where each page contain 4 pdfs. And each title page also have their original name. So that anybody can choose a pdf by comparing all in one pdf and then download what title page he needs.

[I guess it can be done using pdfuite. And if not possible using only pdfunite then combining with LaTeX]

enter image description here

or

enter image description here

Edit

enter image description here

1

The order doesn't match yours, but the following puts the specified pages into one pdf (using LaTeX):

\documentclass[twocolumn]{article}

\usepackage{graphicx}

\newcommand\putTitlepage[1]
  {%
    \bgroup
    \fboxsep=-\fboxrule
    \noindent
    \fbox{%
      \includegraphics[width=\columnwidth,height=.4\textheight,keepaspectratio]
        {#1}%
    }\\%
    \texttt{\detokenize{#1}}%
    \egroup
  }

\newcount\myTPcounter

\makeatletter
\newcommand\putTheTitlepages[1]
  {%
    \@for\cs:={#1}\do
      {%
        \expandafter\putTitlepage\expandafter{\cs}%
        \par
      }%
  }
\newcommand\putTitlepagesPattern[4]
  {%
    \myTPcounter=\numexpr#3-1\relax
    \loop\ifnum\myTPcounter<#4
      \advance\myTPcounter by 1
      \typeout{}%
      \typeout{Now processing file}%
      \typeout{\the\myTPcounter}%
      \typeout{}%
      \expandafter\putTitlepagesPattern@i\expandafter{\the\myTPcounter}{#1}{#2}%
      \par
    \repeat
  }
\newcommand\putTitlepagesPattern@i[3]
  {%
    \putTitlepage{#2#1#3}%
  }
\makeatother


\begin{document}
\centering
% if you need to specify their names because they don't match a pattern
\putTheTitlepages{titlepage-1.pdf,titlepage-2.pdf}

\putTitlepagesPattern{titlepage-}{.pdf}{3}{10}
\end{document}

enter image description here

  • It may be better if you use loop for adding the pdf. So, when there are more pdf in that directory they can be added just recompiling the code. – alhelal Mar 16 '18 at 10:01
  • @alhelal it does use a loop for adding the pdfs. But it doesn't check whether the pdfs it tries to include exist. If you want to include more pdfs, change the arguments of \putTitlepagesPattern. The last two arguments specify the range in which the included pdf-names are. – Skillmon Mar 16 '18 at 10:13
  • I used your solution long times ago. Now, I am trying to use but failed. !pdfTeX error: pdflatex (file ./titlepage_1.pdf): reading image file failed ==> Fatal error occurred, no output PDF file produced! alhelal@VimLaTeX:~/test$ ls combinepdf.aux titlepage_1.pdf titlepage_2.tex titlepage_4.pdf titlepage_5.tex combinepdf.log titlepage_1.tex titlepage_3.pdf titlepage_4.tex titlepage_6.pdf combinepdf.tex titlepage_2.pdf titlepage_3.tex titlepage_5.pdf titlepage_6.tex alhelal@VimLaTeX:~/test$ – alhelal Oct 7 '18 at 9:30
  • error message paste.ubuntu.com/p/STkrv44jdN – alhelal Oct 7 '18 at 9:32
  • @alhelal from the snippet of the output you provide it seems like the file titlepage_1.pdf is corrupted in some way. Can you open it separately in a PDF viewer and check whether that one does output any strange messages (so invoke it from Terminal to see whether it complains). If you still have the sources for that file, can you try to recreate it and then again try to include it? – Skillmon Oct 7 '18 at 11:04
0
\documentclass{scrartcl}
\usepackage{expl3,graphicx,url}
\newcommand\addpage[1]{%
  \parbox{\dimexpr.5\linewidth}{%
      \centering%
      \fbox{\includegraphics[width=0.9\linewidth]{#1}}\\%
      \path{#1}%
  }%
  \penalty0\relax
}
\lineskip=0pt plus 1fil
\begin{document}
\noindent
\ExplSyntaxOn
\int_step_inline:nnnn{1}{1}{100}{
  \file_if_exist:nT{titlepage_#1.pdf}{
    \addpage{titlepage_#1.pdf}
  }
}
\ExplSyntaxOff
\end{document}

This works exact my requirement. I got this code in my laptop. This is actually not my own code. I collected this from someone in the online, but I can't remember. Thank you, the anonymous helper.

  • Bear in mind that this "enlarges" the pages, meaning that the borders drawn around your pages are wider than the physical pages are. Also there is an unnecessary \dimexpr in the argument of \parbox. – Skillmon Oct 7 '18 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.