swiss-seismological-service / REIA-web

Frontend report generation for results of the near real time event specific loss calculations.
GNU Affero General Public License v3.0
0 stars 1 forks source link

Print PDF's as using pdf/a standard #53

Closed schmidni closed 2 months ago

schmidni commented 3 months ago

Very accurate problem description from Philipp:

(vgl. Screenshots unten: Farbverläufe statt Diagramme) Ich mache die .png-Previews der RIA-Sheets für die NAZ, indem ich die PDFs vom PDF-Printer herunterlade und mit PyMuPDF (getestet 1.16.11 und 1.25.5, das ist das jüngste Release) nach png konvertiere. PyMuPDF wrappt MuPDF, eine ziemlich weit verbreitete C-Library für PDF-Management. Offenbar hat die PDF-Geschmacksrichtung von Chrome ein Feature, das PyMuPDF nicht passt. In der Folge kann z.B. schon mein Standard-Linux-PDFviewer die Sheets nicht korrekt darstellen. (es gibt also evtl. noch mehr Nutzer, die damit Probleme haben). Ich habe mal versucht, das PDF mit Acrobat nach PDF/A zu konvertieren. Danach stellen es MuPDF-basierte Viewer richtig dar, und auch meine Konversion funktioniert. Und da offene Standards wie PDF/A eh eine gute Sache sind, wollte ich fragen:

Hat der PDF-Printer eine Option, um ihn standardmässig auf PDF/A zu trimmen?

Acceptance Criteria

Pdfs generated using the web-pdf-generator application are already converted to the PDF/A standard and are correctly displayed using eg. the MuPDF viewer.

Image Image

kaestli commented 3 months ago

(note - not only acrobat, but also ghostscript understands the initial pdf format sufficiently to convert it in a pdf/a which displays correctly using MuPDF based viewers. So we are probably working around a MuPDF bug here. Anyway...)

romanoe commented 2 months ago

@kaestli Does your PDF/A export with Acrobat maintain the same original quality and size of the file ?

I attempted to use ghostscript to convert it to PDF/A, but unfortunately, this process rasterizes the first page, making the text no longer searchable and selectable (see ria_report_ghostscript.pdf). Any clue ?

romanoe commented 2 months ago

After investigation: