Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

New version of Gotenberg 🚀 #32

Open
gulien opened this issue Aug 22, 2021 · 13 comments
Open

New version of Gotenberg 🚀 #32

gulien opened this issue Aug 22, 2021 · 13 comments
Milestone

Comments

@gulien
Copy link

gulien commented Aug 22, 2021

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!

@yumauri
Copy link
Owner

yumauri commented Aug 23, 2021

Hi!
That's awesome 🎉
Thanks for keeping in touch :) I'll try to catch up soon, I hope 😅

@yumauri yumauri added this to the next milestone Aug 23, 2021
@gulien
Copy link
Author

gulien commented Aug 23, 2021

No problem 😄 thank you for maintaining this library 👍

@gulien
Copy link
Author

gulien commented Nov 28, 2021

Hello @yumauri 👋 I've added your JavaScript/TypeScript client to the documentation. I hope it brings more folks to your repository 😄

@yumauri
Copy link
Owner

yumauri commented Nov 28, 2021

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 :)

@gulien
Copy link
Author

gulien commented Nov 28, 2021

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 😉

@karatekaneen
Copy link

@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?

@julianpensionjar
Copy link

julianpensionjar commented Mar 3, 2022

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.

@yumauri
Copy link
Owner

yumauri commented Mar 3, 2022

@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`)

@julianpensionjar
Copy link

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)

@yumauri
Copy link
Owner

yumauri commented Mar 3, 2022

I guess you could simply cast to any to suppress TypeScript ;)

;(request.fields as any).url = request.fields.remoteURL

@SanderBlom
Copy link

Any update on when v7 and v8 will be supported?

@yumauri
Copy link
Owner

yumauri commented Sep 19, 2024

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.

@SanderBlom
Copy link

@yumauri releasing a new version where you drop support for v6 would work perfectly for us :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants