Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I had to produce a pdf report at work this week. The report was written in MS Word, and the covers produced in some vector graphics software. Both Word and the SVG software are able to create pdf files, but how to merge them together?

I usually use pdfarranger for adding/removing pages of pdfs. It’s a neat little tool, but it turns out it does not preserve bookmarks in the pdf – these are crucial for accessibility. My colleague and I tried a few other tools: PDFtk, qpdf (an R package) & LaTeX, but all of these had the same problem – a loss of bookmarks.

As publication date got closer stress levels mounted Eventually I stumbled on this answer which introduced the sejda software. With an open source licence and available installer, I got the job done in time The script I used is below, which also let me select pages from the report file:

sejda-console merge -b retain -f Downloads/DataReport_front.pdf Downloads/WDR2020.pdf Downloads/DataReport_back.pdf -o WDR2.pdf -s all:2-71:all

You can view the output here.

How do you combine pdfs? Have you had a problem with lost bookmarks?