3

I am working with the organization staff of a congress and we have to print a lot of certificates of participation. All these certificates have te same text, except for the name of the participant. I have one certificate already done, but in order to avoid making one-by-one by hand, I was wondering if there is any way of doing this dinamically in Tex, using a *.xls file (in wich we have all the name of the participants) as a database.

Has anybody done something like this and can give me any clue on where to start?

Thanks for all the members!

matgaio
  • 145

1 Answers1

6

Grab or make a blank or partly filled certificate, such as https://images.template.net/wp-content/uploads/2015/03/Free-Blank-Certificate-Template.jpg.

Create a name file (can be exported from the xls file as a csv), read it and use it to loop through the names.

Note the {c}{}{c}{} parameters in \stackinset define the precise location of the name overlay---here, literally, in the center of the page. That can be adjusted. For example, {l}{50pt}{b}{100pt} would mean 50 pt from the left and 100pt from the bottom of the image.

\documentclass{article}
\usepackage[letterpaper,landscape,margin=0pt]{geometry}
\usepackage{filecontents,stackengine,graphicx,readarray}
\begin{filecontents*}{names.txt}
Joe Smith
Jane Doe
\end{filecontents*}
\ignoreemptyitems
\readarraysepchar{,}
\parindent 0pt
\begin{document}
\readdef{names.txt}\namelistdef
\readlist\thenamelist{\namelistdef}
\foreachitem\x\in\thenamelist{%
  \stackinset{c}{}{c}{}{\sffamily\Large\x}{%
    \includegraphics[width=\textwidth]{Free-Blank-Certificate-Template.jpg}}%
  \clearpage%
}
\end{document}

enter image description here

One can get sophisticated and enter multiple fields, using a csv input format for the data.

Poor Jane...just wait until her Mom finds out!

\documentclass{article}
\usepackage[letterpaper,landscape,margin=0pt]{geometry}
\usepackage{filecontents,stackengine,graphicx,readarray}
\begin{filecontents*}{names.txt}
Joe Smith, 3-legged race
Jane Doe, chug-a-lug
\end{filecontents*}
\ignoreemptyitems
\readarraysepchar{\\}
\setsepchar{\\/,}
\parindent 0pt
\begin{document}
\readdef{names.txt}\namelistdef
\readlist\thenamelist{\namelistdef}
\foreachitem\x\in\thenamelist{%
  \stackinset{c}{-75pt}{c}{-30pt}{\sffamily\Large\thenamelist[\xcnt,2]}{%
  \stackinset{c}{}{c}{}{\sffamily\Large\thenamelist[\xcnt,1]}{%
    \includegraphics[width=\textwidth]{Free-Blank-Certificate-Template.jpg}%
  }}%
  \clearpage%
}
\end{document}

enter image description here

  • 3
    Neat, may be worth mentioning that xls columns can be very easily exported in the correct format as .csv rather than .txt –  Apr 30 '19 at 21:52
  • 1
    Amazing solution! Thank you very much! I think it it possible to adapt this solution to the case when the certificate is not an image, but a bunch of plain text, and the added text from the cvs can be placed inside a sentence, like "This is to certify that participated...", right? – matgaio May 01 '19 at 18:25
  • 1
    @matgaio This approach can be used as you hypothesize if the "text" used to create the underlying certificate is placed inside a LaTeX box (e.g., \parbox, \hbox, etc.) – Steven B. Segletes May 01 '19 at 18:32
  • 1
    @matgaio I should clarify...there is no actual requirement on the part of \stackinset that its final argument be a LaTeX box. But if not, the argument will just be a string of text, which does not serve the present purpose of being a certificate layout. – Steven B. Segletes May 01 '19 at 19:22
  • 1
    So kind of you to adding these comments. Again, thank you very much!! – matgaio May 01 '19 at 19:29