4

I'm using Wicked_PDF GEM. Is it possible to set the document height to "AUTO" or something, So that it would change according to the count of created line items inside an order ?

And If not could you guide me to another tool or GEM to help me do so?

Orders.rb

  def show
    respond_to do |format|
      format.html
      format.pdf do
        render  pdf: @order.id.to_s,
        disposition: 'inline',
        layout: "reciept",
        template: "orders/showPDF.html.erb",
        show_as_html: params.key?('debug'), 
        page_height: 160,
        page_width: 80,
        margin:  {  top: 10,
                    bottom: 15,
                    left: 5,
                    right: 5 }
      end
    end
  end
Moataz Zaitoun
  • 729
  • 1
  • 7
  • 18
  • I also used wicked_pdf gem, I dont understand by setting document height to "AUTO"? Do you encounter some layout issue? You can manipulate rendering of data via CSS codes. – aldrien.h Aug 09 '16 at 05:52
  • @aldrien.h I'm not encountering any layout issues, The thing is I want to create a PDF for a receipt -like super markets receipts- of order that containing undetermined number of line items and i want the document height to be increasing dynamically according to the number of created line items as I want all items to be in one page. Got it? – Moataz Zaitoun Aug 09 '16 at 15:43
  • 1
    Wicked PDF only allowing me to set a fixed width and height for the generated document, And I must set both or it will set the document size automatically to A4. – Moataz Zaitoun Aug 09 '16 at 15:56
  • i understand, i think wicked_pdf is built for printing purposes, not the way you want it to be (viewing long like receipt style). try to message on wicked_pdf repository, maybe someone gives you another idea. – aldrien.h Aug 10 '16 at 02:22
  • @MoatazZaitoun did you find the solution for this? I'm having the same issue, I'm also trying to print a receipt ticket, when I set the height to an specific height, and set the css to height: auto; it cuts where it needs but if the content is bigger, the pdf is getting trimmed. – Jose Miguel Ledón Oct 19 '16 at 00:12
  • @JoseMiguelLedón I've used Prawn to generate pdfs, Although It's harder but It's way powerful than Wicked. I set a variable for the line Item height then I set the pdf height to this (variable multiplied by the number of generated line items plus header and footer), It was very hard logic to get, I wish the creator of the Wicked pdf gem consider this. – Moataz Zaitoun Oct 19 '16 at 10:57

0 Answers0