In this post, I will show how do I include a PDF file in my Doxygen’s documentation.

In some projects I might need to add some extra documentation, like a PDF, or a custom page in HTML (this will be discussed in another post). I will show you my way of implementing a PDF in my doxygen, and how the viewer could be improved so it is good implemented.

I first specify in doxywizard the location of my PDF file in the HTML_EXTRA_FILES.

In my souce code, in a doxgen comment, I include the following lines:

@htmlonly
<embed src="file_name.pdf#toolbar=0&navpanes=0&scrollbar=0" width="100%" height="700" type="application/pdf"></embed>
@endhtmlonly 

The @htmlonly[…]@endhtmlonly allows me to include HTML code in the doxygen comment. See htmlonly command in the doxygen’s official documentation.

Then I use the embed tag to include my file. The #toolbar=0&navpanes=0&scrollbar=0 hides the toolbar and the navigation panel, in order to have a frameless PDF viewer. It gives a better implementation in the documentation, but it can be removed if you want to keep the toolbox to avoid any confusion. The tag can also be replace with iframe:

@htmlonly
<iframe src="file_name.pdf#toolbar=0&navpanes=0&scrollbar=0" width="100%" height="700" type="application/pdf"></iframe>
@endhtmlonly 

I noticed if I set a height of 100%, the frame is really small. I give then an arbitrary height, e.g. 700 pixels, to have a not too small frame.