Reputation: 72
I'm using Docsplit
to split pdf
into pages using
Docsplit.extract_pages("my.pdf").
But I want to limit the pages to 4. I tried
Docsplit.extract_pages("my.pdf", :pages => 1..4)
which is not working..
Can anyone suggest me what to do
Upvotes: 2
Views: 1890
Reputation: 152
remove the ESCAPEs from the lib/docscript/page_extractor.rb:18 file like so:
pdftk #{ESCAPE[pdf]} burst output #{ESCAPE[page_path]} 2>&1"
change to :
pdftk #{pdf} burst output #{page_path} 2>&1"
However, the easiest solution IMHO would be to just use to pdftk binary directly, it's quite straightforward: to extract pages 1-4, you could use this snippet :
in_file = 'IN.pdf'
range = 1..4
range_s = range.to_s.gsub('..', '-')
cmd = "pdftk.exe #{in_file} cat #{range_s} output pages#{range_s}.pdf"
res = `cmd`.chomp
This works, provided that the pdftk executable is in your PATH
Upvotes: 1