I am creating a series of laboratory exercises for my University. Thus, I created a .cls file that includes every package and applies any format I need. Among the included packages is the eforms package to create fillable fields and soul package to apply highlighting. Note that I use XeLaTeX for compiling. My main problem is that when I close the pdf, Adobe Reader always prompts "Do you want to save changes to ... before closing?" even no changes are made in those fields, even there is not any field at all. How can I overcome that issue while preserving the visibility of my fields?

A possible solution is to set true the pdfa option of hyperref package. That option disables a variety of properties that prevent the document from being PDF/A compliant. One of those properties is the NeedAppearances, which is set to false instead of default true. The result of that action is that fields are invisible unless they are clicked. The same behavior also is observed by fields created using hyperref commands.

Another possible solution is to use pdfx package with the a-3b option. This solution works almost like a charm, document claims compliance with PDF/A standard, all fields are visible and document is opened in read-only mode, so Adobe Reader doesn't ask for saving for no reason. Unfortunately, pdfx messes with soul package and the \hl{} command for highlighting; doesn't allow text to be highlighted. For example, when a whole sentence is highlighted with \hl, only whitespaces inside the sentence are displayed as highlighted. Thus, this solution cannot be applied since highlighting is a mandatory.

Foxit Reader, on the other hand, seems to be smarter. With the default setting (no pdfx and no pdfa option of hyperrref) Foxit knows when a field is edited and only then asks for saving. But, Foxit's performance is poor compared to Adobe Reader.

So, I am thinking a variety of solutions:

  • Is there any way to instruct Adobe Reader, possibly through latex commands, to open a document as read-only, in a similar way that Adobe Reader does when opens a PDF/A document?

  • Since PDF/A format doesn't seem a bad perspective, is there any way to support highlighting in PDF/A documents, with soul package or with an alternative method/package?

EDIT: I also tried to experiment with a simple example of eforms from here: http://www.math.uakron.edu/~dpstory/acrotex/examples/html/eforms_tst.pdf. The original pdf does not prompt for saving. Although, I compiled the source file that is attached using pdflatex and the prompt appeared again! I updated all packets from MikTeX console and the issue still persists.


A bit of JavaScript that is executed just before the document closes (/WC <<...>> % "will close") un-dirties the PDF:


\usepackage{pdfbase} %\pbs_pdfcatalog:n{...}

  /AA <<    % additional document actions
    /WC <<  % "will close" trigger event
      /S/JavaScript /JS (this.dirty=false;)

    % Content containing form fields, such as...
    Don’t \pushButton[\CA{Push Me}]{myButton}{}{12bp},
    I fall down easily.
  • 1
    This solution doesn't seem to work. I used your code as it is in a new document, and XeLaTeX does not even recognize \pdfcataog. All other compilers (pdflatex, latex, lualatex) compile successfully, but at closing of the document, the same question is being asked. – Christos Dalamagkas Aug 25 '18 at 13:40
  • Sorry, but my example works for me. Not asking for saving. I updated it to be compilable with XeLaTeX. – AlexG Aug 26 '18 at 12:57
  • Unfortunately, this solutions didn't work for me. It seems that it isn't a code issue. I added to my original post the description of a new unsuccessful attempt. – Christos Dalamagkas Aug 28 '18 at 15:58
  • Could you please provide a minimal compilable code example that demonstrates the issue? – AlexG Aug 28 '18 at 17:06
  • 1
    That is a minimal compilable code. Just loading the eforms package, no fields at all. Adding your code, gives the same result; asks for saving the document. \documentclass{article} \usepackage{eforms} \begin{document} Only text. \end{document} – Christos Dalamagkas Aug 28 '18 at 17:33

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.