%----------------------------------------------------------------------------------------
% 'perfectpdf' produce pdf with embedded fonts, hypertext, bookmarks and informations
% by Nicolas Palluat & Guillaume Laurent 
%
% Report bugs and comments to: guillaume.laurent@ens2m.fr
%
%----------------------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{perfectpdf}[2009/09/07]
%----------------------------------------------------------------------------------------
% Declaration of options
%----------------------------------------------------------------------------------------
\newif\iffrenchlang\frenchlangfalse    % english = default language
%
\DeclareOption{english}{\frenchlangfalse}
%
\DeclareOption{french}{\frenchlangtrue}
%
\ProcessOptions
%----------------------------------------------------------------------------------------
% French settings to generate pdf with embedded fonts 
%----------------------------------------------------------------------------------------
\iffrenchlang
	\usepackage[latin1]{inputenc}
	\usepackage[frenchb]{babel}
	\usepackage{ae}
	\usepackage{aecompl}
	\usepackage[cm]{aeguill} 
\fi
%----------------------------------------------------------------------------------------
% Some nice colors for pdf link
%----------------------------------------------------------------------------------------
\usepackage{xcolor}
\definecolor{@purple}{rgb}{0.62,0.12,0.94}
\definecolor{@darkred}{rgb}{0.5,0,0}
\definecolor{@blue}{rgb}{0,0,1}
%----------------------------------------------------------------------------------------
% settings for pdf output
%----------------------------------------------------------------------------------------
\ifx\pdfoutput\undefined
%
   \usepackage[dvips]{graphicx}
%
\else
   \usepackage[pdftex,              
     bookmarks         = true,        % Signets
     bookmarksnumbered = true,        % Signets numérotés
     pdfpagemode       = UseOutlines, % Signets/vignettes fermé à l'ouverture
     pdfstartview      = FitH,        % La page prend toute la largeur
     pdfpagelayout     = SinglePage,  % Vue par page
     colorlinks        = true,        % Liens en couleur
     citecolor         = @purple,     %
     urlcolor          = @blue,       % Couleur des liens externes
     linkcolor         = @darkred,    % Couleur des liens internes
     breaklinks        = true,        %
     pdfborder         = {0 0 0},     % Style de bordure : ici, pas de bordure
     backref           = page         % Renvois dans la bibliographie
     ]{hyperref}                 
   \pdfcompresslevel=9
   \usepackage[pdftex]{graphicx}   
%
\AtBeginDocument{
		\ifx\@author\undefined\def\@author{}\fi
		\ifx\@title\undefined\def\@title{}\fi
		\ifx\@subtitle\undefined\def\@subtitle{}\fi
		\ifx\@keywords\undefined\def\@keywords{}\fi
    \hypersetup{ 
     pdfauthor   = {\@author},%
     pdftitle    = {\@title},%
     pdfsubject  = {\@subtitle},%
     pdfkeywords = {\@keywords},%
     pdfcreator  = {PDFLaTeX},%
     pdfproducer = {PDFLaTeX}}
}
\fi
%----------------------------------------------------------------------------------------

