Skip to content

Commit d93cf64

Browse files
committed
Added Export Form Fields support for convert endpoint. Closes #44.
1 parent ad7bb47 commit d93cf64

5 files changed

Lines changed: 46 additions & 2 deletions

File tree

lib/Domain/Builders/MergeOfficeBuilder.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Gotenberg.Sharp.API.Client.Domain.Builders;
2323
/// <summary>
2424
/// Any non office files sent in are just ignored.
2525
/// A nice surprise: Gotenberg/Chrome will merge in all sheets within a multi-sheet excel workbook.
26-
/// If you send in a csv file but with an xlsx extension, it will merge it in as text.
26+
/// If you send in a csv file but with a xlsx extension, it will merge it in as text.
2727
/// </summary>
2828
public sealed class MergeOfficeBuilder : BaseMergeBuilder<MergeOfficeRequest, MergeOfficeBuilder>
2929
{
@@ -39,12 +39,33 @@ public MergeOfficeBuilder PrintAsLandscape()
3939
return this;
4040
}
4141

42+
/// <summary>
43+
/// If provided, the API will return a pdf containing the pages in the specified range.
44+
/// </summary>
45+
/// <remarks>
46+
/// The format is the same as the one from the print options of Google Chrome, e.g. 1-5,8,11-13.
47+
/// This may move...
48+
/// </remarks>
4249
[PublicAPI]
4350
public MergeOfficeBuilder SetPageRanges(string pageRanges)
4451
{
4552
this.Request.PageRanges = pageRanges;
4653
return this;
4754
}
55+
56+
/// <summary>
57+
/// Set whether to export the form fields or to use the inputted/selected
58+
/// content of the fields. Default is TRUE.
59+
/// </summary>
60+
/// <remarks>
61+
/// Gotenberg v8.3+
62+
/// </remarks>
63+
[PublicAPI]
64+
public MergeOfficeBuilder SetExportFormFields(bool exportFormFields)
65+
{
66+
this.Request.ExportFormFields = exportFormFields;
67+
return this;
68+
}
4869

4970
/// <summary>
5071
/// This tells gotenberg to use unoconv to perform the conversion.

lib/Domain/Requests/Facets/RequestConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void Validate()
7979
/// <remarks>
8080
/// Attention: this feature does not work if the form field webHookURL is given.
8181
/// </remarks>
82-
// Not sure this is useful with the way this client is used, although.. maybe Webhook requests honor it?
82+
// Not sure if this is useful with the way this client is used, although.. maybe Webhook requests honor it?
8383
public string? ResultFileName { get; set; }
8484

8585
/// <summary>

lib/Domain/Requests/MergeOfficeRequest.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,23 @@ protected override string ApiPath
3535

3636
public bool PrintAsLandscape { get; set; }
3737

38+
/// <summary>
39+
/// If provided, the API will return a pdf containing the pages in the specified range.
40+
/// </summary>
41+
/// <remarks>
42+
/// The format is the same as the one from the print options of Google Chrome, e.g. 1-5,8,11-13.
43+
/// This may move...
44+
/// </remarks>
3845
public string? PageRanges { get; set; }
46+
47+
/// <summary>
48+
/// Set whether to export the form fields or to use the inputted/selected
49+
/// content of the fields. Default is TRUE.
50+
/// </summary>
51+
/// <remarks>
52+
/// Gotenberg v8.3+
53+
/// </remarks>
54+
public bool? ExportFormFields { get; set; }
3955

4056
/// <summary>
4157
/// Tells gotenberg to perform the conversion with unoconv.

lib/Extensions/MergeOfficeRequestExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ internal static IEnumerable<HttpContent> PropertiesToHttpContent(this MergeOffic
3434
yield return BuildRequestBase.CreateFormDataItem(
3535
request.PageRanges,
3636
Constants.Gotenberg.LibreOffice.Routes.Convert.PageRanges);
37+
38+
if (request.ExportFormFields.HasValue)
39+
yield return BuildRequestBase.CreateFormDataItem(
40+
request.ExportFormFields.Value,
41+
Constants.Gotenberg.LibreOffice.Routes.Convert.ExportFormFields);
3742

3843
if (!request.UseNativePdfFormat && request.Format == default) yield break;
3944

lib/Infrastructure/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public static class Convert
9999
public const string Landscape = CrossCutting.Landscape;
100100

101101
public const string PageRanges = CrossCutting.PageRanges;
102+
103+
public const string ExportFormFields = "exportFormFields";
102104

103105
public const string NativePdfFormat = "nativePdfFormat";
104106

0 commit comments

Comments
 (0)