Issues with Printing when using pdfform

Added by Manuel Sch about 1 month ago

When I print the exams, the PDF forms behave differently, to the one in the sujet/questions PDF. I.e. something seems to break the PDF forms while printing the exams.

1. Before printing all readers I have tested can click the forms correctly and then also show the ticked boxes correctly (see the attachment).
2. When I use the printing option, the files are generated in /tmp/ and with random names instead of the folder I set up.
3. After the printing the boxes vanish completely when ticked (see the attachment).
4. Adobe Reader does not want me to save the form data (see the attachment).

How do you cope with these issues?

For Nr. 3 I think it would be the easiest to simply print using LaTeX directly, that is just generate a new file for every student. This could also be done when the documents are generated to be sure they are the same.


Replies (14)

RE: Issues with Printing when using pdfform - Added by Juani Mela about 1 month ago

Dear Manuel,

Thanks a lot for introducing pdfforms to the english forum.

I have made a test using pdfforms, and it worked fine, but I did not use the "print button", instead I used my script for splitting the exam and the solution into individual files for each student, ultimately based on pdftk. I'm gonna share them:

  • ./break_exams number_of_students number_of_pages_per_student_in_DOC-sujet number_of_pages_per_student_in_DOC-corrige

is a bash script which reads a student.csv in the same directory, and creates subdirectories with the exams and their solutions. It also creates two textfiles:
email_list_statements, email_list_solutions with the information required to send the emails.

  • send_the_emails

This is a python script that will read from a configuration file, which is email_statements or email_solutions, and send one email to each student. You will also receive a copy.

  • ./send_the_emails statements

will read email_list_statements and send one email to each student with its email attached.

  • ./send_the_emails solutions

will read email_list_solutions will do the same for the solutions.

I have translated the scripts into english, I hope I did not introduce any bug, but I have tested them.


For pdfforms, I would follow this workflow:

  1. Generate DOC-sujet and DOC-corrige with AMC
  2. split the exams with break_exams
  3. setup a moodle task for them to upload their solutions
  4. send one email to each student with ./send_the_emails statements
  5. wait for the exam to finish, then inmediately send the solutions with ./send_the_emails solutions, for the students to have timely feedback
  6. recover their exams from moodle in one big zip file
  7. merge all the pdf files from the exams with pdftk (I have a "Thunar Custom Action" for merging many pdf files [1])
  8. feed the merged pdf file into ACM
  9. follow the usual procedure to get a csv file with detailed data: who was asked what, what sis they answer if the question was multiple-choice, and what was their grade for each question.
  10. recommend AMC to all my colleagues ;-)

Regards

[1] https://help.ubuntu.com/community/ThunarCustomActions

break_exams - break_exams (1.5 kB)

send_the_emails (1.9 kB)

email_solutions.py (601 Bytes)

email_statements.py (563 Bytes)

RE: Issues with Printing when using pdfform - Added by Juani Mela about 1 month ago

But unfortunately, the same problems you reported persist, probably. I do not have a copy of adobe acrobat, but if wants to bully our students to install a you-have-to-pay version, I guess we can only recommend them to install something different. I wonder what would they use in a smartphone...

RE: Issues with Printing when using pdfform - Added by Manuel Sch about 1 month ago

Oh this is really great. Thank you very much for sharing your workflow.

We are using OLAT [1] over here, so I suppose I will use OLAT instead of moodle but otherwise use the same procedure. Add 7: Why are you merging the PDF files instead of feeding all the files to ACM?

Regarding Adobe: I just supposed that most students use Adobe Reader. So I will just let them use Adobe DC as stated in the French forum.

[1] https://www.olat.org/

RE: Issues with Printing when using pdfform - Added by Manuel Sch about 1 month ago

Well actually I downloaded the Adobe DC and installed it using wine. I can also not save the form data there. What editor do you or rather your students use?
Further, if I print the document to a pdf file, AMC is unable to read it. Prepossessing with pdftk seems not to help here.

Btw I found one "bug" in the break_exams script (or maybe the document names for the english version and french/spanish are different).
Instead of "*corrige.pdf" I have to use "*indiv-solution.pdf". Further, I still have the issue when clicking the boxes after splitting with pdftk (as in after_printing.png). I guess the same is happening.

RE: Issues with Printing when using pdfform - Added by Juani Mela about 1 month ago

  • I have found that the "print exams" button in AMC can be configured in the "Main" configuration section. Using option "print using a command", with command lpr %f and extraction method qpdf solves the problem of "checkbox dissappears when I click". However, I would have to adapt the scripts.
  • I have asked my colleagues if they can fill the form and it worked with pretty much everything except free adobe reader:

evince, okular, atril, Adobe Acrobat XI Pro, qpdfview, Apple preview.

I wouldn't mind telling the students to install a free software pdf viewer. They have to be more critical with free versions. Recently, the licenses at my school for adobe reader got cancelled, and this caused quite some disruption for most teachers, who do not bring their laptop to class.

  • I insist on using DOC-corrige, since it differs with DOC-indiv-solution.pdf in that the former includes the output of the explain command.
  • I merge the pdf files since this requires a few seconds in thunar (with the custom action): select all files, right click, join pdfs. Then I only feed one file to AMC. But I just realized that AMC accepts many input files at once, so this is not required at all. I'm used to my own tools, but AMC keeps surprising me. Maybe there are buttons in AMC so that I don't need my scripts at all.

Regards

RE: Issues with Printing when using pdfform - Added by Manuel Sch about 1 month ago

I have found that the "print exams" button in AMC can be configured in the "Main" configuration section. Using option "print using a command", with command lpr %f and extraction method qpdf solves the problem of "checkbox dissappears when I click".

You just saved my day. Thanks a lot. This seems to work.

I wouldn't mind telling the students to install a free software pdf viewer.

Neither do I. Not at all actually :)

So then I print them as you stated and distribute them via email I think.

Muchas gracias

RE: Issues with Printing when using pdfform - Added by Juani Mela about 1 month ago

You just saved my day

And you saved us a lot of time by bringing pdfforms into the english forum, so you're very welcome.

BTW, I still need my script break-exams, since it doesn't just split the exams but also the solutions and also compiles the student list ready for send-the-emails. So I looked at the AMC source code, and even though I don't understand a word of perl, I could find the syntax for qpdf, so I have replaced pdftk by qpdf in my break-exams script. The new version is attached.

Have a nice day!

break_exams (1.8 kB)

RE: Issues with Printing when using pdfform - Added by Manuel Sch about 1 month ago

Yes this works. I actually tried to do it with qpdf before (using your script), but probably used the wrong command. Still I have to replace *carrige.pdf with *indv-solution.pdf. I guess they are just named wrong in the English version, which is the one I am using.

Further I adapted the `send_the_mail` script to support STARTTLS:

if  USE_STARTTLS:
    server = smtplib.SMTP(SMTPSERVER, port=SMTPPORT)
    context = ssl.create_default_context()    
    server.starttls(context=context)
else: 
    server = smtplib.SMTP_SSL(SMTPSERVER, SMTPPORT)

and of course in email_*.py added

USE_STARTTLS = True

Furthermroe, the break_exams script did not work for me as expected, as `cut` starts counting with 0 in my version. Additionally I added support for semincolons as seperator:

    if [[ "$email" == *","* ]]; then
        email=`echo $linea|cut -d ',' -f3`
    elif [[ "$linea" == *";"* ]]; then
        email=`echo $linea|cut -d ';' -f3`
    else
        echo "ERROR: COULD NOT FIND THE MAIL ADDRESS!" 
        echo $linea
        exit 1
    fi

Maybe this helps someone

break_exams (2.2 kB)

send_the_emails (2.3 kB)

RE: Issues with Printing when using pdfform - Added by Alexis Bienvenüe about 1 month ago

Splitting the PDF to individual files with boxes that can be ticked properly should work with the following setup:
  • choose qpdf as Preferences/Main/Printing/Extracting method
  • choose to files as Preferences/Main/Printing/Printing method.

Please try with the development version, and report problems.
The development version also allows to send the PDF subjects to the students when using pre-association.

RE: Issues with Printing when using pdfform - Added by Manuel Sch about 1 month ago

I got the pre-association to work. Important here is to set the Number of papers to 1, otherwise you get confused quite a bit :-)

What branch is the development branch? I used the master branch, as there is no dev branch. Or if the master branch is the dev branch, how can I send the PDF subjects?

RE: Issues with Printing when using pdfform - Added by Alexis Bienvenüe about 1 month ago

The master branch on git is OK.
You may also use the test PPA on ubuntu.
After printing to files with a pre-associated source file, the Send button should appear.

send.png (52.1 kB)

RE: Issues with Printing when using pdfform - Added by Manuel Sch 25 days ago

I am sorry I was quite busy. The problem is that this button never appears for me.

Interestingly my interface looks a little different as well (see attached file), although I use the master branch from git. The About page says Version 1.4.0. Is this correct?

Further, what also could be an issue is that, whenever I print the papers I get the warning that I did not select all papers, although I did (with CTRL-a).

RE: Issues with Printing when using pdfform - Added by Manuel Sch 10 days ago

Ok I installed Ubuntu (16.04 for newer version I could not get auto-multiple-choice to install) and used the ppa. Same results. So I guess my latex file is the issue. What could be wrong here:

\documentclass[a4paper]{article}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{multicol}
\usepackage{amsmath,amssymb}
\usepackage{pdfpages}
\usepackage{arrayjob}
\usepackage{pgfmath,pgffor}
\usepackage{comment}
\usepackage{listofitems}        % to overcome 9 parameter maximum

\usepackage{fp}                 % for randomized questions
\usepackage[german]{babel}

\usepackage[box,completemulti,lang=DE,pdfform]{automultiplechoice}
\usepackage{csvsimple}
\hypersetup{hidelinks}

% Macro for score
\newcommand{\scoreHautMaxMin}[2]{(Max #1 Punkte/Min #2 Punkte) \scoring{haut=#1,v=0,p=#2,e=#2}}
\newcommand{\scoreMaxMin}[2]{(Max #1 Punkte/Min #2 Punkte) \scoring{b=#1,v=0,m=#2,e=#2}}

% DEFINE TEST
\newcommand{\subject}{
  \onecopy{1}{

    \noindent{\bf Test \hfill 25. Juni 2020}

    \vspace*{.5cm}

     \hspace{-.604cm}
     \fbox{
        \begin{minipage}{1\linewidth}
          \vspace*{2em}
          {Name: \namefield{\Large\bf \Name{}} \\[0.5em]}
          {Matrikelnummer: \Large\bf \MatNr{} \\[0.5em]}
        \end{minipage}
      }
    \AMCassociation{\MatNr{}}

    %%% end of the header
    \pagebreak

    \begin{center}
      \hrule\vspace{2mm}
      \bf\Large Fragen
      \vspace{2mm}\hrule
    \end{center}

   \insertgroup{NettoT} 
   \includepdf[pages=-]{../questions/phi_normalverteilung_werte.pdf}

  }
}  

\begin{document}

% Set random seed (set to some integer)
\FPseed=2020

\setsepchar{ }                  % for list of parameters

% Define questions
\setdefaultgroupmode{withoutreplacement}
\input{../questions/mlp_nettobedarfsermittlung.tex}
\input{../questions/mlp_lineare_optimierung.tex}
\input{../questions/mlp_lagerhaltungsmodelle.tex}
\input{../questions/mlp_nachfrageprognose.tex}
\input{../questions/mlp_abcxyz.tex}
\input{../questions/mlp_netzplan.tex}

\cleargroup{all}
\copygroup[1]{NettoR}{all}    
\copygroup[3]{NettoT}{all}    

\copygroup[1]{LpR}{all}       
\copygroup[2]{LpT}{all}       

\copygroup[1]{LagerR}{all}    
\copygroup[2]{LagerT}{all}    

\copygroup[1]{PrognoseR}{all} 
\copygroup[3]{PrognoseT}{all} 

\copygroup[1]{AbcXyzR}{all}   
\copygroup[2]{AbcXyzT}{all}   

\copygroup[1]{NetzplanR}{all} 

\csvreader[head to column names,separator=semicolon]{students.csv}{}{\subject}

\end{document}

I have the association and a namefield. I thought that should be sufficient, or not?

RE: Issues with Printing when using pdfform - Added by Manuel Sch 10 days ago

also with the example of the documentation it does not work...hmm something seems to be not working as supposed I guess

(1-14/14)