From ec17cdc24818b3848e512f529214a2f46590fadc Mon Sep 17 00:00:00 2001 From: Jaben Cargman Date: Sun, 9 Feb 2025 20:05:29 -0500 Subject: [PATCH 1/5] Housekeeping -- copyright updated. --- lib/Domain/Builders/BaseBuilder.cs | 2 +- lib/Domain/Builders/BaseChromiumBuilder.cs | 2 +- lib/Domain/Builders/BaseMergeBuilder.cs | 2 +- lib/Domain/Builders/Faceted/AssetBuilder.cs | 2 +- lib/Domain/Builders/Faceted/ConfigBuilder.cs | 8 +- lib/Domain/Builders/Faceted/Margins.cs | 2 +- lib/Domain/Builders/Faceted/PaperSizes.cs | 2 +- lib/Domain/Builders/Faceted/PdfFormats.cs | 2 +- .../Faceted/UrlExtraResourcesBuilder.cs | 2 +- .../Faceted/UrlHeaderFooterBuilder.cs | 2 +- lib/Domain/Builders/Faceted/WebhookBuilder.cs | 2 +- lib/Domain/Builders/MergeBuilder.cs | 2 +- lib/Domain/Builders/MergeOfficeBuilder.cs | 2 +- lib/Domain/Builders/PdfConversionBuilder.cs | 2 +- lib/Domain/Builders/UrlRequestBuilder.cs | 2 +- .../ContentTypes/IResolveContentType.cs | 2 +- .../Requests/ApiRequests/IApiRequest.cs | 2 +- lib/Domain/Requests/BuildRequestBase.cs | 2 +- lib/Domain/Requests/ChromeRequest.cs | 2 +- lib/Domain/Requests/Facets/AssetDictionary.cs | 2 +- lib/Domain/Requests/Facets/ContentItem.cs | 2 +- .../Requests/Facets/ExtraHttpHeaders.cs | 2 +- lib/Domain/Requests/Facets/FullDocument.cs | 2 +- .../Requests/Facets/HeaderFooterDocument.cs | 2 +- .../Facets/HtmlConversionBehaviors.cs | 2 +- lib/Domain/Requests/Facets/RequestConfig.cs | 2 +- .../Facets/UrlExtras/ExtraUrlResourceItem.cs | 2 +- .../Facets/UrlExtras/ExtraUrlResourceType.cs | 2 +- .../Facets/UrlExtras/ExtraUrlResources.cs | 2 +- lib/Domain/Requests/Facets/Webhook.cs | 2 +- lib/Domain/Requests/HtmlRequest.cs | 2 +- lib/Domain/Requests/IConvertToHttpContent.cs | 2 +- lib/Domain/Requests/MergeOfficeConstants.cs | 2 +- lib/Domain/Requests/MergeOfficeRequest.cs | 2 +- lib/Domain/Requests/MergeRequest.cs | 2 +- lib/Domain/Requests/PdfConversionRequest.cs | 2 +- lib/Domain/Requests/UrlRequest.cs | 2 +- lib/Extensions/DictionaryExtensions.cs | 2 +- lib/Extensions/EnumExtensions.cs | 2 +- lib/Extensions/EnumerableExtensions.cs | 2 +- lib/Extensions/HttpRequestExtensions.cs | 2 +- lib/Extensions/IntExtensions.cs | 2 +- lib/Extensions/KeyValuePairExtensions.cs | 2 +- .../MergeOfficeRequestExtensions.cs | 2 +- lib/Extensions/RequestInterfaceExtensions.cs | 76 +++++++++---------- lib/Extensions/StringExtensions.cs | 2 +- .../TypedClientServiceCollectionExtensions.cs | 3 +- .../ValidOfficeMergeItemExtensions.cs | 2 +- lib/GlobalUsings.cs | 2 +- lib/GotenbergSharpClient.cs | 2 +- lib/Infrastructure/Constants.cs | 2 +- .../ResolveContentTypeImplementation.cs | 2 +- lib/Infrastructure/GotenbergApiException.cs | 2 +- .../MultiFormHeaderAttribute.cs | 2 +- lib/Infrastructure/MultiFormPropertyItem.cs | 2 +- .../MultiTargetHelpers/KeyValuePair.cs | 2 +- lib/Infrastructure/Pipeline/PolicyFactory.cs | 2 +- lib/Infrastructure/Pipeline/TimeoutHandler.cs | 2 +- lib/Infrastructure/ValidOfficeMergeItem.cs | 2 +- 59 files changed, 95 insertions(+), 104 deletions(-) diff --git a/lib/Domain/Builders/BaseBuilder.cs b/lib/Domain/Builders/BaseBuilder.cs index 99bb021..389f9e7 100644 --- a/lib/Domain/Builders/BaseBuilder.cs +++ b/lib/Domain/Builders/BaseBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/BaseChromiumBuilder.cs b/lib/Domain/Builders/BaseChromiumBuilder.cs index 0fbcecf..29f53d1 100644 --- a/lib/Domain/Builders/BaseChromiumBuilder.cs +++ b/lib/Domain/Builders/BaseChromiumBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/BaseMergeBuilder.cs b/lib/Domain/Builders/BaseMergeBuilder.cs index ea0f959..18fe674 100644 --- a/lib/Domain/Builders/BaseMergeBuilder.cs +++ b/lib/Domain/Builders/BaseMergeBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/Faceted/AssetBuilder.cs b/lib/Domain/Builders/Faceted/AssetBuilder.cs index 5382f75..1b7dc5e 100644 --- a/lib/Domain/Builders/Faceted/AssetBuilder.cs +++ b/lib/Domain/Builders/Faceted/AssetBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/Faceted/ConfigBuilder.cs b/lib/Domain/Builders/Faceted/ConfigBuilder.cs index 9e0cd38..ce234a6 100644 --- a/lib/Domain/Builders/Faceted/ConfigBuilder.cs +++ b/lib/Domain/Builders/Faceted/ConfigBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,8 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - - namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted; public sealed class ConfigBuilder @@ -61,7 +59,6 @@ public ConfigBuilder ResultFileName(string resultFileName) { return this.SetResultFileName(resultFileName); } - public ConfigBuilder SetTrace(string trace) { @@ -73,7 +70,6 @@ public ConfigBuilder SetTrace(string trace) return this; } - public ConfigBuilder AddWebhook(Action action) { if (action == null) throw new ArgumentNullException(nameof(action)); @@ -85,14 +81,12 @@ public ConfigBuilder AddWebhook(Action action) return this; } - public ConfigBuilder SetWebhook(Webhook webhook) { this._requestConfig.Webhook = webhook ?? throw new ArgumentNullException(nameof(webhook)); return this; } - [Obsolete("Renamed: Use SetWebhook instead.")] public ConfigBuilder AddWebhook(Webhook webhook) diff --git a/lib/Domain/Builders/Faceted/Margins.cs b/lib/Domain/Builders/Faceted/Margins.cs index f1063ae..11b5151 100644 --- a/lib/Domain/Builders/Faceted/Margins.cs +++ b/lib/Domain/Builders/Faceted/Margins.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/Faceted/PaperSizes.cs b/lib/Domain/Builders/Faceted/PaperSizes.cs index 8f78dac..423825b 100644 --- a/lib/Domain/Builders/Faceted/PaperSizes.cs +++ b/lib/Domain/Builders/Faceted/PaperSizes.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/Faceted/PdfFormats.cs b/lib/Domain/Builders/Faceted/PdfFormats.cs index 499d62f..ac8465f 100644 --- a/lib/Domain/Builders/Faceted/PdfFormats.cs +++ b/lib/Domain/Builders/Faceted/PdfFormats.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/Faceted/UrlExtraResourcesBuilder.cs b/lib/Domain/Builders/Faceted/UrlExtraResourcesBuilder.cs index 62482b6..8c46777 100644 --- a/lib/Domain/Builders/Faceted/UrlExtraResourcesBuilder.cs +++ b/lib/Domain/Builders/Faceted/UrlExtraResourcesBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/Faceted/UrlHeaderFooterBuilder.cs b/lib/Domain/Builders/Faceted/UrlHeaderFooterBuilder.cs index e84cd5b..059eaf1 100644 --- a/lib/Domain/Builders/Faceted/UrlHeaderFooterBuilder.cs +++ b/lib/Domain/Builders/Faceted/UrlHeaderFooterBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/Faceted/WebhookBuilder.cs b/lib/Domain/Builders/Faceted/WebhookBuilder.cs index 2d1d449..d995584 100644 --- a/lib/Domain/Builders/Faceted/WebhookBuilder.cs +++ b/lib/Domain/Builders/Faceted/WebhookBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/MergeBuilder.cs b/lib/Domain/Builders/MergeBuilder.cs index 327521c..8d2c1ad 100644 --- a/lib/Domain/Builders/MergeBuilder.cs +++ b/lib/Domain/Builders/MergeBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/MergeOfficeBuilder.cs b/lib/Domain/Builders/MergeOfficeBuilder.cs index f3fb46a..52ffa6d 100644 --- a/lib/Domain/Builders/MergeOfficeBuilder.cs +++ b/lib/Domain/Builders/MergeOfficeBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/PdfConversionBuilder.cs b/lib/Domain/Builders/PdfConversionBuilder.cs index bc4ede1..2f682ef 100644 --- a/lib/Domain/Builders/PdfConversionBuilder.cs +++ b/lib/Domain/Builders/PdfConversionBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Builders/UrlRequestBuilder.cs b/lib/Domain/Builders/UrlRequestBuilder.cs index b4b2d1d..c50afdc 100644 --- a/lib/Domain/Builders/UrlRequestBuilder.cs +++ b/lib/Domain/Builders/UrlRequestBuilder.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/ContentTypes/IResolveContentType.cs b/lib/Domain/ContentTypes/IResolveContentType.cs index 9272b51..3009838 100644 --- a/lib/Domain/ContentTypes/IResolveContentType.cs +++ b/lib/Domain/ContentTypes/IResolveContentType.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/ApiRequests/IApiRequest.cs b/lib/Domain/Requests/ApiRequests/IApiRequest.cs index c42777c..2089cf7 100644 --- a/lib/Domain/Requests/ApiRequests/IApiRequest.cs +++ b/lib/Domain/Requests/ApiRequests/IApiRequest.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/BuildRequestBase.cs b/lib/Domain/Requests/BuildRequestBase.cs index a5b777e..5e955e9 100644 --- a/lib/Domain/Requests/BuildRequestBase.cs +++ b/lib/Domain/Requests/BuildRequestBase.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/ChromeRequest.cs b/lib/Domain/Requests/ChromeRequest.cs index 23ce361..189503d 100644 --- a/lib/Domain/Requests/ChromeRequest.cs +++ b/lib/Domain/Requests/ChromeRequest.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/Facets/AssetDictionary.cs b/lib/Domain/Requests/Facets/AssetDictionary.cs index 4fb2ae6..c19d646 100644 --- a/lib/Domain/Requests/Facets/AssetDictionary.cs +++ b/lib/Domain/Requests/Facets/AssetDictionary.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/Facets/ContentItem.cs b/lib/Domain/Requests/Facets/ContentItem.cs index 418d398..1d21cdc 100644 --- a/lib/Domain/Requests/Facets/ContentItem.cs +++ b/lib/Domain/Requests/Facets/ContentItem.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/Facets/ExtraHttpHeaders.cs b/lib/Domain/Requests/Facets/ExtraHttpHeaders.cs index d4752fa..e1c23b5 100644 --- a/lib/Domain/Requests/Facets/ExtraHttpHeaders.cs +++ b/lib/Domain/Requests/Facets/ExtraHttpHeaders.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/Facets/FullDocument.cs b/lib/Domain/Requests/Facets/FullDocument.cs index 25094e3..e46a69b 100644 --- a/lib/Domain/Requests/Facets/FullDocument.cs +++ b/lib/Domain/Requests/Facets/FullDocument.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/Facets/HeaderFooterDocument.cs b/lib/Domain/Requests/Facets/HeaderFooterDocument.cs index 32a40a6..1d623bf 100644 --- a/lib/Domain/Requests/Facets/HeaderFooterDocument.cs +++ b/lib/Domain/Requests/Facets/HeaderFooterDocument.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/Facets/HtmlConversionBehaviors.cs b/lib/Domain/Requests/Facets/HtmlConversionBehaviors.cs index 75854c4..acf070d 100644 --- a/lib/Domain/Requests/Facets/HtmlConversionBehaviors.cs +++ b/lib/Domain/Requests/Facets/HtmlConversionBehaviors.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/Facets/RequestConfig.cs b/lib/Domain/Requests/Facets/RequestConfig.cs index 6dbd48d..31c327c 100644 --- a/lib/Domain/Requests/Facets/RequestConfig.cs +++ b/lib/Domain/Requests/Facets/RequestConfig.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResourceItem.cs b/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResourceItem.cs index 438cfa7..f63a1c5 100644 --- a/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResourceItem.cs +++ b/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResourceItem.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResourceType.cs b/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResourceType.cs index 3d5633b..9b1ce97 100644 --- a/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResourceType.cs +++ b/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResourceType.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResources.cs b/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResources.cs index 9ba57d2..0c2a3e8 100644 --- a/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResources.cs +++ b/lib/Domain/Requests/Facets/UrlExtras/ExtraUrlResources.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/Facets/Webhook.cs b/lib/Domain/Requests/Facets/Webhook.cs index 7640819..140d06b 100644 --- a/lib/Domain/Requests/Facets/Webhook.cs +++ b/lib/Domain/Requests/Facets/Webhook.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/HtmlRequest.cs b/lib/Domain/Requests/HtmlRequest.cs index 1fccf1f..72ee4d2 100644 --- a/lib/Domain/Requests/HtmlRequest.cs +++ b/lib/Domain/Requests/HtmlRequest.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/IConvertToHttpContent.cs b/lib/Domain/Requests/IConvertToHttpContent.cs index ed7cfd6..0b17eb7 100644 --- a/lib/Domain/Requests/IConvertToHttpContent.cs +++ b/lib/Domain/Requests/IConvertToHttpContent.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/MergeOfficeConstants.cs b/lib/Domain/Requests/MergeOfficeConstants.cs index 2982c08..cae8ec4 100644 --- a/lib/Domain/Requests/MergeOfficeConstants.cs +++ b/lib/Domain/Requests/MergeOfficeConstants.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/MergeOfficeRequest.cs b/lib/Domain/Requests/MergeOfficeRequest.cs index d01308f..24d3faf 100644 --- a/lib/Domain/Requests/MergeOfficeRequest.cs +++ b/lib/Domain/Requests/MergeOfficeRequest.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/MergeRequest.cs b/lib/Domain/Requests/MergeRequest.cs index dc284f2..b17a1a2 100644 --- a/lib/Domain/Requests/MergeRequest.cs +++ b/lib/Domain/Requests/MergeRequest.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/PdfConversionRequest.cs b/lib/Domain/Requests/PdfConversionRequest.cs index 68b2df2..8cf51ef 100644 --- a/lib/Domain/Requests/PdfConversionRequest.cs +++ b/lib/Domain/Requests/PdfConversionRequest.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Domain/Requests/UrlRequest.cs b/lib/Domain/Requests/UrlRequest.cs index dc87715..6dc6070 100644 --- a/lib/Domain/Requests/UrlRequest.cs +++ b/lib/Domain/Requests/UrlRequest.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Extensions/DictionaryExtensions.cs b/lib/Extensions/DictionaryExtensions.cs index 2f0b187..606d455 100644 --- a/lib/Extensions/DictionaryExtensions.cs +++ b/lib/Extensions/DictionaryExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Extensions/EnumExtensions.cs b/lib/Extensions/EnumExtensions.cs index 43528d6..f753275 100644 --- a/lib/Extensions/EnumExtensions.cs +++ b/lib/Extensions/EnumExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Extensions/EnumerableExtensions.cs b/lib/Extensions/EnumerableExtensions.cs index 71894b7..2567483 100644 --- a/lib/Extensions/EnumerableExtensions.cs +++ b/lib/Extensions/EnumerableExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Extensions/HttpRequestExtensions.cs b/lib/Extensions/HttpRequestExtensions.cs index 95b8221..327ee3d 100644 --- a/lib/Extensions/HttpRequestExtensions.cs +++ b/lib/Extensions/HttpRequestExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Extensions/IntExtensions.cs b/lib/Extensions/IntExtensions.cs index 92a32db..1480ae0 100644 --- a/lib/Extensions/IntExtensions.cs +++ b/lib/Extensions/IntExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Extensions/KeyValuePairExtensions.cs b/lib/Extensions/KeyValuePairExtensions.cs index 408e862..a6a37ad 100644 --- a/lib/Extensions/KeyValuePairExtensions.cs +++ b/lib/Extensions/KeyValuePairExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Extensions/MergeOfficeRequestExtensions.cs b/lib/Extensions/MergeOfficeRequestExtensions.cs index cd28ac4..fce440b 100644 --- a/lib/Extensions/MergeOfficeRequestExtensions.cs +++ b/lib/Extensions/MergeOfficeRequestExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Extensions/RequestInterfaceExtensions.cs b/lib/Extensions/RequestInterfaceExtensions.cs index c54efb8..804ad4a 100644 --- a/lib/Extensions/RequestInterfaceExtensions.cs +++ b/lib/Extensions/RequestInterfaceExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,49 +13,47 @@ // See the License for the specific language governing permissions and // limitations under the License. - - -namespace Gotenberg.Sharp.API.Client.Extensions; - -public static class RequestInterfaceExtensions +namespace Gotenberg.Sharp.API.Client.Extensions { - private const string BoundaryPrefix = Constants.HttpContent.MultipartData.BoundaryPrefix; - - public static IEnumerable IfNullEmptyContent( - this IConvertToHttpContent? converter) + public static class RequestInterfaceExtensions { - return converter?.ToHttpContent() ?? Enumerable.Empty(); - } + private const string BoundaryPrefix = Constants.HttpContent.MultipartData.BoundaryPrefix; - /// - /// A helper method for the linqPad scripts - /// - /// - /// - /// - - public static IEnumerable ToDumpFriendlyFormat( - this IEnumerable items, - bool includeNonText = false) - { - return items.Select( - c => - { - var includeContent = includeNonText || - (c.Headers.ContentType?.ToString().StartsWith("text")) - .GetValueOrDefault(); + public static IEnumerable IfNullEmptyContent( + this IConvertToHttpContent? converter) + { + return converter?.ToHttpContent() ?? Enumerable.Empty(); + } - return new + /// + /// A helper method for the linqPad scripts + /// + /// + /// + /// + public static IEnumerable ToDumpFriendlyFormat( + this IEnumerable items, + bool includeNonText = false) + { + return items.Select( + c => { - Headers = new + var includeContent = includeNonText || + (c.Headers.ContentType?.ToString().StartsWith("text")) + .GetValueOrDefault(); + + return new { - ContentType = string.Join(" | ", c.Headers.ContentType), - Disposition = string.Join(" | ", c.Headers.ContentDisposition) - }, - Content = includeContent - ? c.ReadAsStringAsync().Result - : "-its not text-" - }; - }); + Headers = new + { + ContentType = string.Join(" | ", c.Headers.ContentType), + Disposition = string.Join(" | ", c.Headers.ContentDisposition) + }, + Content = includeContent + ? c.ReadAsStringAsync().Result + : "-its not text-" + }; + }); + } } } \ No newline at end of file diff --git a/lib/Extensions/StringExtensions.cs b/lib/Extensions/StringExtensions.cs index 890bfed..75df819 100644 --- a/lib/Extensions/StringExtensions.cs +++ b/lib/Extensions/StringExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Extensions/TypedClientServiceCollectionExtensions.cs b/lib/Extensions/TypedClientServiceCollectionExtensions.cs index 0c97f81..9c3acf2 100644 --- a/lib/Extensions/TypedClientServiceCollectionExtensions.cs +++ b/lib/Extensions/TypedClientServiceCollectionExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,7 +27,6 @@ namespace Gotenberg.Sharp.API.Client.Extensions; public static class TypedClientServiceCollectionExtensions { - public static IHttpClientBuilder AddGotenbergSharpClient( this IServiceCollection services) { diff --git a/lib/Extensions/ValidOfficeMergeItemExtensions.cs b/lib/Extensions/ValidOfficeMergeItemExtensions.cs index efafb80..b4a3f7f 100644 --- a/lib/Extensions/ValidOfficeMergeItemExtensions.cs +++ b/lib/Extensions/ValidOfficeMergeItemExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/GlobalUsings.cs b/lib/GlobalUsings.cs index bbc27a8..a8c4c1d 100644 --- a/lib/GlobalUsings.cs +++ b/lib/GlobalUsings.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/GotenbergSharpClient.cs b/lib/GotenbergSharpClient.cs index ab628d1..0f205d8 100644 --- a/lib/GotenbergSharpClient.cs +++ b/lib/GotenbergSharpClient.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Infrastructure/Constants.cs b/lib/Infrastructure/Constants.cs index 6ac6c34..ae58085 100644 --- a/lib/Infrastructure/Constants.cs +++ b/lib/Infrastructure/Constants.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Infrastructure/ContentTypes/ResolveContentTypeImplementation.cs b/lib/Infrastructure/ContentTypes/ResolveContentTypeImplementation.cs index 6291db1..9e5e2a6 100644 --- a/lib/Infrastructure/ContentTypes/ResolveContentTypeImplementation.cs +++ b/lib/Infrastructure/ContentTypes/ResolveContentTypeImplementation.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Infrastructure/GotenbergApiException.cs b/lib/Infrastructure/GotenbergApiException.cs index c52e8c3..3f11035 100644 --- a/lib/Infrastructure/GotenbergApiException.cs +++ b/lib/Infrastructure/GotenbergApiException.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Infrastructure/MultiFormHeaderAttribute.cs b/lib/Infrastructure/MultiFormHeaderAttribute.cs index 28ed909..8d86771 100644 --- a/lib/Infrastructure/MultiFormHeaderAttribute.cs +++ b/lib/Infrastructure/MultiFormHeaderAttribute.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Infrastructure/MultiFormPropertyItem.cs b/lib/Infrastructure/MultiFormPropertyItem.cs index 513d44e..361324d 100644 --- a/lib/Infrastructure/MultiFormPropertyItem.cs +++ b/lib/Infrastructure/MultiFormPropertyItem.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Infrastructure/MultiTargetHelpers/KeyValuePair.cs b/lib/Infrastructure/MultiTargetHelpers/KeyValuePair.cs index 7e52caa..214bbb5 100644 --- a/lib/Infrastructure/MultiTargetHelpers/KeyValuePair.cs +++ b/lib/Infrastructure/MultiTargetHelpers/KeyValuePair.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Infrastructure/Pipeline/PolicyFactory.cs b/lib/Infrastructure/Pipeline/PolicyFactory.cs index 1418cb1..9b5b8b0 100644 --- a/lib/Infrastructure/Pipeline/PolicyFactory.cs +++ b/lib/Infrastructure/Pipeline/PolicyFactory.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Infrastructure/Pipeline/TimeoutHandler.cs b/lib/Infrastructure/Pipeline/TimeoutHandler.cs index 510d392..1b74790 100644 --- a/lib/Infrastructure/Pipeline/TimeoutHandler.cs +++ b/lib/Infrastructure/Pipeline/TimeoutHandler.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/Infrastructure/ValidOfficeMergeItem.cs b/lib/Infrastructure/ValidOfficeMergeItem.cs index c709eeb..52f78a4 100644 --- a/lib/Infrastructure/ValidOfficeMergeItem.cs +++ b/lib/Infrastructure/ValidOfficeMergeItem.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2024 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); From f324dd2b9d62740c8904f4bec2b0e95b4c37e04d Mon Sep 17 00:00:00 2001 From: Jaben Cargman Date: Wed, 12 Feb 2025 17:28:13 -0500 Subject: [PATCH 2/5] Fixes #52 Updated the extensions. --- lib/Domain/Requests/MergeOfficeConstants.cs | 31 ++++++++++++--------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/Domain/Requests/MergeOfficeConstants.cs b/lib/Domain/Requests/MergeOfficeConstants.cs index cae8ec4..47faa4b 100644 --- a/lib/Domain/Requests/MergeOfficeConstants.cs +++ b/lib/Domain/Requests/MergeOfficeConstants.cs @@ -1,4 +1,4 @@ -// Copyright 2019-2025 Chris Mohan, Jaben Cargman +// Copyright 2019-2025 Chris Mohan, Jaben Cargman // and GotenbergSharpApiClient Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,18 +18,23 @@ namespace Gotenberg.Sharp.API.Client.Domain.Requests; public static class MergeOfficeConstants { /// - /// Source is here: https://github.com/gotenberg/gotenberg/blob/main/pkg/modules/libreoffice/uno/uno.go + /// Docs are here: https://gotenberg.dev/docs/routes#office-documents-into-pdfs-route + /// Last updated 2/12/2025 /// public static readonly string[] AllowedExtensions = - { - ".bib", ".doc", ".xml", ".docx", ".fodt", ".html", ".ltx", ".txt", ".odt", - ".ott", ".pdb", ".pdf", ".psw", ".rtf", ".sdw", ".stw", ".sxw", ".uot", - ".vor", ".wps", ".epub", ".png", ".bmp", ".emf", ".eps", ".fodg", ".gif", - ".jpg", ".jpeg", ".met", ".odd", ".otg", ".pbm", ".pct", ".pgm", ".ppm", - ".ras", ".std", ".svg", ".svm", ".swf", ".sxd", ".sxw", ".tif", ".tiff", - ".xhtml", ".xpm", ".odp", ".fodp", ".potm", ".pot", ".pptx", ".pps", ".ppt", - ".pwp", ".sda", ".sdd", ".sti", ".sxi", ".uop", ".wmf", ".csv", ".dbf", ".dif", - ".fods", ".ods", ".ots", ".pxl", ".sdc", ".slk", ".stc", ".sxc", ".uos", ".xls", ".xlt", - ".xlsx" - }; + [ + ".123", ".602", ".abw", ".bib", ".bmp", ".cdr", ".cgm", ".cmx", ".csv", ".cwk", + ".dbf", ".dif", ".doc", ".docm", ".docx", ".dot", ".dotm", ".dotx", ".dxf", ".emf", + ".eps", ".epub", ".fodg", ".fodp", ".fods", ".fodt", ".fopd", ".gif", ".htm", ".html", + ".hwp", ".jpeg", ".jpg", ".key", ".ltx", ".lwp", ".mcw", ".met", ".mml", ".mw", + ".numbers", ".odd", ".odg", ".odm", ".odp", ".ods", ".odt", ".otg", ".oth", ".otp", + ".ots", ".ott", ".pages", ".pbm", ".pcd", ".pct", ".pcx", ".pdb", ".pdf", ".pgm", + ".png", ".pot", ".potm", ".potx", ".ppm", ".pps", ".ppt", ".pptm", ".pptx", ".psd", + ".psw", ".pub", ".pwp", ".pxl", ".ras", ".rtf", ".sda", ".sdc", ".sdd", ".sdp", + ".sdw", ".sgl", ".slk", ".smf", ".stc", ".std", ".sti", ".stw", ".svg", ".svm", + ".swf", ".sxc", ".sxd", ".sxg", ".sxi", ".sxm", ".sxw", ".tga", ".tif", ".tiff", + ".txt", ".uof", ".uop", ".uos", ".uot", ".vdx", ".vor", ".vsd", ".vsdm", ".vsdx", + ".wb2", ".wk1", ".wks", ".wmf", ".wpd", ".wpg", ".wps", ".xbm", ".xhtml", ".xls", + ".xlsb", ".xlsm", ".xlsx", ".xlt", ".xltm", ".xltx", ".xlw", ".xml", ".xpm", ".zabw" + ]; } \ No newline at end of file From e900c1eba733cc544c8a68a5d596b4daf2a9fad2 Mon Sep 17 00:00:00 2001 From: Jaben Cargman Date: Wed, 12 Feb 2025 17:53:05 -0500 Subject: [PATCH 3/5] Completes #50 added support for Metadata. --- .../Faceted/HtmlConversionBehaviorBuilder.cs | 29 +++++++++++++++++++ .../Requests/Facets/ExtraHttpHeaders.cs | 2 +- .../Facets/HtmlConversionBehaviors.cs | 8 +++++ lib/Domain/Requests/Facets/Webhook.cs | 2 +- lib/Infrastructure/Constants.cs | 2 ++ 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/Domain/Builders/Faceted/HtmlConversionBehaviorBuilder.cs b/lib/Domain/Builders/Faceted/HtmlConversionBehaviorBuilder.cs index c6d2ce4..9af2493 100644 --- a/lib/Domain/Builders/Faceted/HtmlConversionBehaviorBuilder.cs +++ b/lib/Domain/Builders/Faceted/HtmlConversionBehaviorBuilder.cs @@ -102,6 +102,35 @@ public HtmlConversionBehaviorBuilder AddAdditionalHeaders(JObject extraHeaders) return this; } + /// + /// Sets the document metadata. + /// Not all metadata are writable. Consider taking a look at https://exiftool.org/TagNames/XMP.html#pdf for an (exhaustive?) list of available metadata. + /// + /// + /// + public HtmlConversionBehaviorBuilder SetMetadata(IDictionary dictionary) + { + SetMetadata(new JObject(dictionary)); + + return this; + } + + /// + /// Sets the document metadata. + /// Not all metadata are writable. Consider taking a look at https://exiftool.org/TagNames/XMP.html#pdf for an (exhaustive?) list of available metadata. + /// + /// + /// + + public HtmlConversionBehaviorBuilder SetMetadata(JObject metadata) + { + if (metadata == null) throw new InvalidOperationException("metadata is null"); + + this._htmlConversionBehaviors.MetaData = metadata; + + return this; + } + /// /// Tells gotenberg to return a 409 response if there are exceptions in the Chromium console. /// diff --git a/lib/Domain/Requests/Facets/ExtraHttpHeaders.cs b/lib/Domain/Requests/Facets/ExtraHttpHeaders.cs index e1c23b5..29b8524 100644 --- a/lib/Domain/Requests/Facets/ExtraHttpHeaders.cs +++ b/lib/Domain/Requests/Facets/ExtraHttpHeaders.cs @@ -23,7 +23,7 @@ public void Add(string name, string value) { if (name.IsNotSet()) throw new ArgumentException("Header name is null or empty"); - this._headers.Add(name, new[] { value }); + this._headers.Add(name, [value]); } public void Add(string name, IEnumerable values) diff --git a/lib/Domain/Requests/Facets/HtmlConversionBehaviors.cs b/lib/Domain/Requests/Facets/HtmlConversionBehaviors.cs index acf070d..ee29170 100644 --- a/lib/Domain/Requests/Facets/HtmlConversionBehaviors.cs +++ b/lib/Domain/Requests/Facets/HtmlConversionBehaviors.cs @@ -56,6 +56,14 @@ public class HtmlConversionBehaviors : IConvertToHttpContent [MultiFormHeader(Constants.Gotenberg.Chromium.Shared.HtmlConvert.ExtraHttpHeaders)] public JObject? ExtraHeaders { get; set; } + /// + /// The metadata to write to the PDF (JSON format). + /// Not all metadata are writable. + /// Consider taking a look at https://exiftool.org/TagNames/XMP.html#pdf for an (exhaustive?) list of available metadata. + /// + [MultiFormHeader(Constants.Gotenberg.Chromium.Shared.HtmlConvert.MetaData)] + public JObject? MetaData { get; set; } + /// /// Tells gotenberg to return a 409 response if there are exceptions in the Chromium console. /// diff --git a/lib/Domain/Requests/Facets/Webhook.cs b/lib/Domain/Requests/Facets/Webhook.cs index 140d06b..b1081d4 100644 --- a/lib/Domain/Requests/Facets/Webhook.cs +++ b/lib/Domain/Requests/Facets/Webhook.cs @@ -93,7 +93,7 @@ public bool IsConfigured() public IEnumerable<(string, string?)> GetHeaders() { - if (!this.IsConfigured()) return Enumerable.Empty<(string, string?)>(); + if (!this.IsConfigured()) return []; var webHookHeaders = new List<(string Name, string? Value)> { diff --git a/lib/Infrastructure/Constants.cs b/lib/Infrastructure/Constants.cs index ae58085..ad0d666 100644 --- a/lib/Infrastructure/Constants.cs +++ b/lib/Infrastructure/Constants.cs @@ -264,6 +264,8 @@ public static class HtmlConvert public const string ExtraHttpHeaders = "extraHttpHeaders"; + public const string MetaData = "metadata"; + //javascript public const string FailOnConsoleExceptions = "failOnConsoleExceptions"; From a6a7278bca53ee09639a4ea5060913ccb8e585e2 Mon Sep 17 00:00:00 2001 From: Jaben Cargman Date: Wed, 12 Feb 2025 19:38:09 -0500 Subject: [PATCH 4/5] Added Dimension Support. --- GotenbergSharpApiClient.sln.DotSettings | 1 + lib/Domain/Builders/Faceted/Margins.cs | 3 - .../Builders/Faceted/PagePropertyBuilder.cs | 76 +++++----- lib/Domain/Dimensions/Dimension.cs | 141 ++++++++++++++++++ lib/Domain/Dimensions/DimensionUnitType.cs | 29 ++++ lib/Domain/Requests/Facets/PageProperties.cs | 36 ++--- lib/Extensions/EnumExtensions.cs | 48 +++--- lib/Gotenberg.Sharp.Api.Client.csproj | 1 + 8 files changed, 258 insertions(+), 77 deletions(-) create mode 100644 lib/Domain/Dimensions/Dimension.cs create mode 100644 lib/Domain/Dimensions/DimensionUnitType.cs diff --git a/GotenbergSharpApiClient.sln.DotSettings b/GotenbergSharpApiClient.sln.DotSettings index 684262a..be578c5 100644 --- a/GotenbergSharpApiClient.sln.DotSettings +++ b/GotenbergSharpApiClient.sln.DotSettings @@ -28,6 +28,7 @@ True True True + True True True True diff --git a/lib/Domain/Builders/Faceted/Margins.cs b/lib/Domain/Builders/Faceted/Margins.cs index 11b5151..447c60c 100644 --- a/lib/Domain/Builders/Faceted/Margins.cs +++ b/lib/Domain/Builders/Faceted/Margins.cs @@ -13,11 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. - - namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted; - public enum Margins { None = 0, diff --git a/lib/Domain/Builders/Faceted/PagePropertyBuilder.cs b/lib/Domain/Builders/Faceted/PagePropertyBuilder.cs index 120ee8d..f6d118a 100644 --- a/lib/Domain/Builders/Faceted/PagePropertyBuilder.cs +++ b/lib/Domain/Builders/Faceted/PagePropertyBuilder.cs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Gotenberg.Sharp.API.Client.Domain.Dimensions; + namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted; public sealed class PagePropertyBuilder(PageProperties pageProperties) @@ -56,83 +58,83 @@ public PagePropertyBuilder SetScale(double scale) return this; } + #region Obsolete Helper Functions + [Obsolete("Use SetPaperWidth")] - public PagePropertyBuilder PaperWidth(double width) - { - this._pageProperties.PaperWidth = width; - return this; - } + public PagePropertyBuilder PaperWidth(double width) => SetPaperWidth(width); [Obsolete("Use SetPaperHeight")] - public PagePropertyBuilder PaperHeight(double height) - { - this._pageProperties.PaperHeight = height; - return this; - } + public PagePropertyBuilder PaperHeight(double height) => SetPaperHeight(height); [Obsolete("Use SetMarginTop")] - public PagePropertyBuilder MarginTop(double marginTop) - { - this._pageProperties.MarginTop = marginTop; - return this; - } + public PagePropertyBuilder MarginTop(double marginTop) => SetMarginTop(marginTop); [Obsolete("Use SetMarginBottom")] - public PagePropertyBuilder MarginBottom(double marginBottom) - { - this._pageProperties.MarginBottom = marginBottom; - return this; - } + public PagePropertyBuilder MarginBottom(double marginBottom) => SetMarginBottom(marginBottom); [Obsolete("Use SetMarginLeft")] - public PagePropertyBuilder MarginLeft(double marginLeft) - { - this._pageProperties.MarginLeft = marginLeft; - return this; - } + public PagePropertyBuilder MarginLeft(double marginLeft) => SetMarginLeft(marginLeft); [Obsolete("Use SetMarginRight")] - public PagePropertyBuilder MarginRight(double marginRight) - { - this._pageProperties.MarginRight = marginRight; - return this; - } + public PagePropertyBuilder MarginRight(double marginRight) => SetMarginRight(marginRight); + + #endregion + + #region Dimension Helpers for Inches + + public PagePropertyBuilder SetPaperWidth(double widthInches) => SetPaperWidth(Dimension.FromInches(widthInches)); + + public PagePropertyBuilder SetPaperHeight(double heightInches) => SetPaperHeight(Dimension.FromInches(heightInches)); - public PagePropertyBuilder SetPaperWidth(double width) + public PagePropertyBuilder SetMarginTop(double marginTopInches) => SetMarginTop(Dimension.FromInches(marginTopInches)); + + public PagePropertyBuilder SetMarginBottom(double marginBottomInches) => SetMarginBottom(Dimension.FromInches(marginBottomInches)); + + public PagePropertyBuilder SetMarginLeft(double marginLeftInches) => SetMarginLeft(Dimension.FromInches(marginLeftInches)); + + public PagePropertyBuilder SetMarginRight(double marginRightInches) => SetMarginRight(Dimension.FromInches(marginRightInches)); + + #endregion + + #region Dimension Helpers + + public PagePropertyBuilder SetPaperWidth(Dimension width) { this._pageProperties.PaperWidth = width; return this; } - public PagePropertyBuilder SetPaperHeight(double height) + public PagePropertyBuilder SetPaperHeight(Dimension height) { this._pageProperties.PaperHeight = height; return this; } - public PagePropertyBuilder SetMarginTop(double marginTop) + public PagePropertyBuilder SetMarginTop(Dimension marginTop) { this._pageProperties.MarginTop = marginTop; return this; } - public PagePropertyBuilder SetMarginBottom(double marginBottom) + public PagePropertyBuilder SetMarginBottom(Dimension marginBottom) { this._pageProperties.MarginBottom = marginBottom; return this; } - public PagePropertyBuilder SetMarginLeft(double marginLeft) + public PagePropertyBuilder SetMarginLeft(Dimension marginLeft) { this._pageProperties.MarginLeft = marginLeft; return this; } - public PagePropertyBuilder SetMarginRight(double marginRight) + public PagePropertyBuilder SetMarginRight(Dimension marginRight) { this._pageProperties.MarginRight = marginRight; return this; - } + } + + #endregion [Obsolete("Use SetLandscape()")] public PagePropertyBuilder LandScape(bool landscape = true) diff --git a/lib/Domain/Dimensions/Dimension.cs b/lib/Domain/Dimensions/Dimension.cs new file mode 100644 index 0000000..52170a6 --- /dev/null +++ b/lib/Domain/Dimensions/Dimension.cs @@ -0,0 +1,141 @@ +// Copyright 2019-2025 Chris Mohan, Jaben Cargman +// and GotenbergSharpApiClient Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.ComponentModel; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; + +namespace Gotenberg.Sharp.API.Client.Domain.Dimensions; + +public sealed class Dimension(double value, DimensionUnitType unitType) : IEquatable +{ + private static readonly Regex ValidDimensionRegex = + new(@"^\s*(\d+(\.\d+)?)\s*(pt|px|in|mm|cm|pc)\s*$", RegexOptions.IgnoreCase); + + /// + /// UnitType value + /// + public double Value { get; init; } = value; + + /// + /// pt|px|in|mm|cm|pc + /// + public DimensionUnitType UnitType { get; init; } = unitType; + + public bool Equals(Dimension? other) + { + return other is not null && + Math.Abs(Value - other.Value) < 1e-6 && + UnitType == other.UnitType; + } + + public static Dimension Parse(string dimension) + { + if (string.IsNullOrWhiteSpace(dimension)) + { + throw new ArgumentException("Dimension cannot be null or empty.", + nameof(dimension)); + } + + var match = ValidDimensionRegex.Match(dimension); + if (!match.Success) + { + throw new ArgumentException( + "Invalid dimension format. Expected formats: '200px', '11in', etc.", + nameof(dimension)); + } + + var value = double.Parse(match.Groups[1].Value); + var unitStr = match.Groups[3].Value.ToLower(); + + if (!TryParseUnit(unitStr, out var unit)) + { + throw new ArgumentException($"Unknown unitType '{unitStr}'", nameof(dimension)); + } + + return new Dimension(value, unit); + } + + private static bool TryParseUnit(string unitStr, out DimensionUnitType unitType) + { + foreach (DimensionUnitType type in Enum.GetValues(typeof(DimensionUnitType))) + { + if (type.GetDescription() == unitStr) + { + unitType = type; + return true; + } + } + unitType = default; + + return false; + } + + public static Dimension FromPoints(double points) + { + return new Dimension(points, DimensionUnitType.Points); + } + + public static Dimension FromPixels(double pixels) + { + return new Dimension(pixels, DimensionUnitType.Pixels); + } + + public static Dimension FromInches(double inches) + { + return new Dimension(inches, DimensionUnitType.Inches); + } + + public static Dimension FromMillimeters(double millimeters) + { + return new Dimension(millimeters, DimensionUnitType.Millimeters); + } + + public static Dimension FromCentimeters(double centimeters) + { + return new Dimension(centimeters, DimensionUnitType.Centimeters); + } + + public static Dimension FromPicas(double picas) + { + return new Dimension(picas, DimensionUnitType.Picas); + } + + public override string ToString() + { + return $"{Value}{UnitType.GetDescription()}"; + } + + public override bool Equals(object? obj) + { + return Equals(obj as Dimension); + } + + public override int GetHashCode() + { + return HashCode.Combine(Value, UnitType); + } + + public static bool operator ==(Dimension? left, Dimension? right) + { + return Equals(left, right); + } + + public static bool operator !=(Dimension? left, Dimension? right) + { + return !Equals(left, right); + } +} \ No newline at end of file diff --git a/lib/Domain/Dimensions/DimensionUnitType.cs b/lib/Domain/Dimensions/DimensionUnitType.cs new file mode 100644 index 0000000..810358e --- /dev/null +++ b/lib/Domain/Dimensions/DimensionUnitType.cs @@ -0,0 +1,29 @@ +// Copyright 2019-2025 Chris Mohan, Jaben Cargman +// and GotenbergSharpApiClient Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.ComponentModel; + +namespace Gotenberg.Sharp.API.Client.Domain.Dimensions +{ + public enum DimensionUnitType + { + [Description("pt")] Points, // Points + [Description("px")] Pixels, // Pixels + [Description("in")] Inches, // Inches + [Description("mm")] Millimeters, // Millimeters + [Description("cm")] Centimeters, // Centimeters + [Description("pc")] Picas // Picas + } +} \ No newline at end of file diff --git a/lib/Domain/Requests/Facets/PageProperties.cs b/lib/Domain/Requests/Facets/PageProperties.cs index ebfd05e..cefad2d 100644 --- a/lib/Domain/Requests/Facets/PageProperties.cs +++ b/lib/Domain/Requests/Facets/PageProperties.cs @@ -14,6 +14,7 @@ // limitations under the License. using System.Globalization; +using Gotenberg.Sharp.API.Client.Domain.Dimensions; namespace Gotenberg.Sharp.API.Client.Domain.Requests.Facets { @@ -22,7 +23,7 @@ namespace Gotenberg.Sharp.API.Client.Domain.Requests.Facets /// /// /// Paper size and margins have to be provided in inches. Same for margins. - /// See unit info here: https://gotenberg.dev/docs/modules/chromium#routes + /// See unitType info here: https://gotenberg.dev/docs/modules/chromium#routes /// Paper sizes: https://www.prepressure.com/library/paper-size /// public sealed class PageProperties : IConvertToHttpContent @@ -42,7 +43,7 @@ public sealed class PageProperties : IConvertToHttpContent /// The width of the paper. /// [MultiFormHeader(Constants.Gotenberg.Chromium.Shared.PageProperties.PaperWidth)] - public double PaperWidth { get; set; } + public Dimension? PaperWidth { get; set; } /// /// Gets or sets the height of the paper. @@ -51,7 +52,7 @@ public sealed class PageProperties : IConvertToHttpContent /// The height of the paper. /// [MultiFormHeader(Constants.Gotenberg.Chromium.Shared.PageProperties.PaperHeight)] - public double PaperHeight { get; set; } + public Dimension? PaperHeight { get; set; } /// /// Gets or sets the margin top. @@ -60,7 +61,7 @@ public sealed class PageProperties : IConvertToHttpContent /// The margin top. /// [MultiFormHeader(Constants.Gotenberg.Chromium.Shared.PageProperties.MarginTop)] - public double MarginTop { get; set; } + public Dimension? MarginTop { get; set; } /// /// Gets or sets the margin bottom. @@ -69,7 +70,7 @@ public sealed class PageProperties : IConvertToHttpContent /// The margin bottom. /// [MultiFormHeader(Constants.Gotenberg.Chromium.Shared.PageProperties.MarginBottom)] - public double MarginBottom { get; set; } + public Dimension? MarginBottom { get; set; } /// /// Gets or sets the margin left. @@ -78,7 +79,7 @@ public sealed class PageProperties : IConvertToHttpContent /// The margin left. /// [MultiFormHeader(Constants.Gotenberg.Chromium.Shared.PageProperties.MarginLeft)] - public double MarginLeft { get; set; } + public Dimension? MarginLeft { get; set; } /// /// Gets or sets the margin right. @@ -87,7 +88,7 @@ public sealed class PageProperties : IConvertToHttpContent /// The margin right. /// [MultiFormHeader(Constants.Gotenberg.Chromium.Shared.PageProperties.MarginRight)] - public double MarginRight { get; set; } + public Dimension? MarginRight { get; set; } /// /// Gets or sets a value indicating whether this is landscape. @@ -126,7 +127,8 @@ public sealed class PageProperties : IConvertToHttpContent #region public methods - public static PageProperties ToA4WithNoMargins() => new() { PaperWidth = 8.27, PaperHeight = 11.7 }; + public static PageProperties ToA4WithNoMargins() => new() + { PaperWidth = Dimension.FromInches(8.27), PaperHeight = Dimension.FromInches(11.7) }; /// /// Default Google Chrome printer options @@ -139,12 +141,12 @@ public static PageProperties ToChromeDefaults() { return new PageProperties { - PaperWidth = 8.27, - PaperHeight = 11.7, - MarginTop = 1, - MarginBottom = 1, - MarginLeft = 1, - MarginRight = 1 + PaperWidth = Dimension.FromInches(8.27), + PaperHeight = Dimension.FromInches(11.7), + MarginTop = Dimension.FromInches(1), + MarginBottom = Dimension.FromInches(1), + MarginLeft = Dimension.FromInches(1), + MarginRight = Dimension.FromInches(1) }; } @@ -156,9 +158,9 @@ public static PageProperties ToDeliverableDefault() { return new PageProperties { - PaperWidth = 8.26, - PaperHeight = 11.69, - MarginBottom = .38 //smallest value to get footer to show up is .38 + PaperWidth = Dimension.FromInches(8.26), + PaperHeight = Dimension.FromInches(11.69), + MarginBottom = Dimension.FromInches(.38) //smallest value to get footer to show up is .38 }; } diff --git a/lib/Extensions/EnumExtensions.cs b/lib/Extensions/EnumExtensions.cs index f753275..eac06cf 100644 --- a/lib/Extensions/EnumExtensions.cs +++ b/lib/Extensions/EnumExtensions.cs @@ -14,30 +14,30 @@ // limitations under the License. using System.ComponentModel; +using System.Reflection; +using Gotenberg.Sharp.API.Client.Domain.Dimensions; namespace Gotenberg.Sharp.API.Client.Extensions; internal static class EnumExtensions { - private static readonly IEnumerable<(Margins MarginType, - (double Left, double Right, double Top, double Bottom) Value)> MarginSizer = new[] - { - (Margins.None, (Left: 0.0, Right: 0.0, Top: 0.0, Bottom: 0.0)), - (Margins.Normal, (Left: 1.0, Right: 1.0, Top: 1.0, Bottom: 1.0)), - (Margins.Large, (Left: 2.0, Right: 2.0, Top: 2.0, Bottom: 2.0)) - }; + private static readonly IEnumerable<(Margins MarginType, (Dimension Left, Dimension Right, Dimension Top, Dimension Bottom) Value)> MarginSizer = + [ + (Margins.None, (Left: Dimension.FromInches(0.0), Right: Dimension.FromInches(0.0), Top: Dimension.FromInches(0.0), Bottom: Dimension.FromInches(0.0))), + (Margins.Normal, (Left: Dimension.FromInches(1.0), Right: Dimension.FromInches(1.0), Top: Dimension.FromInches(1.0), Bottom: Dimension.FromInches(1.0))), + (Margins.Large, (Left: Dimension.FromInches(2.0), Right: Dimension.FromInches(2.0), Top: Dimension.FromInches(2.0), Bottom: Dimension.FromInches(2.0))) + ]; - private static readonly IEnumerable<(PaperSizes Size, (double Width, double Height) Value)> - PaperSizer = new[] - { - (PaperSizes.A3, (Width: 11.7, Height: 16.5)), - (PaperSizes.A4, (Width: 8.27, Height: 11.7)), - (PaperSizes.A5, (Width: 5.8, Height: 8.2)), - (PaperSizes.A6, (Width: 4.1, Height: 5.8)), - (PaperSizes.Letter, (Width: 8.5, Height: 11.0)), - (PaperSizes.Legal, (Width: 8.5, Height: 14.0)), - (PaperSizes.Tabloid, (Width: 11.0, Height: 17.0)) - }; + private static readonly IEnumerable<(PaperSizes Size, (Dimension Width, Dimension Height) Value)> PaperSizer = + [ + (PaperSizes.A3, (Width: Dimension.FromInches(11.7), Height: Dimension.FromInches(16.5))), + (PaperSizes.A4, (Width: Dimension.FromInches(8.27), Height: Dimension.FromInches(11.7))), + (PaperSizes.A5, (Width: Dimension.FromInches(5.8), Height: Dimension.FromInches(8.2))), + (PaperSizes.A6, (Width: Dimension.FromInches(4.1), Height: Dimension.FromInches(5.8))), + (PaperSizes.Letter, (Width: Dimension.FromInches(8.5), Height: Dimension.FromInches(11.0))), + (PaperSizes.Legal, (Width: Dimension.FromInches(8.5), Height: Dimension.FromInches(14.0))), + (PaperSizes.Tabloid, (Width: Dimension.FromInches(11.0), Height: Dimension.FromInches(17.0))) + ]; internal static string ToFormDataValue(this PdfFormats format) { @@ -46,7 +46,7 @@ internal static string ToFormDataValue(this PdfFormats format) : $"PDF/A-{format.ToString().Substring(1, 2)}"; } - internal static (double Width, double Height) ToSelectedSize(this PaperSizes selectedSize) + internal static (Dimension Width, Dimension Height) ToSelectedSize(this PaperSizes selectedSize) { if (!Enum.IsDefined(typeof(PaperSizes), selectedSize)) throw new InvalidEnumArgumentException( @@ -60,7 +60,7 @@ internal static (double Width, double Height) ToSelectedSize(this PaperSizes sel return PaperSizer.First(s => s.Size == selectedSize).Value; } - internal static (double Left, double Right, double Top, double Bottom) ToSelectedMargins( + internal static (Dimension Left, Dimension Right, Dimension Top, Dimension Bottom) ToSelectedMargins( this Margins selected) { if (!Enum.IsDefined(typeof(Margins), selected)) @@ -71,4 +71,12 @@ internal static (double Left, double Right, double Top, double Bottom) ToSelecte return MarginSizer.First(m => m.MarginType == selected).Value; } + + public static string GetDescription(this Enum value) + { + FieldInfo field = value.GetType().GetField(value.ToString())!; + DescriptionAttribute? attribute = field.GetCustomAttribute(); + + return attribute?.Description ?? value.ToString(); + } } \ No newline at end of file diff --git a/lib/Gotenberg.Sharp.Api.Client.csproj b/lib/Gotenberg.Sharp.Api.Client.csproj index 1fc115f..b35cda0 100644 --- a/lib/Gotenberg.Sharp.Api.Client.csproj +++ b/lib/Gotenberg.Sharp.Api.Client.csproj @@ -60,6 +60,7 @@ + From d3e11bae2d29b79ba041483ba86e7096de3641a5 Mon Sep 17 00:00:00 2001 From: Jaben Cargman Date: Sat, 15 Feb 2025 19:54:51 -0500 Subject: [PATCH 5/5] Releasing v2.6 --- lib/Domain/Dimensions/Dimension.cs | 31 +++++++++++++++++++++++++++ lib/Gotenberg.Sharp.Api.Client.csproj | 4 +++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/Domain/Dimensions/Dimension.cs b/lib/Domain/Dimensions/Dimension.cs index 52170a6..501bd77 100644 --- a/lib/Domain/Dimensions/Dimension.cs +++ b/lib/Domain/Dimensions/Dimension.cs @@ -20,6 +20,37 @@ namespace Gotenberg.Sharp.API.Client.Domain.Dimensions; +/// +/// Represents a numeric dimension and its corresponding unit type (e.g., points, pixels, inches, etc.). +/// This class is primarily used to specify size values like page dimensions and margins. +/// +/// +/// Example usage: +/// +/// var dim1 = Dimension.Parse("200px"); // Parses from string +/// var dim2 = Dimension.FromInches(8.5); // Creates a dimension in inches +/// var dim3 = new Dimension(21.0, DimensionUnitType.Centimeters); +/// +/// +/// +/// +/// Dimensions are immutable, meaning both and +/// cannot be changed after instantiation. The class implements +/// to facilitate comparisons. +/// +/// +/// +/// Supported unit strings when parsing are: "pt", "px", "in", "mm", "cm", and "pc". +/// An will be thrown if an unsupported or malformed dimension string is provided. +/// +/// +/// +/// Use the static convenience methods (e.g., , +/// , , etc.) to create instances +/// in a specific unit type. The method can be used to parse a dimension +/// string directly, ensuring validation of both the numeric value and the unit type. +/// +/// public sealed class Dimension(double value, DimensionUnitType unitType) : IEquatable { private static readonly Regex ValidDimensionRegex = diff --git a/lib/Gotenberg.Sharp.Api.Client.csproj b/lib/Gotenberg.Sharp.Api.Client.csproj index b35cda0..8a59543 100644 --- a/lib/Gotenberg.Sharp.Api.Client.csproj +++ b/lib/Gotenberg.Sharp.Api.Client.csproj @@ -14,13 +14,14 @@ - 2.5 + 2.6 Gotenberg pdf C# ApiClient unoconv C# API client for interacting with the Gotenberg v7 & v8 micro-service's API, a docker-powered stateless API for converting & merging HTML, Markdown and Office documents to PDF. The client supports a configurable Polly retry policy with exponential back-off for handling transient exceptions. True + v2.6 - Updated office Extensions. Added document metadata support. Add Dimension.FromUnit() support for dimensional values. v2.5 - Renamed "Dimentions" to "PageProperties". Added support for 'GenerateDocumentOutline' and 'OmitBackground.' v2.4 - Updated dependencies. Removed Annotations. Add support for PDF/UA form field. Thank you for the PR @lennartb-! v2.3 - Added Convert Page 'ExportFormFields' flag support (Gotenberg v8.3+ Only). Added .NET 8 target. @@ -41,6 +42,7 @@ true true snupkg + true