lib/pdfs2pdf/utils.rb in pdfs2pdf-0.0.3 vs lib/pdfs2pdf/utils.rb in pdfs2pdf-0.0.4

- old
+ new

@@ -3,54 +3,10 @@ require 'pdf-reader' require_relative '../pdfs2pdf' module Pdfs2Pdf module Utils class << self - # Batch convert to pdf using `wkhtmltopdf` tool - # - # @param [Array<String>] files the input file list - # @param [String] base_dir the base directory - def to_pdfs(files) - files.each_with_index do |file, index| - puts "Convert file #{index + 1} of #{files.size} : #{file}" - to_pdf(file) - end - end - - # Convert '*.xhtml' or '*.html' to pdf - # - # @param filename input filename - def to_pdf(filename) - # @todo allow the options to be passed in so that we can use different theme - # '--no-background' - fail "Invalid input file #{filename}" unless File.exist?(filename) - command = [ - 'wkhtmltopdf', - '--margin-top 4', - '--margin-bottom 4', - '--margin-left 4', - '--margin-right 4', - # Note: working correctly but long URL - '--header-center "[webpage] :: [page]/[topage]"', - # TODO: not yet working properly - # "--header-center #{filename.gsub(base_dir,File.basename(base_dir))} \"[page]/[topage]\"", - # "--header-center #{filename} \"[page]/[topage]\"", - '--header-spacing 1', - '--header-font-size 8', - '--header-line', - '--footer-spacing 1', - '--footer-font-size 8', - '--footer-line', - "#{filename}", - "#{filename}.pdf", - '> /dev/null'] - _stdin, _stderr, status = Open3.capture3(command.join(' ')) - puts "FYI: to_pdf command: #{command.join(' ')}" - # Note: may be log it and continue - fail "Problem processing #{filename}" unless status.success? - end - # Create the 'pdfmarks' file for use with 'gs' utility # # @param [Array<String>] pdf_files the input file list (pdf) # @param [String] output_file the output filename default to 'pdfmarks' # @param [String] base_dir the base directory (TODO: review this code!) @@ -87,10 +43,9 @@ # # @param [Array<String>] list input file list # @param [String] pdfmarks the pdfmarks file default to 'pdfmarks' # @param [String] output_file the output pdf file def merge_pdfs(list, pdfmarks = 'pdfmarks', output_file = 'output.pdf') - # puts "FYI: merge_pdfs: your list: #{list}" _stdin, _stderr, status = Open3.capture3( 'gs', '-q', '-dNOPAUSE', '-dBATCH',