changemakerstudios / gotenbergsharpapiclient Goto Github PK
View Code? Open in Web Editor NEW.NET C# Client for the Gotenberg API
License: Apache License 2.0
.NET C# Client for the Gotenberg API
License: Apache License 2.0
In .Net 6 it is know thrown exception if invariant culture is enabled, but the app is creating a specific culture.
E.g. see this:
https://docs.microsoft.com/en-us/dotnet/core/compatibility/globalization/6.0/culture-creation-invariant-mode
Below is a line from your code where a specific culture info is used. Maybe just set it to Cultureinfo.InvariantCulture?
There is currently no emulatedMediaType=screen option.
This option renders page exactly what it looks like on web and not in print mode.
I will be happy to contribute to v7 branch if you need any help.
Hello :)
FYI, I've just released Gotenberg 6.1.0 ๐
Here is an example with the new features implemented in the go client: https://github.com/thecodingmachine/gotenberg-go-client/releases/tag/v7.0.0
Hello
Thank you for making this library ๐I just saw your post on reddit and I was wondering if I could add it in the documentation of Gotenberg https://thecodingmachine.github.io/gotenberg/#clients.community_clients?
Used the API on a german Windows. Having this the output of ToString() of 8.3 will be 8,3 which breaks the request to Gotenberg with an unable to convert to float message.
Used this to fix the issue:
StringContent contentItem;
switch (value)
{
case float f:
contentItem = new StringContent(f.ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US")));
break;
case double d:
contentItem = new StringContent(d.ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US")));
break;
case decimal c:
contentItem = new StringContent(c.ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US")));
break;
case int i:
contentItem = new StringContent(i.ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US")));
break;
case long l:
contentItem = new StringContent(l.ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US")));
break;
case DateTime date:
contentItem = new StringContent(date.ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US")));
break;
default:
contentItem = new StringContent(value.ToString());
break;
}
I want to post my byte array office file/files to client and get byte array pdf. How can I do this?
I asked my question here but I couldn't do it.
Here:
gotenberg/gotenberg#481 (reply in thread)
Hi,
I have a small feature suggestion:
Gotenberg 8.3.0 introduced the new exportFormFields
form field as an option for its forms/libreoffice/convert
end point.
It's also documented at https://gotenberg.dev/docs/routes#page-properties-libreoffice.
This option is especially useful when converting Word documents containing content controls as currently, these are automatically transformed into form fields - a transformation that's not always ideal.
Best regards,
Mario
After updating to v2 it seems impossible to set multiple request headers to the webhook request.
usage:
reqBuilder.AddWebhook(hook =>
{
hook.SetUrl(gotenbergWebHookUrl, HttpMethod.Post)
.SetErrorUrl(gotenbergErrorUrl, HttpMethod.Post)
.AddRequestHeader("JobId", jobId)
.AddRequestHeader("DocumentId", documentId)
.AddRequestHeader("ContentViewType", Enum.GetName(contentViewType));
})
exception:
System.ArgumentException: An item with the same key has already been added. Key: Gotenberg-Webhook-Extra-Http-Headers
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Gotenberg.Sharp.API.Client.Domain.Builders.Faceted.WebhookBuilder.AddRequestHeader(String name, IEnumerable`1 values)
at Gotenberg.Sharp.API.Client.Domain.Builders.Faceted.WebhookBuilder.AddRequestHeader(String name, String value)
It seems like the method AddRequestHeader should either accept an IDictionary<string, string>
/ IDictionary<string, IEnumerable<string>>
or handle multiple calls of the method correctly. I didnt deep dive into the differences between v1 and v2 and not into differences between Gotenberg v6 and v7, but on the first view it seems to be a bug in GotenbergSharpApiClient. Or am I wrong?
Please add support for the trace feature in Gotenberg.
https://gotenberg.dev/docs/modules/api#trace-all-routes
The purpose of sending a Trace header is to make it easier to find out which client request caused which log entry on the server (gotenberg) side.
Hello here ๐
I've just released version 7.0.0
of Gotenberg ๐
A lot of minor changes, the best if you wish to update your C# client is to head to the new documentation.
Also, I've added your repository to the awesome list ๐ currently, I've marked it as only compatible with Gotenberg 6.x, but do not hesitate to open a PR when your client is compatible with version 7 ๐
PS: if you have any questions, please ask them!
As I understand you have to use GotenbergSharpClient.MergeOfficeDocsAsync for converting office files. But there is limitation that only allows 2 or more files to be converted. There is check for that:
GotenbergSharpApiClient/lib/Domain/Requests/MergeOfficeRequest.cs
Lines 39 to 40 in 2464c8b
It looks like the client returns the result on error without any hints that is response is not 200 OK. Should it not throw an exception at least?
I started using the example defined in the getting started and had instantly this error:
{"level":"error","msg":"strconv.ParseFloat: parsing "0,5": invalid syntax","op":"xhttp.htmlHandler: xhttp.chromePrinterOptions: resource.MarginArgs: resource.Resource.Float64Arg: xassert.Float64","time":"2020-03-04T09:27:32Z","trace":"RP4I2w1Xa684qWtwV7zeeRktGsi3j9I8"}
Should it be possible to reference this from a netcoreapp2.2
project?
Gotenberg.Sharp.Api.Client.csproj
references Microsoft.Extensions.Http v3.0.0
which appears to prevent this situation
...
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.0.0" />
...
The change from v2.2.0 to v3.0.0 took place here
Hello ๐
FYI, I've just released Gotenberg 6.2.0 ๐
The API now accepts a new form field scale
for HTML, URL and Markdown conversions (see https://thecodingmachine.github.io/gotenberg/#html.paper_size_margins_orientation_scaling).
Thank you again for this client ๐
Related #14
I get 404 response for each gotenberg container endpoint. I tried every way to create it, each one returns the same - the string "Not Found" along with the HTTP 404 code. In the logs I get this:
I tried to use images, but neither works:
Using from within code also doesn't work. I have no ideas what else to do. I am asking for tips and correction of the log, because the present say nothing.
@chrismo111 Okay to go ahead and release v1.1 with these fixes or do you have other things you want to put in there?
I have the following Set-up
AppSettings
"GotenbergSharpClient": {
"ServiceUrl": "http://localhost:3000",
"HealthCheckUrl": "http://localhost:3000/ping",
"RetryPolicy": {
"Enabled": true,
"RetryCount": 4,
"BackoffPower": 1.5,
"LoggingEnabled": true
}
}
public void ConfigureServices(IServiceCollection services)
{
.....
services.AddOptions<GotenbergSharpClientOptions>()
.Bind(Configuration.GetSection(nameof(GotenbergSharpClient)));
services.AddGotenbergSharpClient();
.....
}
Question 1:
I notice when I have this
var test = Configuration.GetSection(nameof(GotenbergSharpClient));
It is always null?
So not sure if the App settings is getting passed on to the GotenbergSharpClient or not?
Question 2:
When newing up the GotenbergSharpClient
_Instance = new GotenbergSharpClient(Settings.Current.PDFServer);
How does the Retry options get passed to it?
"RetryPolicy": {
"Enabled": true,
"RetryCount": 4,
"BackoffPower": 1.5,
"LoggingEnabled": true
}
Not 100% sure when newing it up if the Retry Policies gets passed in to it?
I am thinking and hoping by looking at this
public static IAsyncPolicy<HttpResponseMessage> CreatePolicyFromSettings(IServiceProvider sp,
HttpRequestMessage request)
it seems like the policy is created on HttpResponseMessage and it gets the settings from the service provider and since that
is provided in Startup.cs that the retry settings should be passed in regardless of how the Client is used?
Question 3:
How do I check to make sure that the retry settings are being passed into the Gotenberg Service correctly?
Question 4:
What is the best way to Unit test Gotenberg Server Errors which results in HttpResonse errors, to trigger the retry policy to kick in?
Thanks ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.