1+ ⭐ For Gotenberg v7+. Beta⭐
2+
13# <img src =" https://github.com/ChangemakerStudios/GotenbergSharpApiClient/raw/master/lib/Resources/gotenbergSharpClient.PNG " width =" 24 " height =" 24 " /> Gotenberg.Sharp.Api.Client
24
3- [ ![ NuGet version] ( https://badge.fury.io/nu/Gotenberg.Sharp.Api.Client.svg )] ( https://badge.fury.io/nu/Gotenberg.Sharp.Api.Client ) [ ![ Build status] ( https://ci.appveyor.com/api/projects/status/s8lvj93xewlsylxh/branch/master?svg=true )] ( https://ci.appveyor.com/project/Jaben/gotenbergsharpapiclient/branch/master ) [ ![ Downloads] ( https://img.shields.io/nuget/dt/Gotenberg.Sharp.API.Client.svg?logo=nuget&color=purple )] ( https://www.nuget.org/packages/Gotenberg.Sharp.API.Client )
5+ [ ![ NuGet version] ( https://badge.fury.io/nu/Gotenberg.Sharp.Api.Client.svg )] ( https://badge.fury.io/nu/Gotenberg.Sharp.Api.Client ) [ ![ Build status] ( https://ci.appveyor.com/api/projects/status/s8lvj93xewlsylxh?svg=true )] ( https://ci.appveyor.com/project/Jaben/gotenbergsharpapiclient ) [ ![ Downloads] ( https://img.shields.io/nuget/dt/Gotenberg.Sharp.API.Client.svg?logo=nuget&color=purple )] ( https://www.nuget.org/packages/Gotenberg.Sharp.API.Client )
6+
7+ .NET C# Client for interacting with the [ Gotenberg] ( https://gotenberg.dev/ ) micro-service's API. [ Gotenberg] ( https://github.com/gotenberg/gotenberg ) is a [ Docker-powered stateless API] ( https://hub.docker.com/r/gotenberg/gotenberg/ ) for converting & merging HTML, Markdown and Office documents to PDF. The client supports a configurable [ Polly] ( http://www.thepollyproject.org/ ) ** retry policy** with exponential backoff for handling transient exceptions.
48
5- .NET C# Client for interacting with the [ Gotenberg ] ( https://thecodingmachine.github.io/gotenberg ) micro-service's API. [ Gotenberg ] ( https://github.com/thecodingmachine/gotenberg ) is a [ Docker-powered stateless API] ( https://hub.docker.com/r/thecodingmachine/gotenberg ) for converting & merging HTML, Markdown and Office documents to PDF. The client supports a configurable [ Polly ] ( http://www.thepollyproject.org/ ) ** retry policy ** with exponential backoff for handling transient exceptions.
9+ * As of version [ 2.0.0-alpha0002 ] ( https://www.nuget.org/packages/Gotenberg.Sharp. API.Client/2.0.0-alpha0002#supportedframeworks-tab ) Gotenberg.Sharp.API.Client targets net6.0, net5.0; netstandard 2.0 and 2.1 *
610
711# Getting Started
812* Pull the image from dockerhub.com*
913``` powershell
10- > docker pull thecodingmachine /gotenberg:latest
14+ > docker pull gotenberg /gotenberg:latest
1115```
1216* Create & start a container*
1317``` powershell
14- docker run --name gotenbee -e DEFAULT_WAIT_TIMEOUT=1800 -e MAXIMUM_WAIT_TIMEOUT=1800 -e LOG_LEVEL=DEBUG -p: 3000:3000 "thecodingmachine /gotenberg:latest"
18+ docker run --name gotenbee7x --rm -p 3000:3000 gotenberg /gotenberg:latest gotenberg --api-timeout=1800s --log-level=debug
1519```
1620# .NET Core Project Setup
1721* Install nuget package into your project*
@@ -22,7 +26,7 @@ PM> Install-Package Gotenberg.Sharp.Api.Client
2226``` json
2327 "GotenbergSharpClient" : {
2428 "ServiceUrl" : " http://localhost:3000" ,
25- "HealthCheckUrl" : " http://localhost:3000/ping " ,
29+ "HealthCheckUrl" : " http://localhost:3000/health " ,
2630 "RetryPolicy" : {
2731 "Enabled" : true ,
2832 "RetryCount" : 4 ,
@@ -44,9 +48,11 @@ public void ConfigureServices(IServiceCollection services)
4448}
4549
4650```
47- # Using GotenbergSharpClient
51+ # Using GotenbergSharpClient.
4852* See the [ linqPad folder] ( linqpad/ ) * for complete examples.
4953
54+ ### Note: Samples below are currently stale. Linqpad scripts are fresh.
55+
5056## Html To Pdf
5157* With embedded assets:*
5258
@@ -62,12 +68,7 @@ public void ConfigureServices(IServiceCollection services)
6268 dims .SetPaperSize (PaperSizes .A3 )
6369 .SetMargins (Margins .None )
6470 .SetScale (. 99 );
65- }).WithAsyncAssets (async assets => assets .AddItem (" some-image.jpg" , await GetImageBytes ()))
66- .ConfigureRequest (config =>
67- {
68- config .ChromeRpccBufferSize (1024 )
69- .PageRanges (" 1" );
70- });
71+ }).WithAsyncAssets (async assets => assets .AddItem (" some-image.jpg" , await GetImageBytes ()));
7172
7273 var req = await builder .BuildAsync ();
7374
@@ -87,7 +88,7 @@ public async Task<Stream> CreateFromUrl(string headerPath, string footerPath)
8788 .SetUrl (" https://www.cnn.com" )
8889 .ConfigureRequest (config =>
8990 {
90- config .PageRanges (" 1-2" ). ChromeRpccBufferSize ( 1048576 ) ;
91+ config .PageRanges (" 1-2" );
9192 })
9293 .AddAsyncHeaderFooter (async
9394 doc => doc .SetHeader (await File .ReadAllTextAsync (headerPath ))
@@ -111,11 +112,7 @@ public async Task<Stream> CreateFromUrl(string headerPath, string footerPath)
111112public async Task < Stream > DoOfficeMerge (string sourceDirectory )
112113{
113114 var builder = new MergeOfficeBuilder ()
114- .WithAsyncAssets (async a => a .AddItems (await GetDocsAsync (sourceDirectory )))
115- .ConfigureRequest (config =>
116- {
117- config .TimeOut (100 );
118- });
115+ .WithAsyncAssets (async a => a .AddItems (await GetDocsAsync (sourceDirectory )));
119116
120117 var request = await builder .BuildAsync ();
121118 return await _sharpClient .MergeOfficeDocsAsync (request );
@@ -138,10 +135,7 @@ public async Task<Stream> CreateFromMarkdown()
138135 dims .UseChromeDefaults ().LandScape ().SetScale (. 90 );
139136 }).WithAsyncAssets (async
140137 a => a .AddItems (await GetMarkdownAssets ())
141- ).ConfigureRequest (req =>
142- {
143- req .ChromeRpccBufferSize (1048555 );
144- });
138+ ));
145139
146140 var request = await builder .BuildAsync ();
147141 return await _sharpClient .HtmlToPdfAsync (request );
@@ -163,12 +157,11 @@ public async Task<Stream> CreateFromMarkdown()
163157 .SetUrl (" http://host.docker.internal:5000/api/your/webhookReceiver" )
164158 .AddRequestHeader (" custom-header" , " value" );
165159 })
166- .PageRanges (" 1-2" )
167- .ChromeRpccBufferSize (1048576 );
160+ .PageRanges (" 1-2" );
168161 })
169162 .AddAsyncHeaderFooter (async
170- docBuilder => docBuilder .SetHeader (await System .IO .File .ReadAllTextAsync (headerPath ))
171- .SetFooter (await System .IO .File .ReadAllBytesAsync (footerPath ))
163+ b => b .SetHeader (await System .IO .File .ReadAllTextAsync (headerPath ))
164+ .SetFooter (await System .IO .File .ReadAllBytesAsync (footerPath ))
172165 ).WithDimensions (dimBuilder =>
173166 {
174167 dimBuilder .SetPaperSize (PaperSizes .A4 )
@@ -240,11 +233,11 @@ async Task<Stream> ExecuteRequestsAndMerge(IEnumerable<UrlRequest> requests)
240233 var results = await Task .WhenAll (tasks );
241234
242235 var mergeBuilder = new MergeBuilder ()
243- .WithAssets (b =>
244- { b .AddItems (results .Select ((r , i ) => KeyValuePair .Create ($" {i }.pdf" , r ))); }
245- ). ConfigureRequest ( b => b . TimeOut ( 1799 ) );
236+ .WithAssets (b => {
237+ b .AddItems (results .Select ((r , i ) => KeyValuePair .Create ($" {i }.pdf" , r )));
238+ } );
246239
247240 var request = mergeBuilder .Build ();
248241 return await _sharpClient .MergePdfsAsync (request );
249242}
250- ```
243+ ```
0 commit comments