[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7831":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":16,"starSnapshotCount":16,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},7831,"wicked_pdf","mileszs\u002Fwicked_pdf","mileszs","PDF generator (from HTML) plugin for Ruby on Rails","http:\u002F\u002Fwww.mileszs.com\u002Fwicked-pdf-plugin",null,"Ruby",3575,640,45,287,0,1,30.42,"MIT License",false,"master",true,[],"2026-06-12 02:01:45","# Wicked PDF [![Gem Version](https:\u002F\u002Fbadge.fury.io\u002Frb\u002Fwicked_pdf.svg)](http:\u002F\u002Fbadge.fury.io\u002Frb\u002Fwicked_pdf) [![Build Status](https:\u002F\u002Fgithub.com\u002Fmileszs\u002Fwicked_pdf\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fmileszs\u002Fwicked_pdf\u002Factions\u002Fworkflows\u002Fci.yml) [![Code Climate](https:\u002F\u002Fcodeclimate.com\u002Fgithub\u002Fmileszs\u002Fwicked_pdf\u002Fbadges\u002Fgpa.svg)](https:\u002F\u002Fcodeclimate.com\u002Fgithub\u002Fmileszs\u002Fwicked_pdf) [![Open Source Helpers](https:\u002F\u002Fwww.codetriage.com\u002Fmileszs\u002Fwicked_pdf\u002Fbadges\u002Fusers.svg)](https:\u002F\u002Fwww.codetriage.com\u002Fmileszs\u002Fwicked_pdf)\n\n## A PDF generation plugin for Ruby on Rails\n\nWicked PDF uses the shell utility [wkhtmltopdf](http:\u002F\u002Fwkhtmltopdf.org) to serve a PDF file to a user from HTML.  In other words, rather than dealing with a PDF generation DSL of some sort, you simply write an HTML view as you would normally, then let Wicked PDF take care of the hard stuff.\n\n_Wicked PDF has been verified to work on Ruby versions 2.2 through 3.2; Rails 4 through 7.0_\n\n### Installation\n\nAdd this to your Gemfile and run `bundle install`:\n\n```ruby\ngem 'wicked_pdf'\n```\n\nThen create the initializer with\n\n    rails generate wicked_pdf\n\nYou may also need to add\n```ruby\nMime::Type.register \"application\u002Fpdf\", :pdf\n```\nto `config\u002Finitializers\u002Fmime_types.rb` in older versions of Rails.\n\nBecause `wicked_pdf` is a wrapper for  [wkhtmltopdf](http:\u002F\u002Fwkhtmltopdf.org\u002F), you'll need to install that, too.\n\nThe simplest way to install all of the binaries on most Linux or OSX systems is through the gem [wkhtmltopdf-binary](https:\u002F\u002Fgithub.com\u002Fzakird\u002Fwkhtmltopdf_binary_gem). Builds for other systems are available [here](https:\u002F\u002Fwkhtmltopdf.org\u002Fdownloads.html)\nTo install that gem, add this:\n\n```ruby\ngem 'wkhtmltopdf-binary'\n```\n\nTo your Gemfile and run `bundle install`.\n\nThis gem currently installs version 0.12.x of `wkhtmltopdf`. Some of the options listed below are specific 0.9 or below, and others are for 0.12 and up.\n\nYou can see what flags are supported for the current version in [wkhtmltopdf's auto-generated manual](https:\u002F\u002Fwkhtmltopdf.org\u002Fusage\u002Fwkhtmltopdf.txt)\n\nIf your wkhtmltopdf executable is not on your webserver's path, you can configure it in an initializer:\n\n```ruby\nWickedPdf.configure do |c|\n  c.exe_path = '\u002Fusr\u002Flocal\u002Fbin\u002Fwkhtmltopdf'\n  c.enable_local_file_access = true\nend\n```\n\nFor more information about `wkhtmltopdf`, see the project's [homepage](http:\u002F\u002Fwkhtmltopdf.org\u002F).\n\n### Basic Usage\n```ruby\nclass ThingsController \u003C ApplicationController\n  def show\n    respond_to do |format|\n      format.html\n      format.pdf do\n        render pdf: \"file_name\"   # Excluding \".pdf\" extension.\n      end\n    end\n  end\nend\n```\n### Usage Conditions - Important!\n\nThe wkhtmltopdf binary is run outside of your Rails application; therefore, your normal layouts will not work. If you plan to use any CSS, JavaScript, or image files, you must modify your layout so that you provide an absolute reference to these files. The best option for Rails without the asset pipeline is to use the `wicked_pdf_stylesheet_link_tag`, `wicked_pdf_image_tag`, and `wicked_pdf_javascript_include_tag` helpers or to go straight to a CDN (Content Delivery Network) for popular libraries such as jQuery.\n\n#### wicked_pdf helpers\n```html\n\u003C!doctype html>\n\u003Chtml>\n  \u003Chead>\n    \u003Cmeta charset='utf-8' \u002F>\n    \u003C%= wicked_pdf_stylesheet_link_tag \"pdf\" -%>\n    \u003C%= wicked_pdf_javascript_include_tag \"number_pages\" %>\n  \u003C\u002Fhead>\n  \u003Cbody onload='number_pages'>\n    \u003Cdiv id=\"header\">\n      \u003C%= wicked_pdf_image_tag 'mysite.jpg' %>\n    \u003C\u002Fdiv>\n    \u003Cdiv id=\"content\">\n      \u003C%= yield %>\n    \u003C\u002Fdiv>\n  \u003C\u002Fbody>\n\u003C\u002Fhtml>\n```\nUsing wicked_pdf_helpers with asset pipeline raises `Asset names passed to helpers should not include the \"\u002Fassets\u002F\" prefix.` error. To work around this, you can use `wicked_pdf_asset_base64` with the normal Rails helpers, but be aware that this will base64 encode your content and inline it in the page. This is very quick for small assets, but large ones can take a long time.\n\n```html\n\u003C!doctype html>\n\u003Chtml>\n  \u003Chead>\n    \u003Cmeta charset='utf-8' \u002F>\n    \u003C%= stylesheet_link_tag wicked_pdf_asset_base64(\"pdf\") %>\n    \u003C%= javascript_include_tag wicked_pdf_asset_base64(\"number_pages\") %>\n\n  \u003C\u002Fhead>\n  \u003Cbody onload='number_pages'>\n    \u003Cdiv id=\"header\">\n      \u003C%= image_tag wicked_pdf_asset_base64('mysite.jpg') %>\n    \u003C\u002Fdiv>\n    \u003Cdiv id=\"content\">\n      \u003C%= yield %>\n    \u003C\u002Fdiv>\n  \u003C\u002Fbody>\n\u003C\u002Fhtml>\n```\n\n#### Webpacker usage\n\nwicked_pdf supports webpack assets.\n\n- Use `wicked_pdf_stylesheet_pack_tag` for stylesheets\n- Use `wicked_pdf_javascript_pack_tag` for javascripts\n- Use `wicked_pdf_asset_pack_path` to access an asset directly, for example: `image_tag wicked_pdf_asset_pack_path(\"media\u002Fimages\u002Ffoobar.png\")`\n\n#### Asset pipeline usage\n\nIt is best to precompile assets used in PDF views. This will help avoid issues when it comes to deploying, as Rails serves asset files differently between development and production (`config.assets.compile = false`), which can make it look like your PDFs work in development, but fail to load assets in production.\n\n    config.assets.precompile += ['blueprint\u002Fscreen.css', 'pdf.css', 'jquery.ui.datepicker.js', 'pdf.js', ...etc...]\n\n#### CDN reference\n\nIn this case, you can use that standard Rails helpers and point to the current CDN for whichever framework you are using. For jQuery, it would look somethng like this, given the current versions at the time of this writing.\n```html\n\u003C!doctype html>\n\u003Chtml>\n  \u003Chead>\n    \u003C%= javascript_include_tag \"http:\u002F\u002Fcode.jquery.com\u002Fjquery-1.10.0.min.js\" %>\n    \u003C%= javascript_include_tag \"http:\u002F\u002Fcode.jquery.com\u002Fui\u002F1.10.3\u002Fjquery-ui.min.js\" %>\n```\n\n### Advanced Usage with all available options\n\n_NOTE: Certain options are only supported in specific versions of wkhtmltopdf._\n\n```ruby\nclass ThingsController \u003C ApplicationController\n  def show\n    respond_to do |format|\n      format.html\n      format.pdf do\n        render pdf:                            'file_name',\n               disposition:                    'attachment',                 # default 'inline'\n               template:                       'things\u002Fshow',\n               locals:                         {foo: @bar},\n               file:                           \"#{Rails.root}\u002Ffiles\u002Ffoo.erb\",\n               inline:                         '\u003C!doctype html>\u003Chtml>\u003Chead>\u003C\u002Fhead>\u003Cbody>INLINE HTML\u003C\u002Fbody>\u003C\u002Fhtml>',\n               layout:                         'pdf',                        # for a pdf.pdf.erb file\n               wkhtmltopdf:                    '\u002Fusr\u002Flocal\u002Fbin\u002Fwkhtmltopdf', # path to binary\n               show_as_html:                   params.key?('debug'),         # allow debugging based on url param\n               orientation:                    'Landscape',                  # default Portrait\n               page_size:                      'A4, Letter, ...',            # default A4\n               page_height:                    NUMBER,\n               page_width:                     NUMBER,\n               save_to_file:                   Rails.root.join('pdfs', \"#{filename}.pdf\"),\n               save_only:                      false,                        # depends on :save_to_file being set first\n               default_protocol:               'http',\n               proxy:                          'TEXT',\n               basic_auth:                     false                         # when true username & password are automatically sent from session\n               username:                       'TEXT',\n               password:                       'TEXT',\n               title:                          'Alternate Title',            # otherwise first page title is used\n               cover:                          'URL, Pathname, or raw HTML string',\n               dpi:                            'dpi',\n               encoding:                       'TEXT',\n               user_style_sheet:               'URL',\n               cookie:                         ['_session_id SESSION_ID'], # could be an array or a single string in a 'name value' format\n               post:                           ['query QUERY_PARAM'],      # could be an array or a single string in a 'name value' format\n               redirect_delay:                 NUMBER,\n               javascript_delay:               NUMBER,\n               window_status:                  'TEXT',                     # wait to render until some JS sets window.status to the given string\n               image_quality:                  NUMBER,\n               no_pdf_compression:             true,\n               zoom:                           FLOAT,\n               page_offset:                    NUMBER,\n               book:                           true,\n               default_header:                 true,\n               disable_javascript:             false,\n               grayscale:                      true,\n               lowquality:                     true,\n               enable_plugins:                 true,\n               disable_internal_links:         true,\n               disable_external_links:         true,\n               keep_relative_links:            true,\n               print_media_type:               true,\n\n               # define as true the key 'disable_local_file_access' or 'enable_local_file_access', not both\n               disable_local_file_access:      true,\n               enable_local_file_access:       false,                     # must be true when using wkhtmltopdf > 0.12.6\n               allow:                          [\"#{Rails.root}\u002Fpublic\"],  # could be an array or a single string\n\n               disable_smart_shrinking:        true,\n               use_xserver:                    true,\n               background:                     false,                     # background needs to be true to enable background colors to render\n               no_background:                  true,\n               no_stop_slow_scripts:           false,\n               viewport_size:                  'TEXT',                    # available only with use_xserver or patched QT\n               extra:                          '',                        # directly inserted into the command to wkhtmltopdf\n               raise_on_all_errors:            nil,                       # raise error for any stderr output.  Such as missing media, image assets\n               raise_on_missing_assets:        nil,                       # raise when trying to access a missing asset\n               log_level:                      'info',                    # Available values: none, error, warn, or info - only available with wkhtmltopdf 0.12.5+\n               quiet:                          false,                     # `false` is same as `log_level: 'info'`, `true` is same as `log_level: 'none'`\n               outline: {   outline:           true,\n                            outline_depth:     LEVEL },\n               margin:  {   top:               SIZE,                     # default 10 (mm)\n                            bottom:            SIZE,\n                            left:              SIZE,\n                            right:             SIZE },\n               header:  {   html: {            template: 'users\u002Fheader',          # use :template OR :url\n                                               layout:   'pdf_plain',             # optional, use 'pdf_plain' for a pdf_plain.html.pdf.erb file, defaults to main layout\n                                               url:      'www.example.com',\n                                               locals:   { foo: @bar }},\n                            center:            'TEXT',\n                            font_name:         'NAME',\n                            font_size:         SIZE,\n                            left:              'TEXT',\n                            right:             'TEXT',\n                            spacing:           REAL,\n                            line:              true,\n                            content:           'HTML CONTENT ALREADY RENDERED'}, # optionally you can pass plain html already rendered (useful if using pdf_from_string)\n               footer:  {   html: {   template:'shared\u002Ffooter',         # use :template OR :url\n                                      layout:  'pdf_plain.html',        # optional, use 'pdf_plain' for a pdf_plain.html.pdf.erb file, defaults to main layout\n                                      url:     'www.example.com',\n                                      locals:  { foo: @bar }},\n                            center:            'TEXT',\n                            font_name:         'NAME',\n                            font_size:         SIZE,\n                            left:              'TEXT',\n                            right:             'TEXT',\n                            spacing:           REAL,\n                            line:              true,\n                            content:           'HTML CONTENT ALREADY RENDERED'}, # optionally you can pass plain html already rendered (useful if using pdf_from_string)\n               toc:     {   font_name:         \"NAME\",\n                            depth:             LEVEL,\n                            header_text:       \"TEXT\",\n                            header_fs:         SIZE,\n                            text_size_shrink:  0.8,\n                            l1_font_size:      SIZE,\n                            l2_font_size:      SIZE,\n                            l3_font_size:      SIZE,\n                            l4_font_size:      SIZE,\n                            l5_font_size:      SIZE,\n                            l6_font_size:      SIZE,\n                            l7_font_size:      SIZE,\n                            level_indentation: NUM,\n                            l1_indentation:    NUM,\n                            l2_indentation:    NUM,\n                            l3_indentation:    NUM,\n                            l4_indentation:    NUM,\n                            l5_indentation:    NUM,\n                            l6_indentation:    NUM,\n                            l7_indentation:    NUM,\n                            no_dots:           true,\n                            disable_dotted_lines:  true,\n                            disable_links:     true,\n                            disable_toc_links: true,\n                            disable_back_links:true,\n                            xsl_style_sheet:   'file.xsl'}, # optional XSLT stylesheet to use for styling table of contents\n               progress: proc { |output| puts output }, # proc called when console output changes\n               delete_temporary_files: true             # explicitly delete temporary files, default false\n      end\n    end\n  end\nend\n```\nBy default, it will render without a layout (layout: false) and the template for the current controller and action.\n\n#### wkhtmltopdf Binary Options\n\nSome of the options above are being passed to `wkhtmltopdf` binary. They can be used to control the options used in Webkit rendering before generating the PDF.\n\nExamples of those options are:\n\n```ruby\nprint_media_type: true        # Passes `--print-media-type`\nno_background: true           # Passes `--no-background`\n```\n\nYou can see the complete list of options under \"Global Options\" in wkhtmltopdf usage [docs](http:\u002F\u002Fwkhtmltopdf.org\u002Fusage\u002Fwkhtmltopdf.txt).\n\n### Super Advanced Usage ###\n\nIf you need to just create a pdf and not display it:\n```ruby\n# create a pdf from a string\npdf = WickedPdf.new.pdf_from_string('\u003Ch1>Hello There!\u003C\u002Fh1>')\n\n# create a pdf file from a html file without converting it to string\n# Path must be absolute path\npdf = WickedPdf.new.pdf_from_html_file('\u002Fyour\u002Fabsolute\u002Fpath\u002Fhere')\n\n# create a pdf from a URL\npdf = WickedPdf.new.pdf_from_url('https:\u002F\u002Fgithub.com\u002Fmileszs\u002Fwicked_pdf')\n\n# create a pdf from string using templates, layouts, and content option for header or footer\npdf = WickedPdf.new.pdf_from_string(\n  render_to_string('templates\u002Fpdf', layout: 'pdfs\u002Flayout_pdf.html'),\n  footer: {\n    content: render_to_string(\n      'templates\u002Ffooter',\n      layout: 'pdfs\u002Flayout_pdf.html'\n    )\n  }\n)\n\n# It is possible to use footer\u002Fheader templates without a layout, in that case you need to provide a valid HTML document\npdf = WickedPdf.new.pdf_from_string(\n  render_to_string('templates\u002Ffull_pdf_template'),\n  header: {\n    content: render_to_string('templates\u002Ffull_header_template')\n  }\n)\n\n# or from your controller, using views & templates and all wicked_pdf options as normal\npdf = render_to_string pdf: \"some_file_name\", template: \"templates\u002Fpdf\", encoding: \"UTF-8\"\n\n# then save to a file\nsave_path = Rails.root.join('pdfs','filename.pdf')\nFile.open(save_path, 'wb') do |file|\n  file \u003C\u003C pdf\nend\n\n# you can also track progress on your PDF generation, such as when using it from within a Resque job\nclass PdfJob\n  def perform\n    blk = proc { |output|\n      match = output.match(\u002F\\[.+\\] Page (?\u003Ccurrent_page>\\d+) of (?\u003Ctotal_pages>\\d+)\u002F)\n      if match\n        current_page = match[:current_page].to_i\n        total_pages = match[:total_pages].to_i\n        message = \"Generated #{current_page} of #{total_pages} pages\"\n        at current_page, total_pages, message\n      end\n    }\n    WickedPdf.new.pdf_from_string(html, progress: blk)\n  end\nend\n```\nIf you need to display utf encoded characters, add this to your pdf views or layouts:\n```html\n\u003Cmeta charset=\"utf-8\" \u002F>\n```\nIf you need to return a PDF in a controller with Rails in API mode:\n```ruby\npdf_html = ActionController::Base.new.render_to_string(template: 'controller_name\u002Faction_name', layout: 'pdf')\npdf = WickedPdf.new.pdf_from_string(pdf_html)\nsend_data pdf, filename: 'file.pdf'\n```\n### Page Breaks\n\nYou can control page breaks with CSS.\n\nAdd a few styles like this to your stylesheet or page:\n```css\ndiv.alwaysbreak { page-break-before: always; }\ndiv.nobreak:before { clear:both; }\ndiv.nobreak { page-break-inside: avoid; }\n```\n\n### Page Numbering\n\nA bit of javascript can help you number your pages. Create a template or header\u002Ffooter file with this:\n```html\n\u003Chtml>\n  \u003Chead>\n    \u003Cscript>\n      function number_pages() {\n        var vars={};\n        var x=document.location.search.substring(1).split('&');\n        for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = decodeURIComponent(z[1]);}\n        var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];\n        for(var i in x) {\n          var y = document.getElementsByClassName(x[i]);\n          for(var j=0; j\u003Cy.length; ++j) y[j].textContent = vars[x[i]];\n        }\n      }\n    \u003C\u002Fscript>\n  \u003C\u002Fhead>\n  \u003Cbody onload=\"number_pages()\">\n    Page \u003Cspan class=\"page\">\u003C\u002Fspan> of \u003Cspan class=\"topage\">\u003C\u002Fspan>\n  \u003C\u002Fbody>\n\u003C\u002Fhtml>\n```\nAnything with a class listed in \"var x\" above will be auto-filled at render time.\n\nIf you do not have explicit page breaks (and therefore do not have any \"page\" class), you can also use wkhtmltopdf's built in page number generation by setting one of the headers to \"[page]\":\n```ruby\nrender pdf: 'filename', header: { right: '[page] of [topage]' }\n```\n### Configuration\n\nYou can put your default configuration, applied to all pdf's at \"wicked_pdf.rb\" initializer.\n\n### Rack Middleware\n\nIf you would like to have WickedPdf automatically generate PDF views for all (or nearly all) pages by appending .pdf to the URL, add the following to your Rails app:\n```ruby\n# in application.rb (Rails3) or environment.rb (Rails2)\nrequire 'wicked_pdf'\nconfig.middleware.use WickedPdf::Middleware\n```\nIf you want to turn on or off the middleware for certain URLs, use the `:only` or `:except` conditions like so:\n```ruby\n# conditions can be plain strings or regular expressions, and you can supply only one or an array\nconfig.middleware.use WickedPdf::Middleware, {}, only: '\u002Finvoice'\nconfig.middleware.use WickedPdf::Middleware, {}, except: [ %r[^\u002Fadmin], '\u002Fsecret', %r[^\u002Fpeople\u002F\\d] ]\n```\nIf you use the standard `render pdf: 'some_pdf'` in your app, you will want to exclude those actions from the middleware.\n\n\n### Include in an email as an attachment\n\nTo include a rendered pdf file in an email you can do the following:\n\n```ruby\nattachments['attachment.pdf'] = WickedPdf.new.pdf_from_string(\n  render_to_string('link_to_view.pdf.erb', layout: 'pdf')\n)\n```\n\nThis will render the pdf to a string and include it in the email. This is very slow so make sure you schedule your email delivery in a job.\n\n### Further Reading\n\nMike Ackerman's post [How To Create PDFs in Rails](https:\u002F\u002Fwww.viget.com\u002Farticles\u002Fhow-to-create-pdfs-in-rails)\n\nAndreas Happe's post [Generating PDFs from Ruby on Rails](http:\u002F\u002Fwww.snikt.net\u002Fblog\u002F2012\u002F04\u002F26\u002Fwicked-pdf\u002F)\n\nJESii's post [WickedPDF, wkhtmltopdf, and Heroku...a tricky combination](http:\u002F\u002Fwww.nubyrubyrailstales.com\u002F2013\u002F06\u002Fwickedpdf-wkhtmltopdf-and-herokua.html)\n\nBerislav Babic's post [Send PDF attachments from Rails with WickedPdf and ActionMailer](http:\u002F\u002Fberislavbabic.com\u002Fsend-pdf-attachments-from-rails-with-wickedpdf-and-actionmailer\u002F)\n\nCorsego's 2021 post [Complete guide to generating PDFs with gem wicked_pdf](https:\u002F\u002Fblog.corsego.com\u002Fgem-wicked-pdf)\n\nPDFTron's post [How to Generate PDFs With Ruby on Rails](https:\u002F\u002Fwww.pdftron.com\u002Fblog\u002Frails\u002Fhow-to-generate-pdf-with-ruby-on-rails\u002F)\n\nStackOverflow [questions with the tag \"wicked-pdf\"](http:\u002F\u002Fstackoverflow.com\u002Fquestions\u002Ftagged\u002Fwicked-pdf)\n\n### Screencasts\n\n* SupeRails Screencast [EN]\n\n[![Ruby on Rails #17 generate, save, send PDFs with gem wicked_pdf](https:\u002F\u002Fi3.ytimg.com\u002Fvi\u002FtFvtwEmW-GE\u002Fhqdefault.jpg)](https:\u002F\u002Fyoutu.be\u002FtFvtwEmW-GE)\n\n* codigofacilito Screencast [ES]\n\n[![Generar PDF con Ruby on Rails - Tutorial](https:\u002F\u002Fi3.ytimg.com\u002Fvi\u002FjeWM_gusmJc\u002Fhqdefault.jpg)](https:\u002F\u002Fyoutu.be\u002FjeWM_gusmJc)\n\n### Debugging\n\nNow you can use a debug param on the URL that shows you the content of the pdf in plain html to design it faster.\n\nFirst of all you must configure the render parameter `show_as_html: params.key?('debug')` and then just use it like you normally would but add \"debug\" as a GET param in the URL:\n\nhttp:\u002F\u002Flocalhost:3001\u002FCONTROLLER\u002FX.pdf?debug\n\nHowever, the wicked_pdf_* helpers will use file:\u002F\u002F\u002F paths for assets when using :show_as_html, and your browser's cross-domain safety feature will kick in, and not render them. To get around this, you can load your assets like so in your templates:\n```html\n\u003C%= params.key?('debug') ? image_tag('foo') : wicked_pdf_image_tag('foo') %>\n```\n\n#### Gotchas\n\nIf one image from your HTML cannot be found (relative or wrong path for example), others images with right paths **may not** be displayed in the output PDF as well (it seems to be an issue with wkhtmltopdf).\n\nwkhtmltopdf may render at different resolutions on different platforms. For example, Linux prints at 75 dpi (native for WebKit) while on Windows it's at the desktop's DPI (which is normally 96 dpi). [Use `:zoom => 0.78125`](https:\u002F\u002Fgithub.com\u002Fwkhtmltopdf\u002Fwkhtmltopdf\u002Fissues\u002F2184) (75\u002F96) to match Linux rendering to Windows.\n\n### Security considerations\n\nWickedPdf renders page content on the server by saving HTML and assets to temporary files on disk, then executing `wkhtmltopdf` to convert that HTML to a PDF file.\n\nIt is highly recommended if you allow user-generated HTML\u002FCSS\u002FJS to be converted to PDF, you sanitize it first, or at least disallow requesting content from internal IP addresses and hostnames.\n\nFor example, these could potentially leak internal AWS metadata:\n```html\n\u003Ciframe src=\"http:\u002F\u002F169.254.169.254\u002Flatest\u002Fmeta-data\u002F\">\u003C\u002Fiframe>\n\u003Cobject data=\"http:\u002F\u002F169.254.169.254\u002Flatest\u002Fmeta-data\u002F\" type=\"text\u002Fhtml\">\n```\n\nThank you to Adam Gold from [Snyk](https:\u002F\u002Fsnyk.io) for reporting this.\nWe are considering adding host allow & block lists and\u002For potentially HTML element sanitizing.\nPlease open an issue or PR to help us out with this.\n\n### Inspiration\n\nYou may have noticed: this plugin is heavily inspired by the PrinceXML plugin [princely](http:\u002F\u002Fgithub.com\u002Fmbleigh\u002Fprincely\u002Ftree\u002Fmaster).  PrinceXML's cost was prohibitive for me. So, with a little help from some friends (thanks [jqr](http:\u002F\u002Fgithub.com\u002Fjqr)), I tracked down wkhtmltopdf, and here we are.\n\n### Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Run the test suite and check the output (`rake`)\n4. Add tests for your feature or fix (please)\n5. Commit your changes (`git commit -am 'Add some feature'`)\n6. Push to the branch (`git push origin my-new-feature`)\n7. Create new Pull Request\n\n### Awesome Peoples\n\nAlso, thanks to [unixmonkey](https:\u002F\u002Fgithub.com\u002FUnixmonkey), [galdomedia](http:\u002F\u002Fgithub.com\u002Fgaldomedia), [jcrisp](http:\u002F\u002Fgithub.com\u002Fjcrisp), [lleirborras](http:\u002F\u002Fgithub.com\u002Flleirborras), [tiennou](http:\u002F\u002Fgithub.com\u002Ftiennou), and everyone else for all their hard work and patience with my delays in merging in their enhancements.\n","Wicked PDF 是一个用于 Ruby on Rails 的 PDF 生成插件，它通过将 HTML 转换为 PDF 文件来提供服务。核心功能是利用 wkhtmltopdf 工具将标准的 HTML 视图转换成 PDF 格式文档，简化了开发人员处理 PDF 生成的过程。技术特点包括支持 Ruby 2.2 至 3.2 版本以及 Rails 4 至 7.0 版本，并且可以通过简单的配置来集成到项目中。适用于需要从 Web 应用程序直接生成报告、发票等文档的场景。安装和配置过程简单明了，只需在 Gemfile 中添加相关依赖并进行基本设置即可开始使用。",2,"2026-06-11 03:14:38","top_language"]