Hi,
Most of the PDF files that my students upload as part of their assignment submissions cannot be opened in the grading interface. It used to work fine, and I cannot point to a single event that would be an obvious culprit (or a bunch of events for that matter).
Here is what the error looks like (Moodle 3.1.4+). For Google, the message reads
Cannot open the PDF. The file may be corrupt, or in an unsupported format.
After a bit of digging, I found that GhostScript was not able to generate an image of the document. Apache error logs show the following message (similar message for all PDF files):
**** Error reading a content stream. The page may be incomplete.
GPL Ghostscript 9.06: Unrecoverable error, exit code 1
[Fri Feb 10 12:49:51.474866 2017] [:error] [pid 4419] [client 10.10.4.10:49606] Default exception handler: Error generating image with ghostscript, debugging info: <pre>Command:\n'/usr/bin/gs' -q -sDEVICE=png16m -dSAFER -dBATCH -dNOPAUSE -r'100' -dFirstPage='1' -dLastPage='1' -dDOINTERPOLATE -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -sOutputFile='[tempdir]/assignfeedback_editpdf/pageimages/e30aede1e9465eef210d66e071a9562383d872bc/image_page0.png' '[tempdir]/assignfeedback_editpdf/pageimages/e30aede1e9465eef210d66e071a9562383d872bc/combined.pdf'\n\nResult:\nCurrent allocation mode is local\n\nOutput:\nError: /typecheck in --run--\nOperand stack:\n --dict:13/13(L)-- --dict:63/63(ro)(L)-- PageSpotColors --dict:13/13(L)-- --dict:0/0(L)-- --dict:4/4(L)-- --dict:5/5(L)-- --dict:4/4(L)-- 9934387 385 0 --nostringval-- ShadingType 3 ColorSpace DeviceRGB Function --dict:6/6(L)-- Coords --nostringval-- 0.004964 12 (0.00-6673972) --nostringval-- --dict:12/12(ro)(G)--\nExecution stack:\n %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1914 1 3 %oparray_pop 1913 1 3 %oparray_pop 1897 1 3 %oparray_pop --nostringval-- --nostringval-- 2 1 1 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- %loop_continue --nostringval-- --dict:70/70(L)-- --nostringval-- 128 %dict_continue --nostringval-- %loop_continue --nostringval-- --dict:67/67(L)-- --nostringval-- 5 %dict_continue --nostringval-- %loop_continue --nostringval-- --dict:1/1(L)-- --nostringval-- 1 %dict_continue --nostringval-- --nostringval--\nDictionary stack:\n --dict:1175/1684(ro)(G)-- --dict:1/20(G)-- --dict:82/200(L)-- --dict:82/200(L)-- --dict:109/127(ro)(G)-- --dict:293/300(ro)(G)-- --dict:24/31(L)-- --dict:3/6(L)--\nCurrent allocation mode is local</pre> Debug: \nError code: errorgenerateimage\n* line 459 of /mod/assign/feedback/editpdf/classes/pdf.php: moodle_exception thrown\n* line 447 of /mod/assign/feedback/editpdf/classes/document_services.php: call to assignfeedback_editpdf\\pdf->get_image()\n* line 551 of /mod/assign/feedback/editpdf/classes/document_services.php: call to assignfeedback_editpdf\\document_services::generate_page_images_for_attempt()\n* line 69 of /mod/assign/feedback/editpdf/ajax.php: call to assignfeedback_editpdf\\document_services::get_page_images_for_attempt()\n, referer: https://moodle.isf.edu.hk/mod/assign/view.php?id=444&rownum=0&action=grader&userid=36
I have checked the GhostScript file (it's fine) and tested it, using the 'Test GhostScript path' admin tool, and that worked fine as well. I have also checked whether the PDFs were fine, and they all were (we're talking dozens of files). It happens in all assignments, not just mine. The weird thing is - some PDFs go through just fine (I cannot find any difference with the ones that work, and the ones that don't). I updated to 3.1.4 as there were some assignment-related fixes, but that has not worked.
The funny thing is that Unoconv works fine (took a while to get it going...). For example, if a student uploads a ppt file (or other type), it gets converted into whatever Unoconv converts it to (PDF?) and displays fine in the grading interface. Having said that, now that GhostScript is misbehaving, it prevents the assignfeedback_editpdf\\task\\convert_submissions from working properly (it hangs quietly and gets stuck on submissions that have a problem).
Does anybody have any idea what could be the problem?
Cheers,
Fred