Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#8232·Stirling-PDF

[Bug]: sanitize-pdf operation fails for PDFs that contain an encryption dictionary but do not require a password to open

Author: danielbrollCreated Sep 28, 2026Updated Sep 28, 2026

Installation Method

Docker

The Problem

In Stirling-PDF v3.0.0, the sanitize-pdf operation fails for PDFs that contain an encryption dictionary but do not require a password to open.

The PDF can be opened normally without entering a password, but sanitizing it fails through both api and web UI with: IllegalStateException: PDF contains an encryption dictionary, please remove it with setAllSecurityToBeRemoved() or set a protection policy with protect()

I tried to remove the password/encryption first in a pipeline using:

javascript
{
  operation: '/api/v1/general/remove-password',
  parameters: {
    password: '',
  },
},

However, an empty password is rejected by the pipeline validator: java.lang.IllegalArgumentException: Invalid operation: /api/v1/general/remove-password with parameters: {password=}

Important difference between API/pipeline and Web UI

The Web UI at:

/automate

does allow removing an empty password by using a workaround

{
  "name": "automation-remove-password",
  "description": "",
  "icon": "SettingsIcon",
  "operations": [
    {
      "operation": "removePassword",
      "parameters": {
        "password": ""
      }
    },
    {
      "operation": "sanitize",
      "parameters": {
        "removeJavaScript": false,
        "removeEmbeddedFiles": false,
        "removeXMPMetadata": false,
        "removeMetadata": false,
        "removeLinks": false,
        "removeFonts": false
      }
    }
  ]
}

Which succeeds. Using the resulting pdf in the /sanitize Web UI then no longer creates the IllegalStateException: PDF contains an encryption dictionary.

So the underlying PDF can be handled successfully by Stirling-PDF, but the same workflow cannot currently be represented in a pipeline because the '/api/v1/general/remove-password' operation rejects an empty password.

Version of Stirling-PDF

3.0.0

Last Working Version of Stirling-PDF

No response

Page Where the Problem Occurred

http://localhost:8080/sanitize

Docker Configuration

txt

Relevant Log Output

txt
## Sanitize


java.lang.IllegalStateException: PDF contains an encryption dictionary, please remove it with setAllSecurityToBeRemoved() or set a protection policy with protect()
    at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1536)
    at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1475)
    at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1042)
    at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:988)
    at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:940)
    at stirling.software.common.util.WebResponseUtils.pdfDocToWebResponse(WebResponseUtils.java:89)
    at stirling.software.SPDF.controller.api.security.SanitizeController.sanitizePDF(SanitizeController.java:104)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:359)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:158)
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:94)
    at stirling.software.common.aop.AutoJobAspect.lambda$wrapWithJobExecution$0(AutoJobAspect.java:85)
    at stirling.software.common.aop.AutoJobAspect.lambda$wrapWithMDC$0(AutoJobAspect.java:344)
    at stirling.software.common.service.JobExecutorService.lambda$runJobGeneric$3(JobExecutorService.java:212)
    at stirling.software.common.service.JobExecutorService.lambda$executeWithTimeout$0(JobExecutorService.java:479)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPerTaskExecutor$TaskRunner.run(Unknown Source)
    at java.base/java.lang.VirtualThread.run(Unknown Source)


## Remove password


java.lang.IllegalArgumentException: Invalid operation: /api/v1/general/remove-password with parameters: {password=}
    at stirling.software.SPDF.controller.api.pipeline.PipelineProcessor.runPipelineAgainstFilesInternal(PipelineProcessor.java:113)
    at stirling.software.SPDF.controller.api.pipeline.PipelineProcessor.runPipelineAgainstFiles(PipelineProcessor.java:86)
    at stirling.software.SPDF.controller.api.pipeline.PipelineDirectoryProcessor.runPipelineAgainstFiles(PipelineDirectoryProcessor.java:377)
    at stirling.software.SPDF.controller.api.pipeline.PipelineDirectoryProcessor.processPipelineOperations(PipelineDirectoryProcessor.java:228)
    at stirling.software.SPDF.controller.api.pipeline.PipelineDirectoryProcessor.handleDirectory(PipelineDirectoryProcessor.java:185)
    at stirling.software.SPDF.controller.api.pipeline.PipelineDirectoryProcessor$1.preVisitDirectory(PipelineDirectoryProcessor.java:141)
    at stirling.software.SPDF.controller.api.pipeline.PipelineDirectoryProcessor$1.preVisitDirectory(PipelineDirectoryProcessor.java:129)
    at java.base/java.nio.file.Files.walkFileTree(Unknown Source)
    at stirling.software.SPDF.controller.api.pipeline.PipelineDirectoryProcessor.scanWatchedFolder(PipelineDirectoryProcessor.java:125)
    at stirling.software.SPDF.controller.api.pipeline.PipelineDirectoryProcessor.scanFolders(PipelineDirectoryProcessor.java:94)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.scheduling.support.ScheduledMethodRunnable.runInternal(ScheduledMethodRunnable.java:128)
    at org.springframework.scheduling.support.ScheduledMethodRunnable.lambda$run$1(ScheduledMethodRunnable.java:122)
    at io.micrometer.observation.Observation.observe(Observation.java:569)
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:122)
    at org.springframework.scheduling.config.Task$OutcomeTrackingRunnable.run(Task.java:88)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at java.base/java.lang.VirtualThread.run(Unknown Source)

Additional Information

No response

Sample Files

No response

Browsers Affected

No response

No Duplicate of the Issue

  • I have verified that there are no existing issues raised related to my problem.

Source: Stirling-Tools/Stirling-PDF

View original on GitHubView discussion on GitHub