How to exclude password protected PDFs from preview generation?

Hi,

I do have password protected PDFs and this is causing errors during preview generation (ImagickException).

How can I exclude password protected PDFs in general from preview generation?

Nextcloud version: 21.0.1
OS: Ubuntu 20.04.2 LTS (Linux 5.4.0-1047-azure #49-Ubuntu SMP Thu Apr 22 14:30:37 UTC 2021 x86_64)
Apache version: Apache/2.4.41 (Ubuntu) (apache2handler)
PHP version : 7.4.3
previewgenerator: 3.1.1

Output of sudo --user www-data /usr/bin/php /var/www/html/occ preview:generate-all

 **** This file requires a password for access.
Error: /invalidfileaccess in pdf_process_Encrypt
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   runpdf   --nostringval--   2   %stopped_push   --nostringval--   runpdf   runpdf   false   1   %stopped_push   1990   1   3   %oparray_pop   1989   1   3   %oparray_pop   1977   1   3   %oparray_pop   1978   1   3   %oparray_pop   runpdf   runpdf   runpdf   runpdf   false   1   %stopped_push
Dictionary stack:
   --dict:737/1123(ro)(G)--   --dict:1/20(G)--   --dict:80/200(L)--   --dict:80/200(L)--   --dict:135/256(ro)(G)--   --dict:315/325(ro)(G)--   --dict:29/32(L)--
Current allocation mode is local
GPL Ghostscript 9.50: Unrecoverable error, exit code 1

Nextcloud log:

ImagickException: FailedToExecuteCommand `'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' -dFirstPage=1 -dLastPage=1 '-sOutputFile=/tmp/magick-241083-Ij17LVvC54J%d' '-f/tmp/magick-2410831g_8vVs87BjM' '-f/tmp/magick-241083c8DKVc5jEwyK'' (1) @ error/pdf.c/InvokePDFDelegate/291
/var/www/html/lib/private/Preview/Bitmap.php - line 87:

Imagick->readimage()

/var/www/html/lib/private/Preview/Bitmap.php - line 50:

OC\Preview\Bitmap->getResizedPreview()

/var/www/html/lib/private/Preview/GeneratorHelper.php - line 63:

OC\Preview\Bitmap->getThumbnail()

/var/www/html/lib/private/Preview/Generator.php - line 244:

OC\Preview\GeneratorHelper->getThumbnail()

/var/www/html/lib/private/Preview/Generator.php - line 140:

OC\Preview\Generator->getMaxPreview()

/var/www/html/lib/private/PreviewManager.php - line 205:

OC\Preview\Generator->generatePreviews()

/var/www/html/apps/previewgenerator/lib/Command/Generate.php - line 203:

OC\PreviewManager->generatePreviews()

/var/www/html/apps/previewgenerator/lib/Command/Generate.php - line 174:

OCA\PreviewGenerator\Command\Generate->parseFile()

/var/www/html/apps/previewgenerator/lib/Command/Generate.php - line 172:

OCA\PreviewGenerator\Command\Generate->parseFolder()

/var/www/html/apps/previewgenerator/lib/Command/Generate.php - line 172:

OCA\PreviewGenerator\Command\Generate->parseFolder()

/var/www/html/apps/previewgenerator/lib/Command/Generate.php - line 172:

OCA\PreviewGenerator\Command\Generate->parseFolder()

/var/www/html/apps/previewgenerator/lib/Command/Generate.php - line 172:

OCA\PreviewGenerator\Command\Generate->parseFolder()

/var/www/html/apps/previewgenerator/lib/Command/Generate.php - line 155:

OCA\PreviewGenerator\Command\Generate->parseFolder()

/var/www/html/apps/previewgenerator/lib/Command/Generate.php - line 123:

OCA\PreviewGenerator\Command\Generate->generateUserPreviews()

/var/www/html/lib/private/User/Manager.php - line 646:

OCA\PreviewGenerator\Command\Generate->OCA\PreviewGenerator\Command\{closure}("*** sensiti ... *")

/var/www/html/apps/previewgenerator/lib/Command/Generate.php - line 124:

OC\User\Manager->callForSeenUsers()

/var/www/html/3rdparty/symfony/console/Command/Command.php - line 255:

OCA\PreviewGenerator\Command\Generate->execute()

/var/www/html/3rdparty/symfony/console/Application.php - line 1009:

Symfony\Component\Console\Command\Command->run()

/var/www/html/3rdparty/symfony/console/Application.php - line 273:

Symfony\Component\Console\Application->doRunCommand()

/var/www/html/3rdparty/symfony/console/Application.php - line 149:

Symfony\Component\Console\Application->doRun()

/var/www/html/lib/private/Console/Application.php - line 215:

Symfony\Component\Console\Application->run()

/var/www/html/console.php - line 100:

OC\Console\Application->run()

/var/www/html/occ - line 11:

require_once("/var/www/html/console.php")

Thanks,
Thomas

Is there anyone with the same issue or does anybody have a hint how to workaround this?

Thanks,
Thomas