Skip to content

Commit

Permalink
Merge pull request #47 from lennartb-/develop
Browse files Browse the repository at this point in the history
LGTM @lennartb- THANK YOU FOR THE PR!
  • Loading branch information
Jaben authored Aug 10, 2024
2 parents c9a4187 + 6854915 commit ea062f5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/Domain/Builders/MergeOfficeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ public MergeOfficeBuilder UseNativePdfFormat(PdfFormats format)
this.Request.UseNativePdfFormat = true;
this.Request.Format = format;

return this;
}

/// <summary>
/// This tells gotenberg to enable Universal Access for the resulting PDF.
/// </summary>
[PublicAPI]
public MergeOfficeBuilder EnablePdfUa()
{
this.Request.EnablePdfUa = true;

return this;
}
}
7 changes: 6 additions & 1 deletion lib/Domain/Requests/MergeOfficeRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ protected override string ApiPath
/// Note: the documentation says you can't use both together but that regards request headers.
/// When true and Format is not set, the client falls back to PDF/A-1a.
/// </summary>
public bool UseNativePdfFormat { get; set; }
public bool UseNativePdfFormat { get; set; }

/// <summary>
/// This tells gotenberg to enable Universal Access for the resulting PDF.
/// </summary>
public bool EnablePdfUa { get; set; }

protected override IEnumerable<HttpContent> ToHttpContent()
{
Expand Down
5 changes: 5 additions & 0 deletions lib/Extensions/MergeOfficeRequestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ internal static IEnumerable<HttpContent> PropertiesToHttpContent(this MergeOffic
request.ExportFormFields.Value,
Constants.Gotenberg.LibreOffice.Routes.Convert.ExportFormFields);

if (request.EnablePdfUa)
yield return BuildRequestBase.CreateFormDataItem(
"true",
Constants.Gotenberg.LibreOffice.Routes.Convert.PdfUa);

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

if (!request.UseNativePdfFormat && request.Format != default)
Expand Down
2 changes: 2 additions & 0 deletions lib/Infrastructure/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public static class Convert
public const string PdfFormat = CrossCutting.PdfFormat;

public const string Merge = "merge";

public const string PdfUa = "pdfua";
}
}
}
Expand Down

0 comments on commit ea062f5

Please sign in to comment.