Thread "ILIAS 7: insufficient PDF creation by 'wkhtmltopdf'"

Tabs

  • utesche
    utesche | utesche | 25. Jan 2022, 18:03
    Edited on: 9. Mar 2022, 12:09 - by utesche | utesche
    ILIAS 7: insufficient PDF creation by 'wkhtmltopdf'
    @all,

    With ILIAS 7 'phantomjs' as the PDF-generating tool was abandoned due to unreliable maintenance - and 'wkhtmltopdf' came in first place to do the job now.

    For some cases, 'TCPDF' can be configured to generate PDFs. Certificates are produced by 'ilServer' before and now.  For theses cases the generated PDF is good to acceptable.
    For almost all other cases, 'wkhtmltopdf' fails - just in one case the generated PDF is OK (Portfolio).

    We do not see a realistic improvement to this situation in terms of 'lifecycle ILIAS 7' at our university.
    So we decided to reflect this situation by using TCPDF where possible and removing all other concerned buttons and actions from visibilty.
    In consequence as an alternative: the user have to request a 'Print' in these contextes and route the output to a 'local PDF-Target' (e.g. Acrobat, Microsoft Print to PDF,...) or the browser's functionality 'Save as PDF'.

    This plan required:
    1. collect all use cases concerning PDF generation
    2. evaluating the quality of the produced PDFs
    3. identifying how the given button/action can be made invisible, if necessary
    .. quite a bunch of work - which shall now be of worth for the whole community by this post.
    Some of the contextes - mainly in T&A - can be navigated to on different pathes, I use the obvious one hereinafter.



    (A)  working PDF generation contexts

    (A1)  <Test>  >>  Results  >>  Test Results  >>  Detailed Results  >>  "Certificate"
    PDF is generated by ilServer:  OK!

    (A2)  <Test>  >>  Statistics  >>  Evaluation for all Users  >>  "Export as: Certificate (PDF)"
    PDF is generated by ilServer:  OK!

    (A3)
      "Personal Workspace"  >>  Portfolio >>  "Drop-down action: Edit Content"  >>  "Export as PDF"
    The only acceptable PDF output of 'wkhtml' so far:  OK!

    (A4)   <Test>  >>  Questions  >>  Print View  >>  "PDF Export"
    Only IF (!) configured to use TCPDF as PDF renderer:  rather OK.

    If the quality is not acceptable to you, you can remove the button by commenting out the lines of code (2398 to 2403), located here:
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Test/classes/class.ilObjTestGUI.php#L2398

    (A5)   <Test>  >>  Questions  >>  Review  >>  "PDF Export"
    Only IF (!) configured to use TCPDF as PDF renderer:  rather OK.

    If the quality is not acceptable to you, you can remove the button by commenting out the lines of code (2538 to 2543), located here:
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Test/classes/class.ilObjTestGUI.php#L2538



    (B)  broken PDF generation contextes

    (B1)
       <Test>  >>  Results  >>  All Participants  >>  (Participant-Action-Menue:) "Test Results"  >>  "PDF Export"
    to remove the button, comment out the lines of code (1088 to 1090), located here:
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Test/classes/class.ilTestEvaluationGUI.php#L1088

    (B2)   <Test>  >>  Results  >>  All Participants  >>  (Participant-Action-Menue:) Test Results  >>  "Detailed Results"  >>  "PDF Export"
    to remove the button, comment out the lines of code (972 to 974), located here:
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Test/classes/class.ilTestEvaluationGUI.php#L972

    (B3)   <Test>  >>  Results  >>  Test Results  >>  "PDF Export"
    to remove the button, comment out the lines of code (1415 to 1417), located here:
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Test/classes/class.ilTestEvaluationGUI.php#L1415

    (B4)  <Test>  >>  Results  >>  Test Results  >>  Detailed Results  >>  "PDF Export"
    to remove the button, comment out the lines of code (1281 to 1283), located here:
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Test/classes/class.ilTestEvaluationGUI.php#L1281

    (B5)  <Test>  >>  Statistics  >>  Results by Question  >>  "PDF Export"
    to remove the whole tab "Results by Question", comment out the lines of code (834 to 840), located here:
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Test/classes/class.ilTestTabsManager.php#L834

    (preferred)
    to remove just the "PDF Export" actions in the list, comment out this line of code (1701):
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Test/classes/class.ilTestEvaluationGUI.php#L1701

    (B6)  <Test>  >>  Info  >>  "Start New Test Pass"  >>  "Finish the Test"  >>  "PDF Export"
    (you have to be activate the options: "Exam View" and "Overview of Answers Given" and "PDF Download" to get the button)
    to remove the button, comment out the lines of code (105 to 113), located here:
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Test/classes/class.ilTestSubmissionReviewGUI.php#L105

    (B7)  <Test>  >>  Export  >>  "Create Export File: Create Test Export File"
    to remove the action in the drop-down-list, comment out this line of code (31):
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Test/classes/class.ilTestExportGUI.php#L31

    (B8)  <Survey>  >>  Results  >>  Overview  >>  "Export PDF"   AND   <Survey>  >>  Results  >>  Details  >>  "Export PDF"
    to remove these two buttons, comment out the lines of code (840 - 851), located here:
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Survey/Evaluation/class.ilSurveyEvaluationGUI.php#L840

    (B9)  <Wiki>  >>  Print View  >>  "PDF Export"
    to remove the button, comment out this line of code (823):
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Wiki/classes/class.ilWikiPageGUI.php#L823

    (B10)  <cronjob: survey_notification> <task: "Tutor Results">
    all PDFs in the result-mail for the tutor are broken, to suppress this mail, comment out the lines of code (104-109), located here:
    https://github.com/ILIAS-eLearning/ILIAS/blob/release_7/Modules/Survey/classes/class.ilSurveyCronNotification.php#L104


    If any PDF-generation-contextes "out there in ILIAS 7" are not mentioned here,  PLEASE  reply with some info!   I will evaluate and add them to this starting post of the thread.

    wbr,
    Uwe.

    edit:
    feel free to give this issue your 'priority' ...  :-)


    9.3.2022,  edit 2:

    Meanwhile I noticed some updates of concerned PHP code: so "peak around" to locate the referenced positions.  If you're in doubt, you can ask me here for a hint - or you can checkout any commit dated 2022-01-25 in branch release_7.

  • ILIAS_LM
    ILIAS_LM | ILIAS_LM (Moderation) | 26. Jan 2022, 08:35
    Re: ILIAS 7: insufficient PDF creation by 'wkhtmltopdf'
    Thank you for this handy documentation!

    Do you already know the following feature requests?
    I don't know, if there already are more requests. I only remember the mentioning of a general abandoning of PDF generation.
  • utesche
    utesche | utesche | 26. Jan 2022, 09:02
    Edited on: 26. Jan 2022, 09:04 - by utesche | utesche
    Re(2): ILIAS 7: insufficient PDF creation by 'wkhtmltopdf'
    Yes, I know, all 3 FRs are targeted for ILIAS 8.
    The (our) problem is current ILIAS 7.
  • amstutz
    Timon Amstutz | amstutz | 26. Jan 2022, 09:21
    Edited on: 26. Jan 2022, 09:24 - by Timon Amstutz | amstutz
    Re(3): ILIAS 7: insufficient PDF creation by 'wkhtmltopdf'

    Good morning everybody,

    Thx a lot uwe for bringing up this toping and tackling it in such a systematic way and sharing your results here! I completely agree, the pdf generation is a big issue in ILIAS 7. See also: https://docu.ilias.de/goto_docu_blog_3439_725.html Luzern and Uni Bern both opted to workaround the issue (see blog entry). We both agree that this really needs to be improved in the core. As far as I am aware, HSLU is working with a solution, similar to what Uwe is proposing, get rid of the buttons. This is their patch, https://github.com/HochschuleLuzern/ILIAS-HSLU/commit/0056631d46e6b7994c2e9eb7397ef7fae8379dbd . Possible that they refined it, since then. 

    Our approach at Uni Bern is much simpler, messier, hackier and less bullet proof. However, it somewhat keeps the "To PDF" feature alieve, some of our user like so mutch (for reasons I do not understand). We simply throw the whole output into the face of the browser (echo) and tell the browser to print it (window.print) and kill of the execution of ilias (exit). Browsers are used to render nasty output in a digestable manner. Works not so bad. I am sure, that there are several context that are missing (see uwes list above). However, so far this seems to work: 

    Services/PDFGeneration/classes/renderer/wkhtmltopdf/class.ilWkhtmlToPdfRenderer.php
    run runCommandLine function (line 150):

    echo file_get_contents($a_path_to_file)." <script>window.print();</script>"; 
    exit;

    Maybe this helps. I use it and do not recommend it :-).

    +1 Alix for improving it with 8 (interest in funding). 

    Not sure what can be done as bugfix. If there is a way, we would also be interested in funding it. I wrote I respective comment into the ticket. Thx Uwe.

  • pascal.schmitt
    pascal.schmitt | pascal.schmitt (Moderation) | 26. Jan 2022, 09:47
    Re(4): ILIAS 7: insufficient PDF creation by 'wkhtmltopdf'
    Thanks for this helpfull documentation Uwe.

    We are highly dependent on the pdf export of tests and I'm sure there are a lot of users, on our installation as well as on others, loving the pdf export in general.

    I would like to mention that the pdf export is also important for the archiving of content. for example, we are obliged to archive certain content and deliver it to the state archives. for this, the export format must be pdf. Using the print button for such a scenario is obviously not a solution.