Jayzen said over 4 years ago on Creating PDF files with WickedPDF :
thanks for your awesome video, i clone the source code form the current page, i want to apply the bootstrap to the pdf-page but failure, could you give some tips? Thanks a lot!

David Kimura said over 4 years ago on Creating PDF files with WickedPDF :
If you've set up the application with the `vendor/assests/stylesheets/pdf.css` and have this set to complile separately, you can download the CSS from https://getbootstrap.com/docs/3.3/customize/?id=08c164bd0450fe50e9bf and paste it into the `pdf.css`. This is what I'm using. You can probably also do the same for bootstrap 4.1, but the important bits would be the things selected where it is mainly the media styles, grid, typography, etc.

Jayzen said over 4 years ago on Creating PDF files with WickedPDF :
I download the bootstrap code from https://getbootstrap.com/docs/4.0/getting-started/contents/#css-files, i paste the bootstrap.css or bootstrap-grid.css to pdf.css , but i can't applay the "d-flex" function, can your find something wrong?

David Kimura said over 4 years ago on Creating PDF files with WickedPDF :
Personally, I would try to keep the styling in the email simple. Supporting rendering on different email clients is very difficult since there are definitely more email clients than browsers. Check out https://www.campaignmonitor.com/css for individual styling compatibility for mail clients.

David Ng said about 4 years ago on Creating PDF files with WickedPDF :
There is a typo in product_controllers.rb. Guess it should be template rather than **tempate**.

David Kimura said about 4 years ago on Creating PDF files with WickedPDF :
Thank You! Fixed the typo.

David Ng said about 4 years ago on Creating PDF files with WickedPDF :
I am writing a pdf report and want to have page break for every 2 items (with photos) in a loop. The normal [page break] works on html does not work in pdf file. Can you help ? David

David Kimura said about 4 years ago on Creating PDF files with WickedPDF :
In the HTML, you would wrap the two items in a div tag with a class like `new-page`. In the PDF's CSS, define the class like ``` .new-page { page-break-before: always; } ```

David Ng said almost 3 years ago on Creating PDF files with WickedPDF :
Hi, I am trying to add header and footer to the pdf file, but not luck. My controller code :?

//app/contollers/ sales_controller.rb

  def show
    respond_to do |format|
      format.html {}
      format.pdf do
        html = render_to_string(
          template: 'sales/show.pdf.erb', 
          page_size: 'A4',
          margin: { bottom: 25 },
          footer: {
            content: render_to_string('shared/footer')
          }
          layout: 'layouts/application.pdf.erb')
        pdf = WickedPdf.new.pdf_from_string(html)
        send_data(pdf, filename: "sale-#{@sale.our_ref}.pdf", type: 'application/pdf', 
          disposition: :attachment)
      end
    end
  end

// # app/view/shared/footer.html
PRD Footer
....

What is wrong ? 


David Kimura said almost 3 years ago on Creating PDF files with WickedPDF :
  This is an exert from their documentation examples.

pdf = WickedPdf.new.pdf_from_string(
  render_to_string('templates/pdf', layout: 'pdfs/layout_pdf.html'),
  footer: {
    content: render_to_string(
  		'templates/footer',
  		layout: 'pdfs/layout_pdf.html'
  	)
  }
)

Notice that the footer is being passed as a second parameter to the WickedPdf.new.pdf_from_string. In your example, it is getting passed into the first parameter and not the additional options.

David Ng said almost 3 years ago on Creating PDF files with WickedPDF :
Thanks for the prompt reply.  Two issues

1. image 
Same cod and same image, it works on the report, but image does not show on header.  The code is like this

 <header>
  <table style="height: 50px; line-height: 3px;">
    <tbody>
      <tr>
        <td style="width: 70px; padding-left: 00px;">
          <%=  wicked_pdf_image_tag image_url('HKT-logo.jpeg'), size: "125x125" %>
        </td>
        <td style="width: 800px;">
        <h2 style="font-size: 30px;">SITES TESTING CO., LTD.</h2>
        </td>
      </tr>
    </tbody>
  </table>
</header>

2. The variable
The same variable @sale is accessible in the report, but not accessible in footer.  
I tried HTML format, No Luck. The code

           header: { html: { template: 'users/header'....

Any ideas? 



David Ng said almost 3 years ago on Creating PDF files with WickedPDF :
Sorry, that is a typo.  I got it all work out.

Thanks a lot.  

Ismar said almost 2 years ago on Creating PDF files with WickedPDF :
Can you please help me use wicked_pdf with webpacker? it's possible? thanks.

David Kimura said almost 2 years ago on Creating PDF files with WickedPDF :
  what issues with wicked_pdf are you having? Webpacker doesn't really have a part in it as far as I know. Are you trying to serve image assets or something via Webpacker instead of the asset pipeline in the PDFs? 

Ismar said almost 2 years ago on Creating PDF files with WickedPDF :
Exactly, I have the following structure:

app/views/layouts/pdf.html.erb
    <%= wicked_pdf_stylesheet_pack_tag "pdf" -%>    
    <%= wicked_pdf_javascript_pack_tag "pdf" -%>

app/javascript/stylesheets/pdf.scss
@import "~bootstrap/scss/bootstrap";

div.alwaysbreak { page-break-before: always; }
div.nobreak:before { clear:both; }
div.nobreak { page-break-inside: avoid; }

app/javascript/packs/pdf.js
const images = require.context('../images', true);
import number_pages from "../vendor/number_pages.js"
window.addEventListener('load', function() {
  number_pages()
})

app/controllers/contracts_controller.rb
  def show
    respond_to do |format|
      format.html
      format.pdf do
        render(template: 'contracts/contract', pdf: @contract.name, disposition: 'inline')
      end
    end
  end

app/views/contracts/contract.pdf.erb
hello!

However, assets are only loaded with helpers wicked_pdf_stylesheet_link_tag  and wicked_pdf_javascript_include_tag 

The wicked_pdf_asset_pack_path method for imagesm also does not work correctly, resulting in a blank file when added.

Login to Comment