Skip to content

Support Gotenberg 9 alongside 7 and 8 - #95

Merged
Jaben merged 23 commits into
ChangemakerStudios:developfrom
lahma:feature/gotenberg-9
Nov 23, 2026
Merged

Jaben merged 23 commits into
ChangemakerStudios:developfrom
lahma:feature/gotenberg-9

Conversation

@lahma

@lahma lahma commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #83.

One package now serves Gotenberg 7, 8 and 9. The client reads the version of the service once and sends each request with the routes and form fields of that major release, so the same builder code works on all three. Where Gotenberg 9 has no equivalent, the caller gets a GotenbergVersionNotSupportedException before anything is sent, naming what to use instead.

Against 9 the released client fails on almost every call: Gotenberg 9 answers 400 to a form field it does not know, and the client always sends generateDocumentOutline. The PDF engine routes answer 404.

The design questions in #83 are still open. I went ahead with the route I leaned towards there (one package, dispatch on the version) so that there is something concrete to look at. If you would rather go another way, or want this split into several PRs, say so.

How to review

It is large: 23 commits and about 11,700 added lines, of which 6,600 are tests and snapshots and 4,600 are the library. Each commit is one step, builds on its own, and was run against the Gotenberg containers before the next one, so commit by commit is the easy way through. The first two stand alone as fixes for Gotenberg 8; I can send them separately if you want them first.

Commit What it does
31f977f [GotenbergTest] gets an exclusive until version, for tests of what a newer Gotenberg dropped
e4d0aad Stops sending four things no Gotenberg release reads. They are wrong on 8 as well, where the server ignores them
13677df Plumbing, nothing changes on the wire: ApiVersion, rendering a request when it is sent, a shared version cache, and snapshot tests of what every request type sends today
1f2fca5 The Gotenberg 9 names of renamed Chromium and LibreOffice fields, declared with [Gotenberg9Field]
aa22343 Post-processing options become the stages list of Gotenberg 9
e708b95 PDF operations go to forms/pdf/pipe, and the read routes to forms/pdf/metadata and forms/pdf/bookmarks. From here the suite passes on 7, 8 and 9
5ff0173 The file of an image or PDF watermark and stamp can be sent (it could not on 8 either)
c955ea8 The webhook events URL, which Gotenberg 9 requires
c3155fc WithStages and PdfEngineBuilders.Pipe, to list stages directly
a88f684 Five examples compile again; the webhook and watermark examples run on 9
53cc98b Tests run against 9 by default; docs, quick starts and the compose file
a4843f0 The six example projects missing from the solution are added, so CI builds them
1314d76 From the review: a clear error when GET /version fails, and ApiVersion = V9 skips the lookup of the 8.x floors
6c8e066 From the review: a result file name outside printable ASCII is cleaned up instead of refused
753812c From the review: a stamp without its file is refused for Gotenberg 9 like the other removed features, so SupportsAsync agrees
871e42c From the review: StagesBuilder.Rotate takes 90, 180 or 270, like the other rotate methods
810fbcf The shared version cache follows an upgrade or rollback within a major release, not only a new major
8618f93 Cleaning up a result file name cannot throw on .NET Framework
9056f88 An embed relationship is sent to Gotenberg 9 in the form it accepts (data as Data), any other is refused before sending
3d2aeaa SupportsAsync answers false for a request that cannot be rendered for 9: a legacy custom class, or a PDF request with no stage
22cf445 extraLinkTags and extraScriptTags are not sent to Gotenberg 9, which refuses them; neither 8 nor 9 reads them
4b7071c A file a Gotenberg 9 stage names, such as café.png, is found when its name is not ASCII
3a05ce1 The docs say exactly which Gotenberg 8 PDF routes read the post-processing options

Two new docs pages carry the detail: docs/gotenberg-9.md (how the API is picked, what is translated, a table of what differs on 9 and what to do) and docs/stages.md. The "Unreleased" section of CHANGES.MD is the release note.

What changes for a caller on Gotenberg 7 and 8

Requests are unchanged, apart from the fixes of the second commit; snapshot tests written against the old code pin that. A caller notices:

  • One GET /version per service address. ApiVersion is Auto by default, so every application now reads the version once, not only those that use a version-gated route. When it fails with anything but a 404, the request throws a GotenbergApiException that says what Gotenberg answered and to set ApiVersion to V8 or V9, or EnforceMinimumVersion = false when ApiVersion is set already; it keeps the status code, so existing catch blocks still match. ApiVersion = V8 or V9 skips the lookup, and with V9 the gated routes skip it too. The clients of one AddGotenbergSharpClient() registration share the cached version, and the Gotenberg-Version response header refreshes it when the service is upgraded.
  • SetResultFileName takes effect. The name went out as a form field, which Gotenberg never read; it is now the Gotenberg-Output-Filename request header. A name outside printable ASCII is cleaned up before it is sent: accents are stripped (Müller is sent as Muller) and other characters become _.
  • GotenbergVersionNotSupportedException.Requirement and RequiredVersion are nullable: they are null when the exception reports a removed feature (RemovedInVersion, Replacement).
  • A webhook needs an error URL or an events URL, where it needed an error URL.
  • A custom request or facet class that overrides only ToHttpContent() is sent to 7 and 8 exactly as before, and is refused for 9 with a message naming the method to override.

On Gotenberg 9

Translated for you: renamed fields, post-processing options as stages in the order Gotenberg 8 applied them, PDF operations through forms/pdf/pipe, bookmarks (pageNumber), embedded files as attach stages, text, image and PDF stamps.

Refused before sending, with the replacement named: watermarks (9 only draws over the page), stamps with free-form options, image or PDF stamps set without their file, metadata keys outside the eight fields 9 writes, bookmarks written per file, PDF/A together with a password, and a webhook without an events URL. SupportsAsync and EnsureSupportedAsync answer for these too.

New API: WithStages(s => …) on the HTML, URL and merge builders and PdfEngineBuilders.Pipe(s => …), with typed stage methods and Add(op, options) for every other operation; SetEventsUrl; SetImageStamp, SetPdfStamp, SetImageWatermark and SetPdfWatermark.

Everything about Gotenberg 9 comes from its source at 9.5.1 and 8.40.0 and from running against the containers. Two things the source showed that I did not expect: a split by pages wrote one PDF per page on 8, where Gotenberg's upgrade guide says one per range, so it maps to select followed by split with every: 1; and the Chromium routes of 8 never read flatten, so a flatten on an HTML or URL request does nothing on 8 and is applied on 9.

Where I would like your view

  • Post-processing options on the PDF operations. In Gotenberg 8.40.0 the split route reads all of them and the merge route all except the split options; the conversion route reads PDF/A and PDF/UA; flatten, rotate, encrypt, embed and the metadata and bookmark routes read none. On 9 every write operation goes through forms/pdf/pipe and I apply them all, so an EncryptPdfRequest with RotationOptions gets a rotation on 9 and none on 8, and a MergeRequest with SplitOptions returns a zip of PDFs on 9 and one PDF on 8. Dropping them on 9 to match 8 is a small change.
  • SetPosition on a stamp needs Gotenberg 9.4.0 and the client does not check it; 9.0 to 9.3 answer 400.
  • Stage JSON is written in one internal class, StageList, so that Add Native AOT support and replace Newtonsoft.Json with System.Text.Json #82 has one place to change.

Tests

  • dotnet test with no version override now starts Gotenberg 7, 8 and 9 containers: 1145 tests, 1064 passed, 81 skipped by version, 0 failed. Before the first commit the suite had 22 failures on 9 and none on 7 and 8.
  • deploy.yml is unchanged: it runs dotnet test once and the harness starts the three containers. They now run with --api-timeout=5m, because the first Chromium conversion on a freshly started Gotenberg 7 once answered 503 after its default 30 seconds.
  • dotnet build -c Release builds the library for its five target frameworks, the tests and all fifteen examples; dotnet pack still produces only the library package.

Left for the release

I did not touch <PackageReleaseNotes>, the release line of the README or the "Unreleased" heading of CHANGES.MD, since the version number is yours to choose.

lahma added 12 commits November 16, 2026 11:53
…it calls

[GotenbergTest] takes an exclusive 'until' version next to 'since', so a test of a route
or field that Gotenberg 9 removed can skip the servers that no longer have it.
Gotenberg 9 answers 400 to a form field a route does not know; 7 and 8 ignore it.

- Gotenberg-Output-Filename goes out as a request header, the only place Gotenberg
  reads it, so SetResultFileName takes effect. A name that is not printable ASCII is
  rejected before sending.
- Screenshot requests no longer send nativePageRanges.
- LibreOffice requests send merge and nativePageRanges once.
- PDF conversion requests send each PDF once.

Refs ChangemakerStudios#83
Plumbing for Gotenberg 9 support; nothing changes on the wire yet.

- GotenbergApiVersion (Auto, V8, V9) on the options and the client. Auto reads the
  version of the service and picks the API of its major release.
- A request's route, headers and form parts are produced when the message is built,
  through GetApiPath(api) and ToHttpContent(api). A custom request that overrides only
  ToHttpContent() is sent to 7 and 8 as before and refused for 9.
- The clients of one AddGotenbergSharpClient() registration share a version cache per
  service address, refreshed from the Gotenberg-Version response header.
- GotenbergVersionNotSupportedException can report a feature a newer release removed.
- Snapshot tests pin what every request type sends today.

Refs ChangemakerStudios#83
Gotenberg 9 renamed nativePageRanges, generateDocumentOutline and several LibreOffice
fields, and takes the native watermark color as #rrggbb and its rotation in degrees.
[Gotenberg9Field] declares the new name next to the property, and facets render for
an API through ToHttpContent(GotenbergApiVersion). Requests to Gotenberg 7 and 8 are
unchanged.

Chromium conversions and screenshots without post-processing options now pass on
Gotenberg 9.

Refs ChangemakerStudios#83
Gotenberg 9 replaced the flat post-processing fields with one 'stages' field, a JSON
list it runs in the order given. On 9 the client now builds that list from the
existing options, in the order Gotenberg 8 applied them, with metadata before the
PDF/A and PDF/UA remediation and encryption last: merge (LibreOffice), split or
select, stamp-text, rotate, flatten-form, set-metadata, remediate, encrypt.
generateTaggedPdf becomes nativeTaggedPdf.

Options without a faithful equivalent on 9 throw GotenbergVersionNotSupportedException
before anything is sent: watermarks, stamps with free-form options or an image or PDF
source, metadata keys outside the eight fields 9 writes, and PDF/A with a password.
SupportsAsync and EnsureSupportedAsync answer for these as well.

Requests to Gotenberg 7 and 8 are unchanged.

Refs ChangemakerStudios#83
Gotenberg 9 replaced forms/pdfengines/* with forms/pdf/*. On 9 every write
operation (merge, convert, flatten, rotate, split, encrypt, embed, write metadata,
write bookmarks) goes to forms/pdf/pipe as a stage at its place in the stage order,
together with the request's other options; reading metadata and bookmarks goes to
forms/pdf/metadata and forms/pdf/bookmarks.

- Embedded files are uploaded under 'files' with one attach stage each.
- Bookmarks are written with pageNumber and read from page or pageNumber.
- Writing bookmarks per file has no equivalent on 9 and throws
  GotenbergVersionNotSupportedException before anything is sent.
- A PDF conversion without PDF/A or PDF/UA is refused before sending.

Requests to Gotenberg 7 and 8 are unchanged. The whole suite now passes against
Gotenberg 7, 8 and 9.

Refs ChangemakerStudios#83
Gotenberg 8 takes the file of an image or PDF watermark or stamp from the form field
'watermark' or 'stamp', and since 8.32.0 answers 400 without one. The client had no
way to send it, so those sources could not work.

- SetImageWatermark, SetPdfWatermark, SetImageStamp and SetPdfStamp carry the file
  and send it in that field to Gotenberg 7 and 8 (works from 8.28.0, the release
  that added watermarks and stamps).
- On Gotenberg 9 an image or PDF stamp becomes a stamp-image or stamp-pdf stage
  that names the file uploaded under 'files'. Watermarks still have no equivalent
  on 9.
Gotenberg 9 requires Gotenberg-Webhook-Events-Url with the webhook URL and no longer
reads the error URL and error method: errors arrive as webhook.error events.

- WebhookBuilder.SetEventsUrl. A webhook needs an error URL or an events URL.
- Gotenberg 7 and 8 get the headers they always did, plus the events URL when set
  (8.29.0 added it).
- Gotenberg 9 gets the URL, the events URL, the method and the extra headers. A
  webhook without an events URL is refused before anything is sent.

Refs ChangemakerStudios#83
WithStages on the Chromium and merge builders, and PdfEngineBuilders.Pipe for
forms/pdf/pipe, send an explicit stage list: typed methods for merge, split, select,
rotate, the three stamps with position, size and opacity, flatten-form, set-metadata,
set-bookmarks, attach, remediate, encrypt and optimize, and Add for every other
operation of Gotenberg 9.

Explicit stages are sent as listed and do not combine with the options the client
maps to stages. They need Gotenberg 9: against 7 and 8 the request is refused before
anything is sent.

Refs ChangemakerStudios#83
Five examples still used the namespaces of before 3.0 and did not compile; they are
not in the solution, so nothing built them. The webhook example sets the events URL
that Gotenberg 9 requires, and the watermark example stamps through WithStages when
the service is Gotenberg 9, where watermarks have no equivalent.

Refs ChangemakerStudios#83
- The integration tests start Gotenberg 7, 8 and 9, each with a longer API timeout
  so that a cold Chromium start does not fail the first conversion.
- A docs page lists what the client translates for Gotenberg 9 and what differs
  there; the quick starts and the compose file pin gotenberg/gotenberg:9.
- The release notes of the unreleased section read as one note.

Closes ChangemakerStudios#83
Six of the fifteen example projects were not in GotenbergSharpApiClient.sln, so
neither dotnet build nor CI compiled them, and five had stopped compiling unnoticed.
They are packed no more than before: the examples set IsPackable to false.
@molteber

molteber commented Nov 19, 2026 •

Copy link
Copy Markdown

Java4shell vulnerability is a thing now which is flagging gotenberg 8 in our vulnerability scanner. If there is something we can do to speed up this PR to get gotenberg 9 support?

@Jaben

Jaben commented Nov 19, 2026

Copy link
Copy Markdown
Member

Java4shell vulnerability is a thing now which is flagging gotenberg 8 in our vulnerability scanner. If there is something we can do to speed up this PR to get gotenberg 9 support?

Oh that sounds VERY urgent. You should report this to the proper folks who can fix that issue here: https://github.com/gotenberg/gotenberg

@Jaben Jaben left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Supporting 7, 8 and 9 in one package turned out nicer than I expected. I'd like to merge it with two changes:

  1. Failed /version lookups. Caching a successful lookup once per address is fine. When /version fails with a 401, 403 or 5xx, though, the conversion fails with a generic error and the next request tries again. Please throw a clear error there instead, one that tells the user to set ApiVersion = V8 or V9. That covers the case where a proxy blocks /version.

  2. Non-ASCII ResultFileName. Sending it as the header is the right fix, since the form field never did anything. Throwing on non-ASCII means names that used to do nothing quietly now throw on 7 and 8 too. Please clean the name up instead: strip accents (Müller → Muller) and replace any other non-printable ASCII, line breaks included, with _.

With those two in, 7 and 8 users see no breaking change.

A few smaller things came up in review, like SupportsAsync and rendering disagreeing on stamps without a file, and the Rotate angle check. They can come in a follow-up after the merge.

A 401, 403 or 5xx answer to GET /version surfaced as the bare error of a route the
caller never called. It is now a GotenbergApiException that says what Gotenberg
answered, why the client reads the version, and to set ApiVersion to V8 or V9, or
EnforceMinimumVersion to false when ApiVersion is already set; a 401 also points at
the credentials. It keeps the status code and the original as InnerException, so
existing catch blocks still match. The failure is still not cached.

With ApiVersion = V9 the routes with an 8.x minimum release no longer read the
version: a Gotenberg 9 service has them all.
Gotenberg-Output-Filename is a header, which cannot carry characters outside
printable ASCII. Throwing for such a name made requests fail on Gotenberg 7 and 8
that used to send it to no effect. The name is now sent with its accents stripped
(Müller as Muller) and every other such character, line breaks included, replaced
by '_'. ResultFileName keeps the name as it was set.
An image or PDF stamp set with SetSource and an expression naming a file on the
server threw ArgumentException when rendered for Gotenberg 9, while SupportsAsync
answered true. Gotenberg 9 has no way to read a file named on the server, so the
stamp is now refused like the other features it removed:
GotenbergVersionNotSupportedException before anything is sent, naming SetImageStamp
and SetPdfStamp, and SupportsAsync answers false. Gotenberg 7 and 8 are unchanged.
StagesBuilder.Rotate accepted any multiple of 90, 0 and 450 included, while
SetRotationOptions and PdfEngineBuilders.Rotate accept 90, 180 or 270 through
RotationAngle, the rule of Gotenberg 8. Rotate now goes through RotationAngle too,
with an overload that takes one. StagesBuilder is not released yet.
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 152 files, which is 52 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

CodeRabbit couldn't verify your organization's usage billing state, so no usage-priced review was started. Retry after the billing service recovers.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0b04db74-efdf-421c-88b0-52f208a4cc36
Commits

Reviewing files that changed from the base of the PR and between 412e560 and 3a05ce1.

Files selected for processing: 152

  • CHANGES.MD
  • GotenbergSharpApiClient.sln
  • README.md
  • docker/docker-compose-basic-auth.yml
  • docs/advanced-features.md
  • docs/getting-started.md
  • docs/gotenberg-9.md
  • docs/index.md
  • docs/pdf-manipulation.md
  • docs/stages.md
  • examples/ChromiumFeatures/Program.cs
  • examples/EncryptPdf/Program.cs
  • examples/LibreOfficeOptions/Program.cs
  • examples/README.md
  • examples/Screenshot/Program.cs
  • examples/WatermarkAndRotate/Program.cs
  • examples/Webhook/Program.cs
  • mkdocs.yml
  • src/Gotenberg.Sharp.Api.Client/Application/Builders/BaseBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Builders/BaseChromiumBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Builders/BaseMergeBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Builders/PdfEngineBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Builders/UrlRequestBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Overlays/StampOptionsBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Overlays/WatermarkOptionsBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Requests/ConfigBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Stages/EncryptOptionsBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Stages/PdfMetadataBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Stages/StageArguments.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Stages/StagesBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Stages/StampImageOptionsBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Stages/StampPdfOptionsBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Stages/StampStageOptionsBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Stages/StampTextOptionsBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Application/Webhooks/WebhookBuilder.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Bookmarks/Bookmark.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/ExtraUrls/ExtraUrlResources.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/LibreOffice/LibreOfficeOptions.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Overlays/OverlayFile.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Overlays/StampOptions.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Overlays/WatermarkOptions.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Pages/PageProperties.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/PdfOutput/PdfOutputOptions.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/ApiRequests/IVersionedApiRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/ApiRequests/PostApiRequestImpl.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/BuildRequestBase.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/ChromeRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/EmbedRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/EncryptPdfRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/FacetBase.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/FlattenPdfRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/HtmlRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/LegacyContentOverrides.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/MergeOfficeRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/MergeRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/PdfConversionRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/PdfEngineRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/PdfRequestBase.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/PipePdfRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/ReadBookmarksRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/ReadMetadataRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/RequestConfig.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/RotatePdfRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/ScreenshotHtmlRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/ScreenshotRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/ScreenshotUrlRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/SplitPdfRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/UrlRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/WriteBookmarksRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Requests/WriteMetadataRequest.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Settings/GotenbergSharpClientOptions.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Settings/GotenbergSharpClientOptionsValidator.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Shared/GotenbergApiVersion.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Split/SplitOptions.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Stages/ExplicitStages.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Stages/PdfEncryptionAlgorithm.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Stages/PdfPermissions.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Stages/PdfProfile.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Stages/StageList.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Stages/StageMetadata.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Stages/StageValues.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Stages/StampFont.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Stages/StampPosition.cs
  • src/Gotenberg.Sharp.Api.Client/Domain/Webhooks/Webhook.cs
  • src/Gotenberg.Sharp.Api.Client/Extensions/RequestInterfaceExtensions.cs
  • src/Gotenberg.Sharp.Api.Client/Extensions/TypedClientServiceCollectionExtensions.cs
  • src/Gotenberg.Sharp.Api.Client/Gotenberg.Sharp.Api.Client.csproj
  • src/Gotenberg.Sharp.Api.Client/GotenbergSharpClient.cs
  • src/Gotenberg.Sharp.Api.Client/Infrastructure/Constants.cs
  • src/Gotenberg.Sharp.Api.Client/Infrastructure/Gotenberg9FieldAttribute.cs
  • src/Gotenberg.Sharp.Api.Client/Infrastructure/GotenbergApiException.cs
  • src/Gotenberg.Sharp.Api.Client/Infrastructure/GotenbergVersionCache.cs
  • src/Gotenberg.Sharp.Api.Client/Infrastructure/GotenbergVersionNotSupportedException.cs
  • src/Gotenberg.Sharp.Api.Client/Infrastructure/MultiFormPropertyItem.cs
  • test/GotenbergSharpClient.Tests/CrossCuttingOptionsTests.cs
  • test/GotenbergSharpClient.Tests/Gotenberg9PdfRoutesTests.cs
  • test/GotenbergSharpClient.Tests/Gotenberg9RenameTests.cs
  • test/GotenbergSharpClient.Tests/Gotenberg9StagesTests.cs
  • test/GotenbergSharpClient.Tests/GotenbergApiVersionTests.cs
  • test/GotenbergSharpClient.Tests/GotenbergServer.cs
  • test/GotenbergSharpClient.Tests/GotenbergServerSelectionTests.cs
  • test/GotenbergSharpClient.Tests/GotenbergServers.cs
  • test/GotenbergSharpClient.Tests/GotenbergTestAttribute.cs
  • test/GotenbergSharpClient.Tests/GotenbergVersionTests.cs
  • test/GotenbergSharpClient.Tests/OptionsValidationTests.cs
  • test/GotenbergSharpClient.Tests/OverlayFileTests.cs
  • test/GotenbergSharpClient.Tests/PdfEngineOperationsTests.cs
  • test/GotenbergSharpClient.Tests/RenderedRequest.cs
  • test/GotenbergSharpClient.Tests/RetryReplayableBodyTests.cs
  • test/GotenbergSharpClient.Tests/StagesBuilderTests.cs
  • test/GotenbergSharpClient.Tests/StrictFormFieldTests.cs
  • test/GotenbergSharpClient.Tests/WebhookTests.cs
  • test/GotenbergSharpClient.Tests/Wire/V9/cross-cutting.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/engine-cross-cutting.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/engine-embed.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/engine-encrypt.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/engine-flatten.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/engine-read-bookmarks.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/engine-read-metadata.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/engine-rotate.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/engine-split.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/engine-write-bookmarks.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/engine-write-metadata.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/html.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/markdown.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/office-merge.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/pdf-convert.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/pdf-merge.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/screenshot-html.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/screenshot-url.txt
  • test/GotenbergSharpClient.Tests/Wire/V9/url.txt
  • test/GotenbergSharpClient.Tests/Wire/cross-cutting.txt
  • test/GotenbergSharpClient.Tests/Wire/engine-cross-cutting.txt
  • test/GotenbergSharpClient.Tests/Wire/engine-embed.txt
  • test/GotenbergSharpClient.Tests/Wire/engine-encrypt.txt
  • test/GotenbergSharpClient.Tests/Wire/engine-flatten.txt
  • test/GotenbergSharpClient.Tests/Wire/engine-read-bookmarks.txt
  • test/GotenbergSharpClient.Tests/Wire/engine-read-metadata.txt
  • test/GotenbergSharpClient.Tests/Wire/engine-rotate.txt
  • test/GotenbergSharpClient.Tests/Wire/engine-split.txt
  • test/GotenbergSharpClient.Tests/Wire/engine-write-bookmarks-per-file.txt
  • test/GotenbergSharpClient.Tests/Wire/engine-write-bookmarks.txt
  • test/GotenbergSharpClient.Tests/Wire/engine-write-metadata.txt
  • test/GotenbergSharpClient.Tests/Wire/html.txt
  • test/GotenbergSharpClient.Tests/Wire/markdown.txt
  • test/GotenbergSharpClient.Tests/Wire/office-merge.txt
  • test/GotenbergSharpClient.Tests/Wire/pdf-convert.txt
  • test/GotenbergSharpClient.Tests/Wire/pdf-merge.txt
  • test/GotenbergSharpClient.Tests/Wire/screenshot-html.txt
  • test/GotenbergSharpClient.Tests/Wire/screenshot-url.txt
  • test/GotenbergSharpClient.Tests/Wire/url.txt
  • test/GotenbergSharpClient.Tests/WireCharacterisationTests.cs

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@lahma

lahma commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Both changes are in, and so are the two smaller points, since they were small:

  1. Failed /version lookups (1314d76). A 401, 403 or 5xx now throws a GotenbergApiException whose message says what Gotenberg answered to GET /version, why the client reads it, and to set ApiVersion to V8 or V9.
    • With ApiVersion already set, the lookup only happens for a route with a minimum release, so that message names EnforceMinimumVersion = false instead.
    • A 401 also points at the credentials, since the conversion would fail the same way.
    • I kept the type: GotenbergApiException is sealed, and a new type would break existing catch blocks. It keeps the status code and has the original as InnerException.
    • A failure is still not cached, so one transient 5xx doesn't disable the client for its lifetime.
    • ApiVersion = V9 now also skips the lookup of the routes with a minimum release. Every floor is an 8.x release, so with V9 the client never reads /version, and the advice in the message is complete on Gotenberg 9.
  2. Non-ASCII ResultFileName (6c8e066). It no longer throws: accents are stripped (Müller is sent as Muller), and everything else outside printable ASCII, line breaks included, becomes _. A letter with no accent to strip, such as ß or ł, becomes _ too. An integration test checks that Gotenberg 8 and 9 return Muller.pdf.
  3. Stamps without a file (753812c). For Gotenberg 9 they are now refused by the same check as the other removed features, so SupportsAsync answers false, EnsureSupportedAsync throws, and nothing is sent. Gotenberg 7 and 8 are unchanged.
  4. The Rotate angle check (871e42c). I wasn't sure which part you meant, so here is what I changed. StagesBuilder.Rotate accepted any multiple of 90, 0 and 450 included, while SetRotationOptions and PdfEngineBuilders.Rotate take 90, 180 or 270 through RotationAngle, Gotenberg 8's rule. Rotate now goes through RotationAngle as well. If you meant something else, tell me.

The review mentions a few smaller things "like" these two. If there are others, list them and I'll add them here or in a follow-up, whichever you prefer.

The suite passes against Gotenberg 7, 8 and 9 (1116 tests, 0 failed), and I updated the PR description and CHANGES.MD to match.

The shared version cache replaced its version only when a response
reported another major release. A service upgraded in place from 8.20.0
to 8.30.0 kept a gated route such as rotate refused until the application
restarted, and a rollback sent requests that answered with a bare 404.
The cache now takes the version of any response that differs from the
cached one, an unknown cached version included.
…ework

A result file name with a noncharacter (U+FFFF, U+FFFE, U+FDD0) or an
unassigned code point threw ArgumentException ("Invalid Unicode code
point found") on .NET Framework, which refuses to normalize them; .NET 5
and later returned them unchanged. Such characters now skip the
normalization and give "_" on every runtime, and an ArgumentException
from Normalize does the same.
…0 to

Gotenberg 8 wrote the relationship of an embedded file as given, so
"data" or any string worked. The attach stage of Gotenberg 9 takes only
Source, Data, Alternative, Supplement and Unspecified and compares them
case-sensitively. On 9 Embed now sends one of the five in another case in
its canonical form and refuses any other value before sending, naming the
five; StagesBuilder.Attach accepts the five in any case the same way.
Requests to 7 and 8 are unchanged.
SupportsAsync said true for a request that then threw
InvalidOperationException when sent to Gotenberg 9: a class that
overrides only ToHttpContent(), or a PDF operation with no stage to run
(WriteMetadata with every value null), which Gotenberg 9 answers 400
"stages is required". One check, BuildRequestBase.FindUnrenderableOn,
now decides both; rendering throws what it returns, and SupportsAsync and
EnsureSupportedAsync answer with it. Every request for the pipe route
refuses an empty list with a message naming what is missing.
Requests to 7 and 8 are unchanged.
A URL request with AddExtraResources answered 400 on Gotenberg 9, whose
URL route refuses form fields it does not know. Gotenberg 8.40 and 9.5
read neither field, so Gotenberg 8 ignored them. They are no longer sent
to 9, which converts the page as 8 did; 7 and 8 still receive them.
The docs of AddExtraResources and the Gotenberg 9 table say so.
A stamp image "café.png" or an embedded "données.xml" was answered 400
("form file 'café.png' is required"): .NET writes a file name outside
ASCII as an RFC 2047 encoded word, which Go's multipart reader keeps as
text, so the stage could not find its file. Files that a stage reads now
go as filename* (RFC 5987), which Go decodes. Requests to 7 and 8 and
ASCII names are written as before. The check that refuses a stage file
named like another upload sees such names too.
…ions

The docs said Gotenberg 8 read the post-processing options on the merge
and split routes only. In 8.40 the merge route reads every one of them
except the split options, the split route reads them all, the conversion
route reads PDF/A and PDF/UA, and the other PDF routes read none. On 9
the client applies them to every PDF operation, so a merge with split
options returns a zip there and one PDF on 8. The release note and the
Gotenberg 9 table now state that.
@lahma

lahma commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

While waiting I went through the library code once more and found a few more things, now fixed in seven commits on top (the commit table in the description has them):

  • The shared version cache now follows an upgrade or rollback within a major release (810fbcf). Under DI the cache lives as long as the application, and it was replaced only when another major answered. An in-place upgrade from 8.20 to 8.30 then kept a route that needs 8.28 refused until a restart. Before this PR each transient client read /version again, so this was a regression.
  • Cleaning up ResultFileName cannot throw on .NET Framework (8618f93). There Normalize throws for noncharacters such as U+FFFF; they now become _ on every runtime.
  • Embed relationships (9056f88). Gotenberg 8 writes any string, Gotenberg 9 accepts only Source, Data, Alternative, Supplement and Unspecified. On 9 a value is sent in that form regardless of case (data as Data), and any other is refused before sending.
  • SupportsAsync agrees with the send in two more cases (3d2aeaa): a custom request or facet class that overrides only ToHttpContent(), and a PDF request that ends up with no stage, such as WriteMetadata with every value null, which Gotenberg 9 answers 400 to.
  • extraLinkTags and extraScriptTags are not sent to Gotenberg 9 (22cf445). Neither 8.40.0 nor 9.5.1 reads them, and 9 answers 400 to a field it does not know.
  • Stage file names that are not ASCII (4b7071c). Against a real Gotenberg 9, StampImage("café.png", …) and an embedded données.xml answered 400 "form file 'café.png' is required": .NET writes such a name as an RFC 2047 encoded word, which Gotenberg does not match. Those files now carry filename* (RFC 5987), and all three cases pass against the container.
  • The docs said Gotenberg 8's merge and split routes read the post-processing options (3a05ce1). The merge route reads all of them except split. So a MergeRequest with SplitOptions gives one PDF on 8 and a zip on 9. That follows the open question in the description, which I've corrected accordingly.

Apart from the file-name fix, the requests sent to Gotenberg 7 and 8 are unchanged; their wire snapshots pass as they were. The suite passes against 7, 8 and 9: 1145 tests, 0 failed.

@Jaben
Jaben merged commit 55259fa into ChangemakerStudios:develop Nov 23, 2026
2 checks passed
Jaben added a commit to chrisbbe/GotenbergSharpApiClient that referenced this pull request Nov 23, 2026
Brings in ChangemakerStudios#95 (Gotenberg 9 support). Its stage code still used Newtonsoft.Json, so this merge also ports it: StageList writes the stages with JsonObjectWriter, StageMetadata reads metadata from the dictionary types, and StagesBuilder.Add takes an IDictionary<string, object> or a JsonObject instead of an anonymous object or a JObject. Bookmark reads the pageNumber of Gotenberg 9 with System.Text.Json, and LegacyContentOverrides keeps its reflection trim-safe. The tests parse JSON with System.Text.Json.Nodes, and the wire snapshots are updated for compact JSON.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Gotenberg 9

3 participants