1- // Copyright 2019-2025 Chris Mohan, Jaben Cargman
1+ // Copyright 2019-2025 Chris Mohan, Jaben Cargman
22// and GotenbergSharpApiClient Contributors
3- //
3+ //
44// Licensed under the Apache License, Version 2.0 (the "License");
55// you may not use this file except in compliance with the License.
66// You may obtain a copy of the License at
7- //
7+ //
88// http://www.apache.org/licenses/LICENSE-2.0
9- //
9+ //
1010// Unless required by applicable law or agreed to in writing, software
1111// distributed under the License is distributed on an "AS IS" BASIS,
1212// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,8 +19,12 @@ namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted;
1919
2020/// <summary>
2121/// Configures Chromium rendering behaviors for HTML and URL to PDF conversions.
22- /// Includes settings for wait delays, HTTP headers, cookies, metadata, PDF format , and accessibility .
22+ /// Includes settings for wait delays, HTTP headers, cookies, media emulation , and error handling .
2323/// </summary>
24+ /// <remarks>
25+ /// PDF output options (PDF/A, PDF/UA, flatten, tagged PDF, metadata) have moved to
26+ /// <see cref="PdfOutputOptionsBuilder"/> which is available via <c>SetPdfOutputOptions()</c> on all builders.
27+ /// </remarks>
2428public sealed class HtmlConversionBehaviorBuilder
2529{
2630 private readonly HtmlConversionBehaviors _htmlConversionBehaviors ;
@@ -137,39 +141,6 @@ public HtmlConversionBehaviorBuilder AddCookie(Cookie cookie)
137141 return this ;
138142 }
139143
140- /// <summary>
141- /// Sets the document metadata.
142- /// Not all metadata are writable. Consider taking a look at https://exiftool.org/TagNames/XMP.html#pdf for an
143- /// (exhaustive?) list of available metadata.
144- /// </summary>
145- /// <param name="dictionary"></param>
146- /// <returns></returns>
147- public HtmlConversionBehaviorBuilder SetMetadata ( IDictionary < string , object > dictionary )
148- {
149- SetMetadata ( JObject . FromObject ( dictionary ) ) ;
150-
151- return this ;
152- }
153-
154- /// <summary>
155- /// Sets the document metadata.
156- /// Not all metadata are writable. Consider taking a look at https://exiftool.org/TagNames/XMP.html#pdf for an
157- /// (exhaustive?) list of available metadata.
158- /// </summary>
159- /// <param name="metadata"></param>
160- /// <returns></returns>
161- public HtmlConversionBehaviorBuilder SetMetadata ( JObject metadata )
162- {
163- if ( metadata == null )
164- {
165- throw new InvalidOperationException ( "metadata is null" ) ;
166- }
167-
168- _htmlConversionBehaviors . MetaData = metadata ;
169-
170- return this ;
171- }
172-
173144 /// <summary>
174145 /// Tells gotenberg to return a 409 response if there are exceptions in the Chromium console.
175146 /// </summary>
@@ -204,40 +175,47 @@ public HtmlConversionBehaviorBuilder SkipNetworkIdleEvent()
204175 }
205176
206177 /// <summary>
207- /// Sets the format of the resulting PDF document
178+ /// Sets the format of the resulting PDF document.
208179 /// </summary>
209- /// <param name="format"></param>
210- /// <returns></returns>
211- /// <exception cref="InvalidOperationException"></exception>
180+ [ Obsolete ( "Use SetPdfOutputOptions(o => o.SetPdfFormat(...)) on the builder instead" ) ]
212181 public HtmlConversionBehaviorBuilder SetPdfFormat ( ConversionPdfFormats format )
213182 {
214- if ( format == default )
215- {
216- throw new InvalidOperationException ( "Invalid PDF format specified" ) ;
217- }
218-
219- _htmlConversionBehaviors . PdfFormat = format ;
220-
221183 return this ;
222184 }
223185
224186 /// <summary>
225187 /// This tells gotenberg to enable Universal Access for the resulting PDF.
226188 /// </summary>
189+ [ Obsolete ( "Use SetPdfOutputOptions(o => o.SetPdfUa()) on the builder instead" ) ]
227190 public HtmlConversionBehaviorBuilder SetPdfUa ( bool enablePdfUa = true )
228191 {
229- _htmlConversionBehaviors . EnablePdfUa = enablePdfUa ;
230-
231192 return this ;
232193 }
233194
234195 /// <summary>
235196 /// This tells gotenberg to enable embeds logical structure tags for accessibility during generation.
236197 /// </summary>
198+ [ Obsolete ( "Use SetPdfOutputOptions(o => o.SetGenerateTaggedPdf()) on the builder instead" ) ]
237199 public HtmlConversionBehaviorBuilder SetGenerateTaggedPdf ( bool generateTaggedPdf = true )
238200 {
239- _htmlConversionBehaviors . GenerateTaggedPdf = generateTaggedPdf ;
201+ return this ;
202+ }
203+
204+ /// <summary>
205+ /// Sets the document metadata.
206+ /// </summary>
207+ [ Obsolete ( "Use SetPdfOutputOptions(o => o.SetMetadata(...)) on the builder instead" ) ]
208+ public HtmlConversionBehaviorBuilder SetMetadata ( IDictionary < string , object > dictionary )
209+ {
210+ return this ;
211+ }
240212
213+ /// <summary>
214+ /// Sets the document metadata.
215+ /// </summary>
216+ [ Obsolete ( "Use SetPdfOutputOptions(o => o.SetMetadata(...)) on the builder instead" ) ]
217+ public HtmlConversionBehaviorBuilder SetMetadata ( JObject metadata )
218+ {
241219 return this ;
242220 }
243- }
221+ }
0 commit comments