alvarcarto / url-to-pdf-api

Web page PDF/PNG rendering done right. Self-hosted service for rendering receipts, invoices, or any content.
MIT License
7.03k stars 779 forks source link

WIP: Feature/image route #43

Closed Echobob closed 6 years ago

Echobob commented 7 years ago

Not sure if anyone would want this, but I've added support for puppeteer's screenshotting method. This would change the api/render to api/pdf/render & api/image/render (TODO: Docs & Tests)

nicky9door commented 6 years ago

When trying to use this feature, I get an error saying:

Expected options.clip.x to be a number but found undefined

I resolved this by adding the following to core/image-core.js at line 27 ( before logOpts)

if(_.isEmpty(_.pickBy(opts.image.clip))){                                                           
  opts.image.clip = undefined                                                                       
}

This will set the clip value to undefined if none of the clipping options have been set. The error will still occur if some but not all of the clipping options are set but I think that should be the client's responsibility

kimmobrunfeldt commented 6 years ago

This feature is good but the PR is adding a bit too much duplicate code to maintain plus it would be a API breaking change as is. I don't have time to thoroughly think about this through but it would need some refactoring before merge.

kimmobrunfeldt commented 6 years ago

This feature has now been implemented into master. The implementation maintains API backwards compability.