4

I usually prefer PDF images for my LaTeX documents because they are easy to crop/resize using Adobe professional. I am facing a weird problem. I modified one of the PDF images using Adobe professional by writing come comments using the pencil tool and added a rectangular box on the image and saved it. The LaTeX output is not showing the modification that I made to the image file but when i open the image file the modifications are still there. Did anyone face similar problems?

  • 2
    Are the comments perhaps annotations? Or, elaborate more on how you added the "comments" to the existing PDF. – Werner Nov 2 '11 at 5:43
  • 4
    Yes, PDF annotations (notes, hyperlinks, etc.) will be lost in included PDFs. See the accepted answer to How to preserve hyperlinks in included pdf?. – Martin Scharrer Nov 2 '11 at 6:47
  • I found a quick and dirty way to do this. The original pdf image can be opened and edited in image editing softwares such as Corel Draw and saved back to pdf. Output image quality is excellent and it will retain all the modifications. This won't work for hyperlinks though. – John Smith Nov 4 '11 at 5:04
  • 1
    I also can recommend the free PDF annotator xournal. It saves back to PDF without rasterising. You should definitely pay attention that you don't rasterize your PDF. – Marco Nov 7 '11 at 23:12
  • 2
    Maybe you could post your solution in the form of an answer so that this question can be marked so (you can answer your own questions and accept them as well) :) – mpr Nov 13 '11 at 6:41
4

One way to do this preserving the vector form would be to use the Adobe Acrobat "Preflight" tool, which allows you to "flatten" your comments ("Flatten forms and annotations"). I tried to show you an example, but it comes reversed! Maybe it's a bug of version X. :(

Another way inside Acrobat it's to open a console (Ctrl-J) and then execute the command flattenPages() which I can confirm it's working in my version of Acrobat and it's correctly compiled in vector form by pdfLaTeX. The output is like this.

A third option to selectively flatten your content would be one of the several scripts of the Adobe Exchange like this one (there's plenty of others) in case that

2

GhostScript can flatten PDFs. Try putting this in a file on your PATH (like /usr/local/bin/flattenpdf) and making it executable:

#!/bin/bash
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sPDFPassword='' -dPDFSETTINGS=/prepress -dPassThroughJPEGImages=true -sOutputFile="${1%.*} (Flattened).pdf" "$1"

Then just use flattenpdf yourpdffile.pdf to create a flattened version.

also it removes password restrictions from PDFs

1

The problem is that the annotations are added to the PDF on a separate layer, in a way not handled by many tools that embed PDFs in other PS/PDF content. Thus you have to flatten the annotations - turn them to ordinary PDF primitives - for them to show up.

On OS X, the annotation flattening is done from Preview via "Export to PDF".

Here is the workflow I use to annotate photographs:

  1. Open any image file in Preview.
  2. Optionally reduce the size to keep the file size down.
  3. Export to PDF - this will be the editable annotated file.
  4. Open the PDF in Preview.
  5. Add annotations to the PDF. They are editable if you reopen the file later with Preview.
  6. Export to PDF - this will be the flattened file that shows up correctly in pdflatex output etc.
  • 1
    Thanks, however when I do this the exported PDF has an A4 or US Letter format, which the original file did not have ; in other words it puts the original content in a big white page. This makes it impractical for Latex purposes. Any solution? – Arthur Mar 19 '18 at 16:01
  • @Arthur You can crop it, although there is a way to use PdfKit directly to avoid the big white page problem I believe. It'd require some coding, though. – Reinstate Monica Mar 19 '18 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.