Skip to content

Ferrum::Browser load inline page or from local file #260

Closed

Description

@davidwessman

Hello.

I read through the documentation and the options for Ferrum::Browser.new but could not find any way to load a browser from a local file or string instead of an url.

The use-case I have is to render PDFs where there is no URL to load the HTML from.

html = generate_html
browser = Ferrum::Browser.new
browser.load(html)
tmp = Tempfile.new("pdf-chrome-#{filename}")
browser.pdf(
  path: tmp.path,
  format: :A4,
  landscape: false,
  margin: {top: 36, right: 36, bottom: 36, left: 36},
  preferCSSPageSize: true,
  printBackground: true
)
browser.quit
pdf_data = File.read(tmp.path)

I am sorry if I missed some option for this, thankful for any help 🙂

Activity

  1. locked and limited conversation to collaborators on Apr 20, 2022
  2. converted this issue into a discussion #261 on Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions