New version of Gotenberg π
gulien opened this issue Β· 13 comments
Hello @yumauri π
I've just released version 7.0.0
of Gotenberg π
A lot of minor changes, the best if you wish to update your JS/TS 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!
Hi!
That's awesome π
Thanks for keeping in touch :) I'll try to catch up soon, I hope π
No problem π thank you for maintaining this library π
Hello @yumauri π I've added your JavaScript/TypeScript client to the documentation. I hope it brings more folks to your repository π
Wow, thank you so much :) Wish I had more spare time to work on this client >_< New folks with new issues will definitely push me to it :D
For those of you, who will come here from the Gotenberg documentation:
Gotenberg 7.x brings new conception of modules, thus, changing convertion URLs, separating them by different modules.
If you need to use this library now with Gotenberg 7.x, in simple cases you can do it by adjusting connection string, like this:
pipe(
gotenberg('http://localhost:3000/forms/chromium'),
convert,
html,
please
)
Same connection string and approach go for url
and markdown
conversions (both of them are done by chromium module as well).
For office
conversion it is a bit more verbose, something like this:
pipe(
gotenberg(''), // any string here, will be overridden
convert, // it is save to remove this line, if you want
office,
adjust({
// manually adjust endpoint
url: 'http://localhost:3500/forms/libreoffice/convert',
}),
please
)
This is until I come up with new nice looking API for Gotenberg 7.x with modules support :)
Hey, no problem π you spent a lot of time developing this library, thatβs the least I can do.
Also, no pressure regarding the release of a version that matches all Gotenberg 7.x features. Take your time, and if people really wants Gotenberg 7.x support, they should also help you somehow!
Btw, Iβve juste released a new PHP client if you want to take some inspiration: https://github.com/gotenberg/gotenberg-php
Thank you for your work π
@yumauri We rely quite heavily on this library in our product and are really happy that you took the time to write and publish it.
To ease the burden with rewriting the API for v7 maybe it would be a good idea to split it up into multiple issues and tag them with help wanted
and maybe we all can cooperate to incrementally bring this to work with the latest version?
Using the example above, I have office (file) conversion to PDF working using the demo.gotenberg.dev server. However, I cannot get the chromium url conversion working. This is my code:
const pdfFromUrl = pipe(
gotenberg(`https://demo.gotenberg.dev/forms/chromium`),
convert,
url,
please,
)
return pdfFromUrl(`http://www.google.com`)
I get a 400 Bad Request every time. I've tried playing around with the connection string, but everything else gives 404. So I think I'm hitting the right place, but something else is wrong. I can get it to work with a raw POST request (in Postman) to https://demo.gotenberg.dev/forms/chromium/convert/url
providing url as form-data. I just can't figure out how to do the same using gotenberg-js-client.
UPDATE: I can get the raw html option working, just not url version.
@julianpensionjar Oh, I didn't see that URL conversion in 7th version uses different parameter name, just url
instead of remoteURL
in 6th version...
Unfortunately, there is no ready modifier to rename fields in request, and adjust
will not help here, because you need to modify field with input data.
But as a bit hacky workaround you can write you own modifier and put it in chain:
const pdfFromUrl = pipe(
gotenberg(`https://demo.gotenberg.dev/forms/chromium`),
convert,
url,
to({ margins: [0, 0, 0, 0] }), // it is better to remove margins with URL conversion
(request) => {
request.fields.url = request.fields.remoteURL
delete request.fields.remoteURL
return request
},
please,
)
return pdfFromUrl(`http://www.google.com`)
Thanks - I got it working but needed some extra hacking to make Typescript happy - see below for anyone else needing the double-hacky workaround ;o)
Create a new type that extends UrlRequestFields to add url attribute...
export type Urlv7RequestFields = UrlRequestFields & {
url?: string
}
Use that type in the modifier...
const pdfFromUrl = pipe(
gotenberg(`https://demo.gotenberg.dev/forms/chromium`),
convert,
url,
to({ margins: [0, 0, 0, 0] }), // it is better to remove margins with URL conversion
request => {
const v7request: Urlv7RequestFields = request.fields
v7request.url = v7request.remoteURL
delete v7request.remoteURL
request.fields = v7request
return request
},
please,
)
return pdfFromUrl(urlString)
I guess you could simply cast to any
to suppress TypeScript ;)
;(request.fields as any).url = request.fields.remoteURL
Any update on when v7
and v8
will be supported?
Oh.
I would hate to say that this library is abandoned, but thing is I don't use it anymore myself. I wrote this library for a project, which was closed and no more in active development. Since then I didn't have an urgent demand to upgrade my library, and I was postponing this with hacks, mentioned above in this thread.
I still want to upgrade it though. I saw few other JS clients for Gotenberg, but I still think that API of my client is most beautiful (and most polite, heh). So, I will not mark it as abandoned and deprecated, upgrade is still on a table, but I don't have a roadmap for it. And time, for now, unfortunately...
@SanderBlom But your question has resurrected my desire from long stagnation, as I see that someone is interested in my work :) I remember, that I was trying to make library compatible with v6 and v7 both, when v7 was out, but I didn't came up with a nice solution and was frustrated. Now I think it is not necessary to support v6, since it is very old, and one using it can stick with current library version anyways. I'll see, maybe without such restriction things will go smoother.
@yumauri releasing a new version where you drop support for v6 would work perfectly for us :)