Closed restebanez closed 12 years ago
Hi,
That comment means that any of the types [String, File, StringIO, Tempfile] are acceptable for the :pdf option so you can try:
@pdftk.cat([{:pdf => StringIO.new(pdf_raw_content)}, {:pdf=> pdf_file_path}])
Also, the types should be able to be mixed as well, 1 as a StringIO, 1 as a path, it should all work correctly.
Let me know if that works. ~ Tom
PS. I need to finish up a few last things on this gem before I release it. Hoping to find the time to get to that soon.
hi @tcocca
Thanks for your fast answer. Unfortunately I can't make it work in my machine, i think this piece of code may proof a bug:
@pdftk = ActivePdftk::Wrapper.new
pir="/Users/restebanez/ctms-sandbox-PIR.pdf"
string_file=File.read(pir)
raw=@pdftk.cat([{:pdf => StringIO.new(string_file)},{:pdf=> pir}])
ActivePdftk::CommandError: sh: StringIO:0x007faa006c4f60: No such file or directory
#!# While executing #=> `pdftk B=#<StringIO:0x007faa006c4f60> C=/Users/restebanez/ctms-sandbox-PIR.pdf cat B C output -`
It looks like active_pdftk thinks that #StringIO:0x007faa006c4f60 is a file name. I'm using Ruby 1.9.2p290 in a OS X 10.7
Thanks,
Rodrigo
Ah, that documentation line might be a typo actually.
Looking through my specs here: https://github.com/tcocca/active_pdftk/blob/master/spec/active_pdftk/wrapper_spec.rb#L218-230
However in you code above, you were trying to cat a file that you read in to StringIO onto the same file that you just read. So that code above (if it was working) would just return StringIO of the file twice ...
I'm not sure what exactly you are trying to do here.
Anyway take a look through the docs and figure out if its even possibly to send input to #cat or #shuffle (i'm not sure it is possible to give those commands stdin like that).
~ Tom
Thinking about it, there isn't any command that can accept more than one file as STDIN option because there is only one STDIN. A workaround would be to create a tmp file whenever it receives a StringIO.
I should have said that my code was only for showing the bug, yeah the output would generate the same PDF twice.
Thanks for your help
Rodrigo
Hi,
I'm not sure if i understand this comment in /lib/active_pdftk/wrapper.rb correctly:
# @option ranges [String, File, StringIO, Tempfile] :pdf optional unless multiple inputs are required the file to run the range on.
Does it mean i can pass any of those data types?
I'd like to pass a StringIO instead of a pdf path, but unfortunately it doesn't work:
Thanks,
Rodrigo