XeTeXGenerating small business cards

Information and discussion about XeTeX, an alternative for pdfTeX based on e-Tex
Post Reply
bartzmc
Posts: 10
Joined: Thu Apr 06, 2017 9:15 pm

Generating small business cards

Post by bartzmc »

Based on https://www.overleaf.com/latex/examples ... nhcjvkvcfd

I'm trying to implement a project that would generate small business cards based on a csv file.
I created a code similar to here:

https://tex.stackexchange.com/questions ... s-in-latex

That is, compiling one business card to the first.pdf file, and for the next compilation inserting it into the second page so that you can cut them according to the pattern. It's a two step process. I want these small business cards to be generated straight away from the file. I want to achive only second side of my file and in addition not only one person's business card but one by one each line from the file. But not necessarily, I care more about small business cards, it can be one person's data.

Image

Data.csv looks like:

Code: Select all

Name,Subtitle,Division,Employer,JobTitle,Speciality1,Speciality2,Speciality3,Web,Email1,Email2,Mobile,GPG
{Helena Doe},subtitle,Division,Employer,Job Title,Speciality 1,Speciality 2,Speciality 3,https://fqdn/,helena@univ.edu,hxr42@gmail.com,+1 123 456 7890,425B 030A B8D2 0316 CA1B 4709 CA83 5DDA EC31 CA56
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Image

My code:

Code: Select all

Code, edit and compile here:
\documentclass[11pt,a4paper]{article}
\setstocksize{55mm}{85mm} % UK Stock size
\setpagecc{55mm}{85mm}{*}
\settypeblocksize{45mm}{75mm}{*}
\setulmargins{5mm}{*}{*}
\setlrmargins{5mm}{*}{*}
\usepackage{xcolor}
\usepackage{datatool}
\DTLloaddb{namelist}{data.csv}
\setheadfoot{0.1pt}{0.1pt}
\setheaderspaces{1pt}{*}{*}
\checkandfixthelayout[fixed]
\pagestyle{empty}
\usepackage{pstricks}
\usepackage{auto-pst-pdf,pst-barcode}
%% These packages only for typesetting the instructions
\usepackage{listings}
\usepackage{enumitem}
\usepackage{stackengine}
\usepackage{graphicx}
\newlength\plusheight
\newlength\stackvgap
\def\myvgap{1ex}
\def\myhgap{1ex}
\def\myimg{\protect\includegraphics[scale=1.0]{first}}
\def\myimgwd{\widthof{\myimg}-\widthof{+}}
\def\imgline{\myimg\protect\hspace{\myhgap}\myimg}
\def\seperatorline{+\protect\rule{\myimgwd+\myhgap}{0pt}+\protect\rule{\myimgwd+\myhgap}{0pt}+}
\setlength\plusheight{\heightof{+}}
\addtolength\plusheight{\depthof{+}}
\setlength\stackvgap{\myvgap-\the\plusheight}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Last edited by bartzmc on Sun Mar 03, 2019 12:20 pm, edited 4 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Generating small business cards

Post by rais »

You could try putting the card in a box, say

Code: Select all

Code, edit and compile here:
\documentclass[11pt,a4paper]{article}
\usepackage{xcolor}
\usepackage{filecontents}
\begin{filecontents*}{\jobname-dat.csv}
Name,Subtitle,Division,Employer,JobTitle,Speciality1,Speciality2,Speciality3,Web,Email1,Email2,Mobile,GPG
{Helena Doe},subtitle,Division,Employer,Job Title,Speciality 1,Speciality 2,Speciality 3,https://fqdn/,helena@univ.edu,hxr42@gmail.com,+1 123 456 7890,425B 030A B8D2 0316 CA1B 4709 CA83 5DDA EC31 CA56
{Jane Doe},subtitle,Division,Employer,Job Title,Speciality 1,Speciality 2,Speciality 3,https://fqdn/,jane@univ.edu,hxr42@gmail.com,+1 123 456 7890,425B 030A B8D2 0316 CA1B 4709 CA83 5DDA EC31 CA56
\end{filecontents*}
\usepackage{datatool}
\usepackage[left=1cm, right=1cm, top=1cm, bottom=1cm]{geometry}
\DTLloaddb{namelist}{\jobname-dat.csv}
\usepackage{fontspec}
\setmainfont{Universalis ADF Std}
\pagestyle{empty}
\usepackage{pstricks}
\usepackage{auto-pst-pdf,pst-barcode}
\newsavebox\currbizcard
\pagestyle{empty}
\usepackage{scrextend}
\newlength\xbetweencards
\newlength\ybetweencards
\setlength\xbetweencards{24pt}
\setlength\ybetweencards{24pt}
\begin{document}
%% For each line in namelist (which was loaded from \jobname-dat.csv),
%% output the following text (with mailmerged field values)
\DTLforeach*{namelist}{% Map each column header in your .csv file to a command
\Name=Name, \Subtitle=Subtitle, \Division=Division, \Employer=Employer,%
\JobTitle=JobTitle, \SpecialityOne=Speciality1, \SpecialityTwo=Speciality2, \SpecialityThree=Speciality3,%
\Web=Web, \EmailOne=Email1, \EmailTwo=Email2, \Mobile=Mobile, \GPG=GPG%
}{%
\sbox\currbizcard{%
\begin{minipage}{74mm}%
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I may have thrown out a bit too much from the code, but hey...
The font you used I don't have on this machine, I opted for a font that ships with TL'18 instead.(that's not part of my
suggestion)
I renamed the csv file, because the filecontents package lets the filecontents environment overwrite any existing file with the filename given to this environment (to be able to make changes from within the .tex file)---in short, I didn't want to overwrite your data.csv by accident;-)

KR
Rainer
bartzmc
Posts: 10
Joined: Thu Apr 06, 2017 9:15 pm

Generating small business cards based on a csv file

Post by bartzmc »

Thank you for this solution.
victorpatrick123
Posts: 1
Joined: Wed Dec 11, 2019 11:53 am

Generating small business cards

Post by victorpatrick123 »

This is very useful.
Post Reply