Create and save a PDF file
ldco2016 opened this issue · 5 comments
Hey guys I am not sure where the code under the heading of:
Create and save a PDF file is supposed to go.
This piece of code:
require 'prawn/labels'
names = ["Jordan", "Chris", "Jon", "Mike", "Kelly", "Bob", "Greg"]
Prawn::Labels.generate("names.pdf", names, :type => "Avery5160") do |pdf, name|
pdf.text name
end
Any class, controller or model should work. I would imagine.
@ldco2016 I'm not sure I understand your question. Can you give us some more details?
If you are looking for a full, runnable example of that piece of code you can checkout our tests:
https://github.com/madriska/prawn-labels/blob/master/test/features/generic_labels_test.rb
Does that help?
Hi Jordan,
I was referring to this code here:
require 'prawn/labels'
names = ["Jordan", "Chris", "Jon", "Mike", "Kelly", "Bob", "Greg"]
Prawn::Labels.generate("names.pdf", names, :type => "Avery5160") do |pdf, name|
pdf.text name
end
Where exactly is that supposed to go? Does this go in a yaml file? If so, what folder?
@ldco2016 nope this would not go in a yaml file. That's ruby code so you'd want to put it within a ruby script. Assuming you have prawn-labels
installed, you can drop that code into a file called labels.rb
, and run ruby labels.rb
from your console and it will create a pdf file with the name names.pdf
.
That being said it sounds like you are using this within a rails project. If that's the case then you should follow the instructions from the following section of the README:
https://github.com/madriska/prawn-labels#generating-labels-in-a-rails-controller
Thanks Jordan,
I am making some progress.