Waiting for process to finish

I want to print a file from a ruby script using the cups-pdf printer, and I'm using Kernel#system like:

def self.lpr_pdf(ps)
   system("lpr", "-P", "PDF", "-o", "number-up=2", "-o",
     "media=a4", "#{ps}")
end

After the file has finished printing, I want to process it with pdfk further. How can I do this in ruby?

I want to print a file from a ruby script using the cups-pdf printer, and
I'm using Kernel#system like:

def self.lpr_pdf(ps)
  system("lpr", "-P", "PDF", "-o", "number-up=2", "-o",
    "media=a4", "#{ps}")
end

It seems you want to convert a PostScript file into a PDF file. Why
are you using CUPS for that? Why don't you just use Ghostscript's
ps2pdf?

Btw. the string interpolation for ps is superfluous. If you cannot be
sure that ps is a string then just use ps.to_s or ps.to_str.

After the file has finished printing, I want to process it with pdfk
further. How can I do this in ruby?

You would have to find the file and then do whatever you need to do.
But the approach using ps2pdf directly is much easier: you can control
the output file name and you know when it has finished.

Kind regards

robert

···

On Wed, Mar 30, 2016 at 5:23 PM, Joe Gain <joe.gain@gmail.com> wrote:

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/

I want to print a file from a ruby script using the cups-pdf printer, and
I'm using Kernel#system like:

def self.lpr_pdf(ps)
   system("lpr", "-P", "PDF", "-o", "number-up=2", "-o",
     "media=a4", "#{ps}")
end

It seems you want to convert a PostScript file into a PDF file. Why
are you using CUPS for that? Why don't you just use Ghostscript's
ps2pdf?

Danke, Robert!

Good idea. I was using cups-pdf to create two pages per sheet, but I should be doing that to the postscript file. After which I can create the pdf using ps2pdf.

Btw. the string interpolation for ps is superfluous. If you cannot be
sure that ps is a string then just use ps.to_s or ps.to_str.

It's not a string, rather a Pathname object.

After the file has finished printing, I want to process it with pdfk
further. How can I do this in ruby?

You would have to find the file and then do whatever you need to do.
But the approach using ps2pdf directly is much easier: you can control
the output file name and you know when it has finished.

Kind regards

robert

Thanks again, Joe

···

On 30.03.2016 18:34, Robert Klemme wrote:

On Wed, Mar 30, 2016 at 5:23 PM, Joe Gain <joe.gain@gmail.com> wrote:

--
Joe Gain
Jacob-Burckhardt-Str. 16
78464 Konstanz
Deutschland

t: +49 (0)7531 60389
m: +49 (0)160 4070680