Uploaded image for project: 'OpenOLAT'
  1. OpenOLAT
  2. OO-5067

RS when exporting checklist

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 15.2.8
    • Fix Version/s: 15.2.9, 15.3.3
    • Component/s: Course
    • Labels:
      None

      Description

      A redscreen can occur when exporting the overview of a checklist as PDF. We had the problem with the name "Taşoğlu". The stack trace is

      Exception: java.lang.IllegalArgumentException: U+015F ('scedilla') is not available in this font Helvetica encoding: WinAnsiEncoding at org.apache.pdfbox.pdmodel.font.PDType1Font.encode(PDType1Font.java:426) at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:332) at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:363) at org.olat.core.util.pdf.PdfDocument.getStringWidth(PdfDocument.java:198) at org.olat.core.util.pdf.PdfDocument.getStringWidth(PdfDocument.java:189) at org.olat.course.nodes.cl.ui.CheckboxPDFExport.create(CheckboxPDFExport.java:198) at org.olat.course.nodes.cl.ui.CheckListAssessmentController.doExportPDF(CheckListAssessmentController.java:598) 
      

      I fixed the problem for me with the following patch. But there is probably a better solution

       diff --git a/src/main/java/org/olat/course/nodes/cl/ui/CheckboxPDFExport.java b/src/main/java/org/olat/course/nodes/cl/ui/CheckboxPDFExport.java
      index 09ddd24..f80ba6b 100644
      --- a/src/main/java/org/olat/course/nodes/cl/ui/CheckboxPDFExport.java
      +++ b/src/main/java/org/olat/course/nodes/cl/ui/CheckboxPDFExport.java
      @@ -21,6 +21,7 @@
       
       import java.io.IOException;
       import java.io.InputStream;
      +import java.text.Normalizer;
       import java.util.List;
       
       import javax.servlet.http.HttpServletResponse;
      @@ -354,7 +355,12 @@
       				currentContentStream.setTextMatrix(Matrix.getRotateInstance(3 * (Math.PI / 2), textx + cellMargin, texty - cellMargin));
       				textx += colWidth;
       			}
      -			currentContentStream.showText(cleanString(text));
      +			try {
      +				currentContentStream.showText(cleanString(text));
      +			} catch (IllegalArgumentException e) {
      +				currentContentStream.showText(Normalizer.normalize(cleanString(text), Normalizer.Form.NFKD)
      +						.replaceAll("\\p{InCombiningDiacriticalMarks}+",""));
      +			}
       			currentContentStream.endText();
       		}
       
      @@ -381,7 +387,12 @@
       							currentContentStream.beginText();
       							currentContentStream.setFont(font, fontSize);
       							currentContentStream.newLineAtOffset(textx, lineTexty);
      -							currentContentStream.showText(textLine);
      +							try {
      +								currentContentStream.showText(textLine);
      +							} catch (IllegalArgumentException e) {
      +								currentContentStream.showText(Normalizer.normalize(textLine, Normalizer.Form.NFKD)
      +										.replaceAll("\\p{InCombiningDiacriticalMarks}+",""));
      +							}
       							currentContentStream.endText();
       							lineTexty -= (lineHeightFactory * fontSize);
       						}
      @@ -389,7 +400,12 @@
       						currentContentStream.beginText();
       						currentContentStream.setFont(font, fontSize);
       						currentContentStream.newLineAtOffset(textx, texty);
      -						currentContentStream.showText(text);
      +						try {
      +							currentContentStream.showText(text);
      +						} catch (IllegalArgumentException e) {
      +							currentContentStream.showText(Normalizer.normalize(text, Normalizer.Form.NFKD)
      +									.replaceAll("\\p{InCombiningDiacriticalMarks}+",""));
      +						}
       						currentContentStream.endText();
       					}
       				}
      
      

       

        Figma for Jira By 42nd

          Attachments

            Activity

              People

              Assignee:
              srosse Stéphane Rossé
              Reporter:
              stephan Stephan Clemenz
              Tester:
              Mandy Menzel
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: