chore(pdf): use pdf encryption on admin test page

This commit is contained in:
Steffen Jost 2022-07-25 13:14:58 +02:00
parent 09b2a88b4e
commit 56c2847b45
3 changed files with 23 additions and 9 deletions

View File

@ -304,6 +304,11 @@ getAdminTestPdfR = do
case content of
Right (Right bs) -> do
liftIO $ LBS.writeFile "/tmp/generated.pdf" bs
sendByteStringAsFile "demoPDF.pdf" (LBS.toStrict bs) now
mbEncPdf <- encryptPDF "tomatenmarmelade" bs
case mbEncPdf of
Left err -> sendResponseStatus internalServerError500 $ decodeUtf8 $ LBS.toStrict $ "PDFtk error: \n" <> err
Right encPdf -> do
liftIO $ LBS.writeFile "/tmp/crypted.pdf" encPdf
sendByteStringAsFile "demoPDF.pdf" (LBS.toStrict bs) now
Right (Left err) -> sendResponseStatus internalServerError500 $ decodeUtf8 $ LBS.toStrict $ "LaTeX compile error: \n" <> err
Left err -> sendResponseStatus internalServerError500 $ "Pandoc error: \n" <> P.renderError err

View File

@ -68,7 +68,11 @@
<section>
<h2>
Erzeugtes PDF herunterladen:
Hier ist ein
<a href=@{AdminTestPdfR}>
Download-Link
für eine PDF Vorschau.
<p>
Hier ist ein
<a href=@{AdminTestPdfR}>
Download-Link
für eine PDF Vorschau.
<p>
Zusätzlich wird dabei im Verzeichnis /tmp
das PDF mit und ohne Passwort gespeichert.

View File

@ -69,7 +69,12 @@
<section>
<h2>
Download a generated PDF
Here is a
<a href=@{AdminTestPdfR}>
Download-Link
for a preview.
<p>
Here is a
<a href=@{AdminTestPdfR}>
Download-Link
for a preview.
<p>
Following the link, the pdf will also be saved
to the /tmp directory, once without
and once with password protection.