Stirling-PDF icon indicating copy to clipboard operation
Stirling-PDF copied to clipboard

[Bug]: Pipeline Configuration To support secondary file inputs

Open LckySndays opened this issue 1 year ago • 7 comments

Installation Method

Docker

The Problem

Pipeline Configuration -> add-watermark -> watermarkType (string): text

With watermarkType set to text and watermarkImage set to default "FileInputPathToBeInputtedManuallyForOffline" or Null Pipeline still failed with [Field error in object 'addWatermarkRequest' on field 'watermarkImage': rejected value [FileInputPathToBeInputtedManuallyForOffline]

Any documentation about what is the correct value/format for "watermarkImage (string):" looks like and how to utilize it correctly? Is it a required field for watermark even if "watermarkType (string): " set to text ?

"opacity (number): " in pipeline menu format (0.0~1.0) is also not consistent with watermark menu format Opacity (0% - 100%)

Version of Stirling-PDF

0.29.0

Last Working Version of Stirling-PDF

No response

Page Where the Problem Occurred

https://pdf.xxx.co/pipeline

Docker Configuration

version: '3.3'
volumes:
  stirling-data:
    name: stirling-data
  stirling-config:
    name: stirling-config
  stirling-custom:
    name: stirling-custom
services:
  stirling-pdf:
    container_name: stirling
    restart: unless-stopped
    image: frooodle/s-pdf:latest
    ports:
      - '8818:8080'
    volumes:
      #- stirling-data:/usr/share/tesseract-ocr/4.00/tessdata #Required for extra OCR languages
      - stirling-data:/usr/share/tessdata
      - stirling-config:/configs
      - stirling-custom:/customFiles/
    environment:
      - DOCKER_ENABLE_SECURITY=false
      - INSTALL_BOOK_AND_ADVANCED_HTML_OPS=true

Relevant Log Output

02:59:01.418 [qtp1789237070-123] INFO  s.s.S.c.a.p.PipelineController - Received POST request to /handleData with 1 files

02:59:01.419 [qtp1789237070-123] INFO  s.s.S.c.a.pipeline.PipelineProcessor - Files successfully loaded. Starting processing...

02:59:01.419 [qtp1789237070-123] INFO  s.s.S.c.a.pipeline.PipelineProcessor - Running operation: /api/v1/security/add-watermark isMultiInputOperation false

02:59:01.441 [qtp1789237070-152] WARN  o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolved [org.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [0] in public org.springframework.http.ResponseEntity<byte[]> stirling.software.SPDF.controller.api.security.WatermarkController.addWatermark(stirling.software.SPDF.model.api.security.AddWatermarkRequest) throws java.io.IOException,java.lang.Exception: [Field error in object 'addWatermarkRequest' on field 'watermarkImage': rejected value [FileInputPathToBeInputtedManuallyForOffline]; codes [typeMismatch.addWatermarkRequest.watermarkImage,typeMismatch.watermarkImage,typeMismatch.org.springframework.web.multipart.MultipartFile,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [addWatermarkRequest.watermarkImage,watermarkImage]; arguments []; default message [watermarkImage]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile' for property 'watermarkImage'; Cannot convert value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile' for property 'watermarkImage': no matching editors or conversion strategy found]] ]

Additional Information

No response

Browsers Affected

No response

No Duplicate of the Issue

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

LckySndays avatar Oct 16 '24 03:10 LckySndays

@Frooodle For The Pipeline Configuration - addWatermark operation How to input watermarkText (string) as string($binary) or file input? https://stirlingpdf.io/swagger-ui/index.html#/Security/addWatermark [watermarkImage string($binary)]

Conversion Error Log Message [Field error in object 'addWatermarkRequest' on field 'watermarkImage': rejected value [/pipeline/Image.png] [Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile' for property 'watermarkImage'; Cannot convert value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile' for property 'watermarkImage': no matching editors or conversion strategy found]]

01:26:05.406 [qtp1458751976-11512] ERROR s.s.S.c.a.p.PipelineController - Error handling data: 
org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request: "{"timestamp":"2024-11-13T01:26:05.403+00:00","status":400,"error":"Bad Request","exception":"org.springframework.web.bind.MethodArgumentNotValidException","trace":"org.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [0] in public org.springframework.http.ResponseEntity<byte[]> stirling.software.SPDF.controller.api.security.WatermarkController.addWatermark(stirling.software.SPDF.model.api.security.AddWatermarkRequest) throws java.io.IOException,java.lang.Exception: [Field error in object 'addWatermarkRequest' on field 'watermarkImage': rejected value [/pipeline/Image.png]; codes [typeMismatch.addWatermarkRequest.watermarkImage,typeMismatch.watermarkImage,typeMismatch.org.springframework.web.multipart.MultipartFile,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [addWatermarkRequest.watermarkImage,watermarkImage]; arguments []; default message [watermarkImage]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile' for property 'watermarkImage'; Cannot convert value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile' for property 'watermarkImage': no matching editors or conversion strategy found]]

Related Issue https://github.com/Stirling-Tools/Stirling-PDF/issues/2036

LckySndays avatar Nov 13 '24 01:11 LckySndays

Can you show your example inputs? What did you select for watermark type etc?

Frooodle avatar Nov 13 '24 07:11 Frooodle

@Frooodle Just like what I mentioned above, even when watermarkType set to text, the watermarkImage value still being evaluated no matter if the value set to empty or not and it will failed with Cannot convert value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile' for property 'watermarkImage' and I am not even sure how to set watermarkImage value with the correct value, I have tried to input the file path as well before

image

Pipeline is valid
files[i] testfile.pdf
pipelineConfigJson {
  "name": "Custom",
  "pipeline": [
    {
      "operation": "/api/v1/security/add-watermark",
      "parameters": {
        "watermarkType": "text",
        "watermarkText": "TestWatermarkText",
        "watermarkImage": "FileInputPathToBeInputtedManuallyForOffline",
        "alphabet": "roman",
        "fontSize": 30,
        "rotation": 0,
        "opacity": 0.5,
        "widthSpacer": 50,
        "heightSpacer": 50,
        "convertPDFToImage": false
      }
    }
  ],
  "_examples": {
    "outputDir": "{outputFolder}/{folderName}",
    "outputFileName": "{filename}-{pipelineName}-{date}-{time}"
  },
  "outputDir": "httpWebRequest",
  "outputFileName": "{filename}"
}

LckySndays avatar Nov 14 '24 01:11 LckySndays

Ahh I see what issue is Thanks for raising will resolve this

Frooodle avatar Nov 14 '24 08:11 Frooodle

@Frooodle

The problem probably affecting other pipeline features as well just like https://github.com/Stirling-Tools/Stirling-PDF/issues/2036 with (stampImage) or any others

Thanks for resolving the issue

LckySndays avatar Nov 14 '24 09:11 LckySndays

@Frooodle for me its also happening when executing the pipeline I'm getting an empty txt

image

{
  "name": "PDF als GESPERRT markieren",
  "pipeline": [
    {
      "operation": "/api/v1/misc/add-stamp",
      "parameters": {
        "pageNumbers": "n",
        "stampType": "text",
        "stampText": "GESPERRT",
        "stampImage": "FileInputPathToBeInputtedManuallyForOffline",
        "alphabet": "roman",
        "fontSize": 150,
        "rotation": -55,
        "opacity": 0,
        "position": 1,
        "overrideX": -1,
        "overrideY": -1,
        "customMargin": "x-large",
        "customColor": "#f22626",
        "fileInput": "automated"
      }
    }
  ],
  "_examples": {
    "outputDir": "{outputFolder}/{folderName}",
    "outputFileName": "{filename}-{pipelineName}-{date}-{time}"
  },
  "outputDir": "{outputFolder}",
  "outputFileName": "{filename}"
}

MarcBollmann avatar Nov 14 '24 15:11 MarcBollmann

@Frooodle Will this be fixed in Pipeline v2 enhancement?

Ahh I see what issue is Thanks for raising will resolve this

LckySndays avatar Dec 05 '24 00:12 LckySndays