2

What would be the fastest way to have JPEG pictures into a PDF document?

I consider include graphics. Ideally, it would be great if a package could read the file content of a given directory, and create a list of JPEG files, and then use method to produce the pdf (fullwidth, one JPEG per page).

Best regards,

linux5962
  • 175
  • 8
  • 1
    I think \includegraphics is your friend here. Do a Google search to find a way of expanding a picture along the page and for futher information. – manooooh Jun 06 '19 at 05:17
  • 2
    Use \includepdf{NameOfJpeg} to get a full page of the image. – Johannes_B Jun 06 '19 at 05:22

1 Answers1

4

You can do this. Requires -shell-escape in order to get a file list.

\documentclass{article}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{xurl}
\usepackage{xparse}

\ExplSyntaxOn

\NewDocumentCommand{\processdir}{O{ls~-m~}mm+m}
 {% #1 = shell command, #2 = directory, #3 = pattern, #4 = template for processing
  \cs_set_protected:Nn \__linuxn_process:n { #4 }
  \sys_shell_get:nnN { #1 #2/#3 } { } \l__linuxn_process_tl
  \clist_set:NV \l__linuxn_process_clist \l__linuxn_process_tl
  \clist_map_function:NN \l__linuxn_process_clist \__linuxn_process:n
 }

\tl_new:N \l__linuxn_process_tl
\clist_new:N \l__linuxn_process_clist
\cs_new_protected:Nn \__linuxn_process:n {}

\ExplSyntaxOff

\begin{document}

\processdir{/usr/local/texlive/2019/texmf-dist/tex/latex/mwe}{*.jpg}{%
  \clearpage
  \noindent\parbox[c][\textheight]{\textwidth}{%
    {\centering\includegraphics[max width=\textwidth]{#1}\par}
    \bigskip
    \path{#1}
  }
  \clearpage
}

\end{document}

The leading optional argument is for the flavor of ls you need: on Unix systems ls -m returns the file list with items separated by commas; adapt it for other systems.

enter image description here

egreg
  • 1,121,712