# Link bookmark to top of a page

I assign pdf bookmarks manually in my document, because I do not use any sections or similar stuff, but only put together other pdf files.

My problem is that the bookmarks do not link to the top of the regarding page, but a few cm below, where the content of that page starts. This is a little bit annoying and I would like to change that. Is there a way to link directly to the upper end of a page?

\documentclass[11pt,a4paper,sans]{article}

\usepackage[utf8]{inputenc}
\usepackage[top=2.5cm,bottom=2.5cm,left=3cm,right=3cm]{geometry}
\usepackage{pdfpages}
\usepackage{hyperref}
\usepackage{bookmark}
\hypersetup{
bookmarks=true,
pdftitle={FusedPDF},
}

\begin{document}

\pdfbookmark{\contentsname}{PDF1}
\includepdf[pages=-]{PDF1.pdf}

\pdfbookmark{\contentsname}{PDF2}
\includepdf[pages=-]{PDF2.pdf}

\end{document}


// Edit: OK, what I did now is to manually set the bookmarks with BeCyPDFMetaEdit. There it is no problem to link to the top of the page. But that is not exactly the way I imagined in the first place.

You can raise the destination. But you must do it with the pagecommand key of \includepdf to avoid to get a blank page (the values are from your geometry setting, but one could calculate them):

\documentclass[11pt,a4paper,sans]{article}

\usepackage[utf8]{inputenc}
\usepackage[top=2.5cm,bottom=2.5cm,left=3cm,right=3cm]{geometry}
\usepackage{pdfpages}
\usepackage{hyperref}
\usepackage{bookmark}
\hypersetup{
bookmarks=true,
pdftitle={FusedPDF},
}

\begin{document}

\includepdf[pages=1,pagecommand={\hspace*{-3cm}\raisebox{\dimexpr 2.5cm+\topskip}[0pt][0pt]{\pdfbookmark{\contentsname}{PDF1}}}]{example-image-duck.pdf}

\includepdf[pages=2-20]{example-image-duck.pdf}

\end{document}


An alternative is to set the margins to 0 before the \includepdf:

\documentclass[11pt,a4paper,sans]{article}

\usepackage[utf8]{inputenc}
\usepackage[top=2.5cm,bottom=2.5cm,left=3cm,right=3cm]{geometry}
\usepackage{pdfpages}
\usepackage{hyperref}
\usepackage{bookmark}
\hypersetup{
bookmarks=true,
pdftitle={FusedPDF},
}

\begin{document}
blblb

\newgeometry{margin=0pt}
\pdfbookmark{\contentsname}{PDF1}
\includepdf[pages=1-10]{example-image-duck.pdf}

\pdfbookmark{\contentsname}{PDF2}
\includepdf[pages=1-10]{example-image-duck.pdf}

\restoregeometry bbbb
\end{document}

• Ha, ok that would be a solution, although it seems quite unflexible. Is there no way to simply create a link directly to the top of a page...? – jusaca Apr 5 at 15:21
• I added a second suggestion. – Ulrike Fischer Apr 5 at 15:32