YusukeIwaki/puppeteer-ruby

Puppeteer::Page#pdf without path: parameter

zzeligg opened this issue · 2 comments

Great job on that port!

Testing it out, I wanted to generate a PDF from a Page, which I did by calling @page#pdf without the path: argument.

2 things:

  1. It raises an Exception that ArgumentError is not defined:

pdf_options.rb:26:in 'initialize': undefined method 'ArgumentError' for #<Puppeteer::Page::PDFOptions:0x00007fca3abc6f18> (NoMethodError)

because the call should be ArgumentError.new("...") on line 26

  1. I did read your comment to the effect that there is nothing to do without path parameter, but I disagree. While it is convenient to save a web page to a PDF file in just one call, I would prefer to be able to get the result in a String myself. And ProtocolStreamReader does return a String already, so what I need is already there. I think simply commenting out the unless options[:path] block on line 23 of pdf_options.rb does the trick, since Page#pdf already calls ProtocolStreamReader.new(...).read.

Thank you for the feedback.

I would prefer to be able to get the result in a String myself.

Puppeteer (JS) merged this feature just a while ago :)
puppeteer/puppeteer#5731

I agree the feature is useful and should be ported into Ruby.

@zzeligg puppeteer-ruby 0.34.1 files the issue. Could you try it? Thank you :)