Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using prawn.icon #124

Open
alliedarmour opened this issue Aug 25, 2020 · 2 comments
Open

Using prawn.icon #124

alliedarmour opened this issue Aug 25, 2020 · 2 comments

Comments

@alliedarmour
Copy link

Hey, first thanks for the great gem!
I recently tried to use the prawn-icon gem to include Font Awesome icons in my PDF document.

The issue is the following: I need the icons for my table, so I'm using the table_icon helper:

prawn_document(page_layout: :landscape, page_size: "A6", filename: "Bestellungen_#{I18n.l(Date.today)}") do |pdf|
    # pdf.font_families.update(
    #     "Font Awesome" => { :normal => Rails.root.join("app", "assets", "fonts", "fa-solid-900.ttf") }
    # )

    @orders.each do |order|
        data = [ 
            ["Salat", "Suppe", "Dessert"],
            [pdf.table_icon('fas-birthday-cake')]
        ]
        pdf.font("Helvetica", size: 20, style: :bold) do 
            pdf.float { pdf.text(order.user.name, align: :left) }
            pdf.text(l(order.day), align: :right)
        end
        pdf.move_down 10
        pdf.table(data)
    end
end

Without changing the font for the whole document to Font Awesome with pdf.font "Font Awesome", I keep getting the following error:

Your document includes text that's not compatible with the Windows-1252 character set.
If you need full UTF-8 support, use external fonts instead of PDF's built-in fonts.

But unfortunately it neither works when I just change the cell font type like this:

  cell_1 = pdf.make_cell(pdf.table_icon('fas-birthday-cake'))
  cell_1.font = "Font Awesome"

Is there anything I can do to use the gem with prawn-rails? Or might it be a problem with prawn-table?

@jessedoyle
Copy link
Contributor

Hi Guys! I'm the author of prawn-icon and I've done a bit of research here.

It looks like #60 was merged in years ago, but a release was never made on Rubygems. This PR should resolve the issue that @alliedarmour is running into.

Can someone please cut a new release on Rubygems?

@alliedarmour
Copy link
Author

I can confirm that it's working with that PR without problems. A new release would be awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants