Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for PDF/UA form field #47

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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