prawn - import image from URL
you need to do the following -
require "open-uri"
Prawn::Document.generate(INSERT_YOUR_PDF_FILENAME_HERE) do
image open(INSERT_YOUR_URL_HERE)
end
Refer to http://rubydoc.info/gems/prawn/0.12.0/frames for more details. Prawn - Links inside table cells
You can specify inline_format
for the cell and create the link yourself:
cell_email = pdf.make_cell(
:content => "<link href='mailto:#{booking.user_email}'>#{booking.user_email}</link>",
:inline_format => true
)
You can specify inline_format
for the whole table, too:table data, :cell_style => { :inline_format => true }
Prawn's inline_format
supports <b>
, <i>
, <u>
, <strikethrough>
, <sub>
, <sup>
, <font>
, <color>
and <link>
. How to download specific GIF images (condition: phd*.gif) from a website using Python's BeautifulSoup?
Instead of checking the name in the loop, you can use BeautifulSoup
's built-in support for regular expressions. Provide the compiled regular expression as a value of src
argument:
import re
from bs4 import BeautifulSoup as bs # note, you should use beautifulsoup4
for image in soup.find_all("img", src=re.compile('phd\d+\.gif$')):
...
phd\d+\.gif$
regular expression would search for text starting with phd
, followed by 1 or more digits, followed by dot, followed by gif
at the end of the string.Note that you are using an outdated and unmaintained BeautifulSoup3
, switch to beautifulsoup4
:
pip install beautifulsoup4
Related Topics
Calling Module Method into Another Module in Ruby
How to Include Actionmailer Class in Rake Task
Automatically Logging Exceptions in Ruby
List Array of Days Between Two Dates
How to Use The "Self" Keyword in Rails
Rack: How to Store The Url as a Variable
How to Convert Ruby Formatted JSON String to JSON Hash in Ruby
Changing The Reading Order of Rubygem Sources
How to Programmatically Remove "Singleton Information" on an Instance to Make It Marshal
Including Methods to a Controller from a Plugin
How to Save Data with Has_Many: Through
Loading/Unloading/Updating Class in Ruby