feat(pdfengines): add rotate feature

This commit is contained in:
Julien Neuhart
2026-03-18 22:36:20 +01:00
parent 21e300fcec
commit 0663e5f92b
19 changed files with 472 additions and 9 deletions

View File

@@ -1010,6 +1010,16 @@ Feature: /forms/chromium/convert/html
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
@rotate
Scenario: POST /forms/chromium/convert/html (Rotate 90)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/html" endpoint with the following form data and header(s):
| files | testdata/page-1-html/index.html | file |
| rotateAngle | 90 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
@embed
Scenario: POST /forms/chromium/convert/html (Embeds)
Given I have a default Gotenberg container

View File

@@ -585,6 +585,16 @@ Feature: /forms/libreoffice/convert
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
@rotate
Scenario: POST /forms/libreoffice/convert (Rotate 90)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/libreoffice/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.docx | file |
| rotateAngle | 90 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
@watermark
Scenario: POST /forms/libreoffice/convert (Native Watermark - Text)
Given I have a default Gotenberg container
@@ -640,9 +650,10 @@ Feature: /forms/libreoffice/convert
@metadata
@watermark
@stamp
@rotate
@flatten
@embed
Scenario: POST /forms/libreoffice/convert (PDF/A-3b & PDF/UA-1 & Metadata & Watermark & Stamp & Flatten & Embeds)
Scenario: POST /forms/libreoffice/convert (PDF/A-3b & PDF/UA-1 & Metadata & Watermark & Stamp & Rotate & Flatten & Embeds)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/libreoffice/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.docx | file |
@@ -653,6 +664,7 @@ Feature: /forms/libreoffice/convert
| watermarkExpression | CONFIDENTIAL | field |
| stampSource | text | field |
| stampExpression | DRAFT | field |
| rotateAngle | 90 | field |
| flatten | true | field |
| embeds | testdata/embed_1.xml | file |
| embeds | testdata/embed_2.xml | file |

View File

@@ -425,6 +425,17 @@ Feature: /forms/pdfengines/merge
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
@rotate
Scenario: POST /forms/pdfengines/merge (Rotate 90)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/merge" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| rotateAngle | 90 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
@embed
Scenario: POST /foo/forms/pdfengines/merge (Embeds)
Given I have a default Gotenberg container
@@ -443,10 +454,11 @@ Feature: /forms/pdfengines/merge
@metadata
@watermark
@stamp
@rotate
@flatten
@embed
@bookmarks
Scenario: POST /forms/pdfengines/merge (PDF/A-3b & PDF/UA-1 & Metadata & Watermark & Stamp & Flatten & Embeds & Bookmarks)
Scenario: POST /forms/pdfengines/merge (PDF/A-3b & PDF/UA-1 & Metadata & Watermark & Stamp & Rotate & Flatten & Embeds & Bookmarks)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/merge" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
@@ -458,6 +470,7 @@ Feature: /forms/pdfengines/merge
| watermarkExpression | CONFIDENTIAL | field |
| stampSource | text | field |
| stampExpression | DRAFT | field |
| rotateAngle | 90 | field |
| bookmarks | [{"title":"Merged Index","page":1}] | field |
| flatten | true | field |
| embeds | testdata/embed_1.xml | file |

View File

@@ -0,0 +1,164 @@
@pdfengines
@pdfengines-rotate
@rotate
Feature: /forms/pdfengines/rotate
Scenario: POST /forms/pdfengines/rotate (90 - All Pages - pdfcpu)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_ROTATE_ENGINES | pdfcpu |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
| rotateAngle | 90 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the "pages_3.pdf" PDF should have 3 page(s)
Scenario: POST /forms/pdfengines/rotate (180 - All Pages - pdfcpu)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_ROTATE_ENGINES | pdfcpu |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| rotateAngle | 180 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the "page_1.pdf" PDF should have 1 page(s)
Scenario: POST /forms/pdfengines/rotate (270 - All Pages - pdfcpu)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_ROTATE_ENGINES | pdfcpu |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| rotateAngle | 270 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the "page_1.pdf" PDF should have 1 page(s)
Scenario: POST /forms/pdfengines/rotate (90 - Specific Pages - pdfcpu)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_ROTATE_ENGINES | pdfcpu |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
| rotateAngle | 90 | field |
| rotatePages | 1,3 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the "pages_3.pdf" PDF should have 3 page(s)
Scenario: POST /forms/pdfengines/rotate (90 - All Pages - pdftk)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_ROTATE_ENGINES | pdftk |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| rotateAngle | 90 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the "page_1.pdf" PDF should have 1 page(s)
Scenario: POST /forms/pdfengines/rotate (Specific Pages - pdftk unsupported)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_ROTATE_ENGINES | pdftk |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
| rotateAngle | 90 | field |
| rotatePages | 1,3 | field |
Then the response status code should be 500
Scenario: POST /forms/pdfengines/rotate (Bad Request - Invalid Angle)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| rotateAngle | 45 | field |
Then the response status code should be 400
Then the response body should contain string:
"""
Invalid form data: form field 'rotateAngle' is invalid
"""
Scenario: POST /forms/pdfengines/rotate (Bad Request - Missing Angle)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
Then the response status code should be 400
Then the response body should match string:
"""
Invalid form data: form field 'rotateAngle' is required
"""
Scenario: POST /forms/pdfengines/rotate (Bad Request - No PDF)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| rotateAngle | 90 | field |
Then the response status code should be 400
Then the response body should match string:
"""
Invalid form data: no form file found for extensions: [.pdf]
"""
Scenario: POST /forms/pdfengines/rotate (Many PDFs)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| rotateAngle | 90 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be 2 PDF(s) in the response
Scenario: POST /forms/pdfengines/rotate (Routes Disabled)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_DISABLE_ROUTES | true |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| rotateAngle | 90 | field |
Then the response status code should be 404
Scenario: POST /forms/pdfengines/rotate (Gotenberg Trace)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| rotateAngle | 90 | field |
| Gotenberg-Trace | forms_pdfengines_rotate | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then the response header "Gotenberg-Trace" should be "forms_pdfengines_rotate"
Then the Gotenberg container should log the following entries:
| "trace":"forms_pdfengines_rotate" |
@webhook
Scenario: POST /forms/pdfengines/rotate (Webhook)
Given I have a default Gotenberg container
Given I have a webhook server
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| rotateAngle | 90 | field |
| Gotenberg-Webhook-Url | http://host.docker.internal:%d/webhook | header |
| Gotenberg-Webhook-Error-Url | http://host.docker.internal:%d/webhook/error | header |
Then the response status code should be 204
When I wait for the asynchronous request to the webhook
Then the webhook request header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the webhook request
Scenario: POST /forms/pdfengines/rotate (Basic Auth)
Given I have a Gotenberg container with the following environment variable(s):
| API_ENABLE_BASIC_AUTH | true |
| GOTENBERG_API_BASIC_AUTH_USERNAME | foo |
| GOTENBERG_API_BASIC_AUTH_PASSWORD | bar |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| rotateAngle | 90 | field |
Then the response status code should be 401
Scenario: POST /foo/forms/pdfengines/rotate (Root Path)
Given I have a Gotenberg container with the following environment variable(s):
| API_ENABLE_DEBUG_ROUTE | true |
| API_ROOT_PATH | /foo/ |
When I make a "POST" request to Gotenberg at the "/foo/forms/pdfengines/rotate" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| rotateAngle | 90 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"

View File

@@ -499,6 +499,18 @@ Feature: /forms/pdfengines/split
Then the response header "Content-Type" should be "application/zip"
Then there should be 2 PDF(s) in the response
@rotate
Scenario: POST /forms/pdfengines/split (Rotate 90)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/split" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
| splitMode | intervals | field |
| splitSpan | 2 | field |
| rotateAngle | 90 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be 2 PDF(s) in the response
@embed
Scenario: POST /foo/forms/pdfengines/split (Embeds)
Given I have a default Gotenberg container
@@ -522,9 +534,10 @@ Feature: /forms/pdfengines/split
@metadata
@watermark
@stamp
@rotate
@flatten
@embed
Scenario: POST /forms/pdfengines/split (PDF/A-3b & PDF/UA-1 & Metadata & Watermark & Stamp & Flatten & Embeds)
Scenario: POST /forms/pdfengines/split (PDF/A-3b & PDF/UA-1 & Metadata & Watermark & Stamp & Rotate & Flatten & Embeds)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/split" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
@@ -537,6 +550,7 @@ Feature: /forms/pdfengines/split
| watermarkExpression | CONFIDENTIAL | field |
| stampSource | text | field |
| stampExpression | DRAFT | field |
| rotateAngle | 90 | field |
| flatten | true | field |
| embeds | testdata/embed_1.xml | file |
| embeds | testdata/embed_2.xml | file |