{"repo":"NielsSteensma/Dhalang","free":true,"listed":false,"github":"https://github.com/NielsSteensma/Dhalang","clone":"git clone https://github.com/NielsSteensma/Dhalang.git","description":"Generate PDFs and make screenshots of HTML using Puppeteer in Ruby","language":"Ruby","stars":42,"topics":["puppeteer","pdf-generation","screenshot","pdf"],"license":"MIT","category":"scrapers-browser-automation","readme_excerpt":"Dhalang Dhalang is a Ruby wrapper for Google's Puppeteer. Features Generate PDFs from webpages Generate PDFs from HTML ( external images/stylesheets supported ) Capture screenshots from webpages Scrape HTML from webpages Prerequisites Node ≥ 18 Puppeteer ≥ 22 Unix shell ( Dhalang will not work on Windows shells ) Installation Add this line to your application's Gemfile: gem 'Dhalang' And then execute: $ bundle update Install puppeteer or puppeteer-core in your application's root directory: $ npm install puppeteer or $ npm install puppeteer-core Usage PDF of a website url It is important to pass the complete url, leaving out https://, http:// or www. will result in an error. PDF of a HTML string PNG screenshot of a website JPEG screenshot of a website WEBP screenshot of a website HTML of a website Above methods either return a string containing the PDF/JPEG/PNG/WEBP in binary or the scraped HTML. Custom options To override the default options that are set by Dhalang you can pass as last argument a hash with the custom options you want to set. For example to set custom margins for PDFs: For example to only take a screenshot of the visible part of the page: A list of all possible PDF options that can be set, can be found at: https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.pdfoptions.md A list of all possible screenshot options that can be set, can be found at: https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.screenshotoptions.md The default","default_branch":null,"files":null,"tree":[],"storefront":"/r/NielsSteensma","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/NielsSteensma/Dhalang/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}