1
votes

Working on a PDF and (in both development and production) the PDF will render only the cover page:

https://www.patchvault.org/lodges/456a-powhatan/issues/checklist.pdf

Debug shows the rest of the content, without the cover page:

https://www.patchvault.org/lodges/456a-powhatan/issues/checklist.pdf?debug=true

This intermittently will render fine, or show subsequent pages without images (typical of when it does render), but mostly it just renders the cover. Disabling the cover in the controller action gets the other pages to render as expected. Here's the controller action (I have attachment disabled for development purposes):

def checklist
    # PDF Checklist of issues from a lodge
    @issues = @issueable.issues.non_event_issues.ordered_issues
    @event_issues = @issueable.issues.event_issues.order(issue_number: :asc)
    respond_to do |format|
      format.html
      format.pdf do
        render pdf:   "#{@issueable.slug}_checklist",
        # disposition:  'attachment',
        template:     'issues/checklist.pdf.erb',
        cover:        render_to_string('issues/checklist_cover.pdf.erb'),
        dpi:          '150',
        background:   true,
        header:       {html: {template: 'layouts/_checklist_header'}, spacing: 5 },
        footer:       {html: {template: 'layouts/_checklist_footer'}, spacing: 0 },
        margin:       {top: 30, bottom: 20, left: 10, right: 10},
        show_as_html: params.key?('debug')
      end
    end
  end

and here's is the output in development to wkhtmltopdf:

"***************[\"/Users/jathayde/Development/Meticulous/Products/patchvault/vendor/cache/ruby/2.4.0/gems/wkhtmltopdf-binary-0.12.3.1/bin/wkhtmltopdf\", \"-q\", \"--dpi\", \"150\", \"--margin-top\", \"30\", \"--margin-bottom\", \"20\", \"--margin-left\", \"10\", \"--margin-right\", \"10\", \"--header-spacing\", \"5\", \"--header-html\", \"file:////var/folders/25/q7y1f5px3xz8bw7sdzcyrz_c0000gn/T/wicked_header_pdf20180312-17436-12xyhl7.html\", \"--footer-spacing\", \"0\", \"--footer-html\", \"file:////var/folders/25/q7y1f5px3xz8bw7sdzcyrz_c0000gn/T/wicked_footer_pdf20180312-17436-eldx10.html\", \"cover\", \"/var/folders/25/q7y1f5px3xz8bw7sdzcyrz_c0000gn/T/wicked_cover_pdf20180312-17436-y1d6wy.html\", \"file:////var/folders/25/q7y1f5px3xz8bw7sdzcyrz_c0000gn/T/wicked_pdf20180312-17436-tr8hae.html\", \"/var/folders/25/q7y1f5px3xz8bw7sdzcyrz_c0000gn/T/wicked_pdf_generated_file20180312-17436-18ftq2q.pdf\"]***************"

The cover is a full HTML page as it wouldn't render styles without being one and calling the CSS file.

Software notes:

  • Ruby 2.4.0p0
  • Rails 5.1.5
  • Patch images are served from S3.
  • Gems, etc are cached to vendor/cache
1

1 Answers

0
votes

The only solution I've found is to remove the Google font call in the cover page, and only load fonts on the inside page template.