Tuesday, November 12, 2013

How to create PDF document from doxygen

How to create PDF documentation with Doxygen/MiKTeX automatically
Let us suppose you need to make API Reference Guide with Doxygen as a PDF file.

You can do it in several steps:

1. Your development environment should have make tool.
Cygwin is a good one
2. Download distributives for the following software:

Doxygen - http://www.stack.nl/~dimitri/doxygen/
ghostscript http://pages.cs.wisc.edu/~ghost/
Miktex http://www.miktex.org/
or much active TeX Live
TeX Live 2013 is available over the Internet and on DVD. It was released on 18 June 2013
http://www.tug.org/texlive/
http://www.tug.org/texlive/acquire-netinstall.html

Graphviz http://www.graphviz.org/ - optionally

3. Install Doxygen. Now you are able to create a configuration file for your doxy-documentation. Use Doxywizard for that purpose: File -> Save as...

#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = YES
LATEX_OUTPUT = doxygen/latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = letter
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = YES





4. Install Ghostscript.

4.1 http://www.ghostscript.com/download/

Add ghostscript installation directory to your PATH environment variable
EG: C:\Program Files\gs\gs9.10\bin

4.2 install Ghostview

5. Install Miktex (note that the release will be discontinued end of 2013).


OR

5. Install TexLive

Windows


download and unzip installation package and run

install-tl-advanced.bat




be patient it takes some time..

or

6. Update Miktex.
a. Pick appropriate shortcut (with Admin access for Win7)


b. Pick the nearest package repository



Once the version of miktex has been updated start the update over. This time you'll be able to select all packages



When Doxygen is finished processing, in the latex directory there's a file called 'refman.tex'.
There are three ways you can use that file to get 'a book' out of Doxygen:
·         LaTeX -> dvips -> ps2pdf
latex myfile
dvips myfile
ps2pdf myfile.ps
·         LaTeX -> dvipdfm
latex myfile
dvipdfm myfile
·         pdflatex (or pdftex for plain TeX)

pdflatex myfile

On Ubuntu

Install LaTeX in Ubuntu
Note Updated to work with Ubuntu 10.04 and TeXLive 2009-7
TeX Live 2013 is available over the Internet and on DVD. It was released on 18 June 2013

Installing LaTeX in Ubuntu is actually quite straightforward,
but this guide is a good entry point for other LaTeX tips.
I assume that Ubuntu is already installed on the target machine.
Make sure that Ubuntu is fully updated by running the Update Manager from the System→Administration menu.
Install LaTeX by entering the following in a Terminal.
you can install the full distribution; it has the advantage that you most likely don't have to install any packages afterwards, but at the
cost of disk space - it installs more than a gigabyte of fetish rubber packages including language packages that you will probably never need. You may need to enter your
password to execute the command.
$> sudo apt-get install texlive-full

or


Alternatively you can select to install a complete distribution that only includes the language packages you need by specifying each package to install
$> sudo apt-get install texlive-base
$> sudo apt-get install texlive-binaries
$> sudo apt-get install texlive-common
$> sudo apt-get install texlive-latex-base
$> sudo apt-get install texlive-publishers
$> sudo apt-get install texlive-music
$> sudo apt-get install texlive-latex3
$> sudo apt-get install texlive-generic-recommended
$> sudo apt-get install texlive-omega
$> sudo apt-get install texlive-font-utils
$> sudo apt-get install texlive-plain-extra
$> sudo apt-get install texlive-formats-extra
$> sudo apt-get install texlive-games
$> sudo apt-get install texlive-metapost
$> sudo apt-get install texlive-generic-extra
$> sudo apt-get install texlive-pictures
$> sudo apt-get install texlive-math-extra
$> sudo apt-get install texlive-extra-utils
$> sudo apt-get install texlive-latex-recommended
$> sudo apt-get install texlive-bibtex-extra
$> sudo apt-get install texlive-humanities
$> sudo apt-get install texlive-fonts-recommended
$> sudo apt-get install texlive-pstricks
$> sudo apt-get install texlive-science
$> sudo apt-get install texlive-fonts-extra-doc
$> sudo apt-get install texlive-latex-base-doc
$> sudo apt-get install texlive-doc-base
$> sudo apt-get install texlive-latex-recommended-doc
$> sudo apt-get install texlive-humanities-doc
$> sudo apt-get install texlive-pstricks-doc
$> sudo apt-get install texlive-science-doc
$> sudo apt-get install texlive-metapost-doc
$> sudo apt-get install texlive-pictures-doc
$> sudo apt-get install texlive-latex-extra-doc
$> sudo apt-get install texlive-publishers-doc
$> sudo apt-get install texlive-fonts-recommended-doc
$> sudo apt-get install texlive-doc-en
$> sudo apt-get install texlive-lang-danish
$> sudo apt-get install texlive-lang-ukenglish
$> sudo apt-get install texlive-lang-german
$> sudo apt-get install texlive-lang-french
$> sudo apt-get install texlive-lang-greek
$> sudo apt-get install feynmf
$> sudo apt-get install tex4ht
$> sudo apt-get install tex4ht-common
$> sudo apt-get install texinfo tex-common
$> sudo apt-get install libkpathsea5
$> sudo apt-get install libkpathsea-dev
$> sudo apt-get install pgf
$> sudo apt-get install dvipng
$> sudo apt-get install latex-xft-fonts
$> sudo apt-get install xfonts-mathml
$> sudo apt-get install musixtex
$> sudo apt-get install musixlyr
$> sudo apt-get install latex-sanskrit
$> sudo apt-get install latex-xcolor
$> sudo apt-get install lacheck ps2eps
$> sudo apt-get install latex-beamer
$> sudo apt-get install cm-super
$> sudo apt-get install cm-super-minimal
$> sudo apt-get install context
$> sudo apt-get install musixtex-slurps
$> sudo apt-get install preview-latex-style
$> sudo apt-get install prosper
$> sudo apt-get install tipa
$> sudo apt-get install lmodern
$> sudo apt-get install lcdf-typetools


Note that the above installs language packages for Danish, Greek, German and French (English is part of the standard distribution and is always installed).
Now you have a full working LaTeX distribution installed and you can compile your LaTeX document by running
$> pdflatex filename.tex

That is actually how simple it is. I recommend to use either gedit (part of Ubuntu installation) or Eclipse (can be installed using the Synaptics Package Manager or apt-get) to write LaTeX documents, but
you can use whichever plain text editor you prefer.

7. Install Graphviz (optionally)
8. Create makefile with complete scenario.

####################################################################
#
# This is makefile for doxygen documentation.
#
####################################################################

include ./rules

ifeq ($(HOST_OS),WIN)
all:
cd $(PROJECT_PATH)/doc; \
$(DOXYGEN_PATH)/doxygen Doxyfile > doxylog.log; \
cp $(PROJECT_PATH)/doc/conf/Makefile $(PROJECT_PATH)/doc/latex/Makefile; \
cp $(PROJECT_PATH)/doc/conf/pdflatex.input $(PROJECT_PATH)/doc/latex/pdflatex.input; \
cd $(PROJECT_PATH)/doc/latex; \
$(DOXYGEN_MAKE_PATH)/make; \
$(RM) refman.pdf; \
$(DOXYGEN_MAKE_PATH)/make; \
cp $(PROJECT_PATH)/doc/latex/refman.pdf $(PROJECT_PATH)/doc/$(DOCNAME).pdf

clean:
$(RM) $(PROJECT_PATH)/doc/html/*.*; \
$(RM) $(PROJECT_PATH)/doc/latex/*.*
endif


$(DOXYGEN_PATH)/doxygen is the path to the doxygen.exe file,
Doxyfile is the name of your doxy-configuration file,
doxylog.log is the output file to analyze warnings and errors,
pdflatex.input is the helpful file with an answer to all questions. Just letter r. This answer helps you avoid manually typing using a keyboard.

r

$(PROJECT_PATH)/doc/conf/Makefile is the additional makefile especially to create manual.pdf file

With the TexLive package the following Makefile will be autognerated

all: clean refman.dvi

ps: refman.ps

pdf: refman.pdf

ps_2on1: refman_2on1.ps

pdf_2on1: refman_2on1.pdf

refman.ps: refman.dvi
dvips -o refman.ps refman.dvi

refman.pdf: refman.ps
gswin32c -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=refman.pdf -c save pop -f refman.ps

refman.dvi: refman.tex doxygen.sty
echo "Running latex..."
latex refman.tex
echo "Running makeindex..."
makeindex refman.idx
echo "Rerunning latex...."
latex refman.tex
latex_count=5 ; \
while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\
do \
echo "Rerunning latex...." ;\
latex refman.tex ;\
latex_count=`expr $$latex_count - 1` ;\
done

refman_2on1.ps: refman.ps
psnup -2 refman.ps >refman_2on1.ps

refman_2on1.pdf: refman_2on1.ps
gswin32c -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=refman_2on1.pdf -c save pop -f refman_2on1.ps

clean:
rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out refman.pdf


and the last hint is using double building due to well known bug with page indexes
$(DOXYGEN_MAKE_PATH)/make; \
$(RM) manual.pdf; \
$(DOXYGEN_MAKE_PATH)/make; \


simply typing make doc in the root project's directory.

at the end of make all inside the latex sub folder you should see

(see the transcript file for additional information)
Output written on refman.dvi (1873 pages, 6754516 bytes).
Transcript written on refman.log.

No comments: