====== Resume Using LaTeX and PHP ======
Beeing actively searching for a new Job, I needed to distribute muy resume in an easy way.
Keeping my resume up to date proved to be a hassle, and formatting in Microsoft Word was never as good as I wished. Moreover, any simple update caused the formatting to span multiple pages, or simply look bad.
This is when I finally turned to LaTeX to format and distribute my wiki.
The goal is to have a nice looking resume that can :
* be translated to english and french
* have a public and a private version (private beeing when I ask for a job, public will be posted on the internet)
* be automatically updated with the latest dates as time goes by.
For this, I wrote and formatted my resume in LaTeX (see below or the latex source code), including some basic time-counting functions and translations.
Now, when I want to distribute it, I have to compile the latex to re-calculate everything...
Informatitians are lazy people, so instead of compiling it by hand every time I wanted to send it out, I wrote some php to compile the resume on the spot each time someone wants to download it.
The resume is now accessible for demo at the following address :
* [[http://resume.emolinier.com/?lang=en&public=true|english resume]]
* [[http://resume.emolinier.com/?lang=fr&public=true|french resume]]
Of course, 2 other urls will generate the resume including my private contact informations, but I will not disclose these urls on this public wiki...
You will find below the LaTeX source code as well as the current php script to call the latex compiler.
I am in the process of adding the following functionalities :
* move to https to add encryption of the resume when in transfer over the internet
* include a token-based security to compile the resume with my private contact informations
* add several versions of my resume to deliver to different persons.
===== LaTeX =====
Here is the LaTeX code used to compile my resume :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINE THE LANGUAGE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% You might need to remove this part to generate it using PHP later on.
\newif\ifenglish
%\englishtrue % Show English text only
\englishfalse % will show French text only
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINE THE VISIBILITY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% if you want to display your private informations, comment the following line.
\def\ispublic{1}
% you might need to comment it out if you want to handle this with PHP later on.
\documentclass[11pt,a4paper]{article}
\title{Curriculum vit\ae}
\author{Etienne Molinier}
\date{Novembre 2015}
%% Standard packages
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage[english]{babel}
\usepackage[bindingoffset=1cm,centering,includeheadfoot,margin=1cm]{geometry}
\usepackage{ifthen}
%\usepackage{blindtext}
%\usepackage{txfonts}
% Change spacing of dections and subsections
\usepackage{titlesec}
%\titlespacing{command}{left spacing}{before spacing}{after spacing}[right]
\titlespacing\section{0pt}{12pt plus 4pt minus 4pt}{5pt plus 2pt minus 3pt}
\titlespacing\subsection{10pt}{10pt plus 2pt minus 4pt}{0pt plus 2pt minus 2pt}
% Change the page margins
\addtolength{\oddsidemargin}{-.3in}
\addtolength{\evensidemargin}{-.3in}
\addtolength{\textwidth}{0.0in}
\addtolength{\topmargin}{-.4in}
\addtolength{\textheight}{0.9in}
%\setlength{\textheight}{9.5in} % increase text height to fit on 1-page
%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINE YOUR ADDRESS HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set coordinates depending on public or not
% You can run this command to obtain the public version :
% pdflatex "\def\ispublic{1} \input\{resume.tex}"
\ifdefined\ispublic
\def \email {webmaster@emolinier.com}
\def \address {Region Rh\^{o}ne-Alpes Auvergne}
\def \telephone {http://wiki.emolinier.com/etienne\textunderscore molinier}
\else
\def \email {here goes your private @email}
\def \address {here goes your private postal address}
\def \telephone {Tel : here goes your private phone number}
\fi
%%%%%%%%%%%%%%%%%%%%%%%%% CALCULATE THE AGE OF THE PERSON %%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{MyAge}
\setcounter{MyAge}{\the\year}
\addtocounter{MyAge}{-PutYourYearOfBirthHere}
\ifthenelse{\the\month
===== PHP =====
At first, I used a remote API to have the LaTeX sources compiled by a third party (this saved me some time first).
Then, I was growing more and more uneasy to use a third party service (what about downtimes, confidentiality, ...).
So I moved on and installed a LaTeX compiler on my NAS and wrote the php code to compile my files locally.
==== Compile locally ====
You first need to install LaTeX on the webserver, if like me you have an exotic architecture for your NAS hardware, you can follow this guide : [[synology:install_latex_on_a_synology_nas| Install LaTeX on a Synology NAS]]
Once LaTeX is installed, here is the php file I used to call the compiler on-demand:
==== Call a remote API to compile LaTeX files ====
The Idea is to call a remote API to compile the latex file on the spot.
Also, we add a few settings to the latex file.
"value") ==> index.php?param=value
function CallAPI($method, $url, $data = false){
$curl = curl_init();
switch ($method){
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($curl, CURLOPT_PUT, 1);
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
// Optional Authentication:
//curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
//curl_setopt($curl, CURLOPT_USERPWD, "username:password");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
// Default options :
$lang="fr";
$public=true;
$outputname="CV-MOLINIER_Etienne";
$outputsuffix="";
$outputextension=".pdf";
// Parse options provided by client
if ( array_key_exists("privateinformationoutput",$_GET) && $_GET["privateinformationoutput"]=="true") {
$public=false;
} else {
$outputsuffix="_public";
}
if ( array_key_exists("lang",$_GET) && $_GET["lang"]=="en") {
$lang="en";
$outputname="Resume MOLINIER Etienne";
}
if ( array_key_exists("lang",$_GET) && $_GET["lang"]=="fr") {
$lang="fr";
$outputname="CV MOLINIER Etienne";
}
// load the latex code
$tex=file_get_contents("resume.tex");
// check if we are allowed to print private informations
if ($public) {
// add the latex variable to display only public informations
$tex="\def\ispublic{1}\n".$tex;
}
if ($lang=="en") {
$tex="\\newif\ifenglish\n\\englishtrue".$tex;
} else {
$tex="\\newif\ifenglish\n\\englishfalse".$tex;
}
// prepare the data for the query
$data =array(
"pole"=>$tex,
"pdf"=>"PDF",
"preklad"=>"latex",
"pruchod"=>"1",
".cgifields"=>"komprim"
);
// and call the API
$result = CallApi("POST","https://tex.mendelu.cz/en/",$data);
//return the file.
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"" . ($outputname.$outputsuffix.$outputextension) . "\"");
//readfile($file_url); // do the double-download-dance (dirty but worky)
echo $result;
?>