oxen_printer 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +31 -0
  6. data/Rakefile +8 -0
  7. data/app/controllers/oxen/print_jobs_controller.rb +10 -0
  8. data/app/controllers/oxen/printers_controller.rb +33 -0
  9. data/app/jobs/background_printer_job.rb +14 -0
  10. data/app/models/ox_print_job.rb +47 -0
  11. data/app/models/ox_printable.rb +17 -0
  12. data/app/models/ox_printer.rb +36 -0
  13. data/app/policies/oxen/print_job_policy.rb +51 -0
  14. data/app/views/oxen/print_jobs/_form.html.haml +45 -0
  15. data/app/views/oxen/print_jobs/_print_job.html.haml +3 -0
  16. data/app/views/oxen/print_jobs/_print_jobs.html.haml +11 -0
  17. data/app/views/oxen/print_jobs/_printer_print_job.html.haml +12 -0
  18. data/app/views/oxen/print_jobs/_printer_print_jobs.html.haml +11 -0
  19. data/app/views/oxen/print_jobs/_show.html.haml +0 -0
  20. data/app/views/oxen/printers/_account_printer.html.haml +11 -0
  21. data/app/views/oxen/printers/_account_printers.html.haml +14 -0
  22. data/app/views/oxen/printers/_form.html.haml +31 -0
  23. data/app/views/oxen/printers/_new.html.haml +68 -0
  24. data/app/views/oxen/printers/_printer.html.haml +3 -0
  25. data/app/views/oxen/printers/_printers.html.haml +11 -0
  26. data/app/views/oxen/printers/_user_printer.html.haml +18 -0
  27. data/app/views/oxen/printers/_user_printers.html.haml +14 -0
  28. data/app/views/oxen/printers/create.html.haml +5 -0
  29. data/bin/rails +12 -0
  30. data/config/locales/da.yml +7 -0
  31. data/config/routes.rb +47 -0
  32. data/lib/action_printer.rb +90 -0
  33. data/lib/c4_label_print_provider.rb +215 -0
  34. data/lib/generators/printer/install_generator.rb +14 -0
  35. data/lib/generators/printer/printer_generator.rb +27 -0
  36. data/lib/generators/printer/templates/print_job.rb +21 -0
  37. data/lib/generators/printer/templates/printable.rb +13 -0
  38. data/lib/generators/printer/templates/printer.rb +15 -0
  39. data/lib/java_pdf/LICENSE +71 -0
  40. data/lib/java_pdf/LICENSE-LGPL-2.1.txt +504 -0
  41. data/lib/java_pdf/LICENSE-W3C-TEST +28 -0
  42. data/lib/java_pdf/README +92 -0
  43. data/lib/java_pdf/about.jar +0 -0
  44. data/lib/java_pdf/barbecue-1.5-beta1.jar +0 -0
  45. data/lib/java_pdf/barcodeprinter.jar +0 -0
  46. data/lib/java_pdf/browser.jar +0 -0
  47. data/lib/java_pdf/core-renderer-minimal.jar +0 -0
  48. data/lib/java_pdf/core-renderer.jar +0 -0
  49. data/lib/java_pdf/docbook.jar +0 -0
  50. data/lib/java_pdf/iText-2.0.8.jar +0 -0
  51. data/lib/java_pdf/itext-paulo-155.jar +0 -0
  52. data/lib/java_pdf/lib/LICENSE +71 -0
  53. data/lib/java_pdf/lib/LICENSE-LGPL-2.1.txt +504 -0
  54. data/lib/java_pdf/lib/LICENSE-W3C-TEST +28 -0
  55. data/lib/java_pdf/lib/README +92 -0
  56. data/lib/java_pdf/lib/core-renderer-minimal.jar +0 -0
  57. data/lib/java_pdf/lib/core-renderer.jar +0 -0
  58. data/lib/java_pdf/lib/iText-2.0.8.jar +0 -0
  59. data/lib/java_pdf/lib/itext-paulo-155.jar +0 -0
  60. data/lib/java_pdf/lib/minium.jar +0 -0
  61. data/lib/java_pdf/minium.jar +0 -0
  62. data/lib/java_pdf/pd4ml_demo.jar +0 -0
  63. data/lib/java_pdf/ss_css2.jar +0 -0
  64. data/lib/java_pdf/svg.jar +0 -0
  65. data/lib/oxen_printer.rb +8 -0
  66. data/lib/oxen_printer/cab_printer.rb +101 -0
  67. data/lib/oxen_printer/csv_printer.rb +12 -0
  68. data/lib/oxen_printer/engine.rb +19 -0
  69. data/lib/oxen_printer/html_printer.rb +12 -0
  70. data/lib/oxen_printer/label_printer.rb +12 -0
  71. data/lib/oxen_printer/pdf_printer.rb +66 -0
  72. data/lib/oxen_printer/version.rb +3 -0
  73. data/lib/print_drivers.rb +94 -0
  74. data/lib/print_engine.rb +135 -0
  75. data/lib/tasks/oxen_printer_tasks.rake +4 -0
  76. data/oxen_printer.gemspec +25 -0
  77. metadata +163 -0
@@ -0,0 +1,28 @@
1
+ W3C� DOCUMENT LICENSE
2
+ http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231
3
+
4
+ Public documents on the W3C site are provided by the copyright holders under the following license. By using and/or copying this document, or the W3C document from which this statement is linked, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions:
5
+
6
+ Permission to copy, and distribute the contents of this document, or the W3C document from which this statement is linked, in any medium for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the document, or portions thereof, that you use:
7
+
8
+ 1. A link or URL to the original W3C document.
9
+ 2. The pre-existing copyright notice of the original author, or if it doesn't exist, a notice (hypertext is preferred, but a textual representation is permitted) of the form: "Copyright � [$date-of-document] World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231"
10
+ 3. If it exists, the STATUS of the W3C document.
11
+
12
+ When space permits, inclusion of the full text of this NOTICE should be provided. We request that authorship attribution be provided in any software, documents, or other items or products that you create pursuant to the implementation of the contents of this document, or any portion thereof.
13
+
14
+ No right to create modifications or derivatives of W3C documents is granted pursuant to this license. However, if additional requirements (documented in the Copyright FAQ) are satisfied, the right to create modifications or derivatives is sometimes granted by the W3C to individuals complying with those requirements.
15
+
16
+ THIS DOCUMENT IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
17
+
18
+ COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.
19
+
20
+ The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to this document or its contents without specific, written prior permission. Title to copyright in this document will at all times remain with copyright holders.
21
+
22
+ ----------------------------------------------------------------------------
23
+
24
+ This formulation of W3C's notice and license became active on December 31 2002. This version removes the copyright ownership notice such that this license can be used with materials other than those owned by the W3C, moves information on style sheets, DTDs, and schemas to the Copyright FAQ, reflects that ERCIM is now a host of the W3C, includes references to this specific dated version of the license, and removes the ambiguous grant of "use". See the older formulation for the policy prior to this date. Please see our Copyright FAQ for common questions about using materials from our site, such as the translating or annotating specifications. Other questions about this notice can be directed to site-policy@w3.org.
25
+
26
+ Joseph Reagle <site-policy@w3.org>
27
+
28
+ Last revised $Id: LICENSE-W3C-TEST,v 1.1 2007/07/10 19:52:36 pdoubleya Exp $
@@ -0,0 +1,92 @@
1
+ Flying Saucer
2
+ Release R8pre2
3
+ Jan 27, 2008
4
+
5
+ https://xhtmlrenderer.dev.java.net
6
+ Please see project website for links to CVS, mailing lists, issue tracker, etc.
7
+
8
+
9
+ OVERVIEW
10
+ --------
11
+ Flying Saucer is a pure-Java library for rendering arbitrary well-formed XML
12
+ (or XHTML) using CSS 2.1 for layout and formatting, output to Swing panels,
13
+ PDF, and images.
14
+
15
+ Comprehensive documentation available in our user's guide,
16
+ https://xhtmlrenderer.dev.java.net/r7/users-guide-r7.html online or
17
+ located under www/r7/users-guide-r7.html in the source. The documentation is
18
+ current as of the R7 release. For information on our development releases
19
+ (R8preX), please contact us on our mailing lists.
20
+
21
+ If you end up using Flying Saucer for your own projects, please drop us an
22
+ email and tell us about it; it helps inform where we go next, and is interesting
23
+ and inspiring to other developers.
24
+
25
+
26
+ LICENSE
27
+ -------
28
+ Flying Saucer is distributed under the LGPL.Flying Saucer itself is licensed
29
+ under the GNU Lesser General Public License, version 2.1 or later, available at
30
+ http://www.gnu.org/copyleft/lesser.html. You can use Flying Saucer in any
31
+ way and for any purpose you want as long as you respect the terms of the
32
+ license. A copy of the LGPL license is included as license-lgpl-2.1.txt
33
+ in our distributions and in our source tree.
34
+
35
+ Flying Saucer uses a couple of FOSS packages to get the job done. A list
36
+ of these, along with the license they each have, is listed in the
37
+ LICENSE file in our distribution.
38
+
39
+
40
+ WHAT'S IN THE DISTRIBUTION
41
+ --------------------------
42
+
43
+ "BINARY" DISTRIBUTION
44
+ ---------------------
45
+ The binary distribution includes only those files you need to *use* Fying Saucer
46
+ in your own programs. The files are all Java JAR files and just need to be included
47
+ in the CLASSPATH as described in the User's Guide.
48
+
49
+ * core-renderer.jar: the main file, always in the classpath
50
+ * itext*.jar: support for generating PDF files as output
51
+ * minium*.jar: support for a custom anti-aliasing algorithm on output; may look better on some older JVMs
52
+
53
+ * core-renderer-minimal.jar: see note at end of this section
54
+
55
+ In principle, for an application using only Swing JPanels for output, you could
56
+ restrict yourself to using core-renderer.jar; however, we recommend you include
57
+ core*, itext* and minium* to avoid any linking errors/ClassNotFoundExceptions. When
58
+ in doubt, contact us via mail.
59
+
60
+ "Minimal" Core JAR File
61
+ -----------------------
62
+ We now include a "minimal" core JAR file which does not contain X/HTML entity
63
+ definitions and DTDs. If you have are not using entities, or have defined entities
64
+ inline in your documents, you might use this JAR file for a smaller total download
65
+ in your own applications--for example, for applets or webstartables. However, if you
66
+ can spare the extra size, we recommend you just use the core-renderer.jar, which,
67
+ while a little larger, will save you some time tracking down XHTML parsing-related
68
+ errors.
69
+
70
+ "SOURCE" DISTRIBUTION
71
+ ---------------------
72
+ The source distribution includes all the relevant source code, libraries and build
73
+ scripts to build and extend Flying Saucer. You'll need Ant if you want to use our
74
+ build scripts. There are some files under source control (notes, some docs) which
75
+ are not included in the source distribution. You can pull the whole lot from our source
76
+ tree by visiting our project website (URL at top of this doc) and extracting from
77
+ source control.
78
+
79
+
80
+
81
+
82
+ GETTING STARTED
83
+ ---------------
84
+ Please see the user's guide (URLs listed above) for info on how to get started.
85
+ At a minimum, you'll need core-renderer.jar in your classpath; itext*.jar
86
+ for PDF output and minium.jar for alternate anti-aliasing in the renderer.
87
+ Some good entry points (classes) are:
88
+ org.xhtmlrenderer.simple.XHTMLPanel
89
+ org.xhtmlrenderer.simple.PDFRenderer
90
+ org.xhtmlrenderer.simple.ImageRenderer
91
+
92
+
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,8 @@
1
+ require "oxen_printer/version"
2
+ require "oxen_printer/engine"
3
+ require "exceptions"
4
+ require "print_engine"
5
+
6
+ module OxenPrinter
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,101 @@
1
+ class CabPrinter < ActionPrinter
2
+ # J Job start
3
+ # S Set label size
4
+ # H Heat, speed, and printing method
5
+ # O Set print options
6
+ # T Text field definition
7
+ # B Barcode field definition
8
+ # G Graphic field definition
9
+ # I Image field definition
10
+ # A Amount of labels
11
+ def do_render(print_job,*args)
12
+ path = print_job.view_template_path
13
+ #TODO vi får en fejl her når vi begynder at mixe modellerne f.eks. Employee.find_by_sql('select * from products')
14
+ locals = { resource_class: print_job.printing_class.constantize, collection: print_job.printing_class.constantize.find_by_sql( print_job.print_sql) }
15
+ #
16
+ # TODO args must be mergeable ;)
17
+ # if args.flatten.compact.any?
18
+ # locals.merge! args
19
+ # end
20
+ # html = ActionView::Base.new(Rails.configuration.paths['app/views']).render(
21
+ # file: 'accounts/record.html.haml',
22
+ # # partial: 'test',
23
+ # formats: [:html],
24
+ # handlers: [:erb,:haml],
25
+ # locals: { variable: 'value' }
26
+ # )
27
+ #
28
+ of = text_file render( file: path, formats: [:html], handlers: [:haml,:erb], locals: locals)
29
+ logit :info, "created a label file: #{of.path}"
30
+ var = %x[ mv #{of.path} #{label_file_path} ]
31
+ logit :info, "moved it to: #{label_file_path}"
32
+ true
33
+ rescue => e
34
+ logit :error, "Rendering to TXT failed! The error was #{e.message}"
35
+ false
36
+ end
37
+
38
+ # CAB print last command is "A n" where n is the number of copies - an information which we add at print time
39
+ def do_print copies=1
40
+ result = nil
41
+ prn = printer
42
+ unless prn.command.blank?
43
+ if copies.to_i > 0
44
+ cpcmd = `echo 'A #{copies.to_i}\n' >> #{label_file_path}`
45
+ label_path = label_file_path.split("/")[-1]
46
+ pap = paper || prn.paper
47
+ cmd = prn.command.gsub(/\$1/, prn.cups_printer).gsub(/\$2/, label_file_path)
48
+ # Here we start actually printing
49
+ # $1 is the CUPS printer
50
+ # $2 is the PDF file_path_and_name
51
+ # $3 is the PDF filename
52
+ # the command being something along the lines of: lp -d $1 -o media=a4 $2
53
+ result = `#{cmd}`
54
+ end
55
+ end
56
+ !result.blank?
57
+ rescue
58
+ false
59
+ end
60
+
61
+ def file_path
62
+ label_file_path
63
+ end
64
+
65
+ end
66
+ #
67
+ #
68
+ # cmd = self.say_c4_label
69
+ #
70
+ # cmd = "
71
+ # J
72
+ # H 175,+0
73
+ # O R
74
+ # S l1;0,0,145,149,104;label
75
+ # G 5,5,0;R:140,100,.5,.5
76
+ # A 1
77
+ # "
78
+ #
79
+ # return false if cmd=="" # say_c4_label returned false due to some error
80
+ #
81
+ # #
82
+ # # TODO 2008-09-06 remove the tmp/labels_for_task_#{self.id.to_s} file
83
+ # # TODO 2008-09-09 make a Spool to show printer assigned jobs and printer status
84
+ # File.open("#{Rails.root}/public/documents/labels/label_for_stock_item_#{self.id.to_s}", "w") do |f|
85
+ # f.write(cmd)
86
+ # end
87
+ #
88
+ # # user=User.logged_in_user
89
+ # user=User.find(1) if Rails.env == "development"
90
+ # p = user.printers.on_paper("Pakkelabel").preferred_printer rescue []
91
+ # if p.any?
92
+ # p = p.first
93
+ # cmd = p.command.gsub(/\$1/, p.cups_printer).gsub(/\$2/, "#{Rails.root}/public/documents/labels/label_for_stock_item_#{self.id.to_s}")
94
+ # # return false unless self.upload_logo( p.cups_printer)
95
+ # value = `#{cmd}`
96
+ # puts cmd
97
+ # return true
98
+ # else
99
+ # return false
100
+ # end
101
+ #
@@ -0,0 +1,12 @@
1
+ class CsvPrinter < ActionPrinter
2
+ #IKKE FÆRDIG
3
+ def do_render(print_job)
4
+ path = print_job.view_template.path
5
+ locals = { resource_class: print_job.entity.constantize, collection: print_job.entity.constantize.find_by_sql( print_job.resources_sql) }
6
+ of = html_file render_to_string( path, locals: locals )
7
+ %x[ java -jar lib/java_pdf/barcodeprinter.jar #{of.path} #{pdf_file_path} ]
8
+ rescue
9
+ false
10
+ end
11
+
12
+ end
@@ -0,0 +1,19 @@
1
+ module OxenPrinter
2
+ class Engine < ::Rails::Engine
3
+ # config.autoload_paths << File.expand_path("../concerns", __FILE__)
4
+ #
5
+ # config.generators do |g|
6
+ # g.test_framework :rspec,
7
+ # :fixture => false,
8
+ # :fixtures => true,
9
+ # :view_specs => false,
10
+ # :helper_specs => false,
11
+ # :routing_specs => false,
12
+ # :controller_specs => true,
13
+ # :request_specs => true
14
+ # g.fixture_replacement :factory_girl, :dir => "spec/factories"
15
+ # g.assets false
16
+ # g.helper false
17
+ # end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ class HtmlPrinter < ActionPrinter
2
+ #IKKE FÆRDIG
3
+ def do_render(print_job)
4
+ path = print_job.view_template.path
5
+ locals = { resource_class: print_job.entity.constantize, collection: print_job.entity.constantize.find_by_sql( print_job.resources_sql) }
6
+ of = html_file render_to_string( path, locals: locals )
7
+ %x[ java -jar lib/java_pdf/barcodeprinter.jar #{of.path} #{pdf_file_path} ]
8
+ rescue
9
+ false
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ class LabelPrinter < ActionPrinter
2
+ #IKKE FÆRDIG
3
+ def do_render(print_job)
4
+ path = print_job.view_template.path
5
+ locals = { resource_class: print_job.entity.constantize, collection: print_job.entity.constantize.find_by_sql( print_job.resources_sql) }
6
+ of = html_file render_to_string( path, locals: locals )
7
+ %x[ java -jar lib/java_pdf/barcodeprinter.jar #{of.path} #{pdf_file_path} ]
8
+ rescue
9
+ false
10
+ end
11
+
12
+ end
@@ -0,0 +1,66 @@
1
+ class PdfPrinter < ActionPrinter
2
+ #IKKE FÆRDIG
3
+ def do_render(print_job,*args)
4
+ path = print_job.view_template_path
5
+ # TODO vi får en fejl her når vi begynder at mixe modellerne f.eks. Employee.find_by_sql('select * from products')
6
+ locals = { resource_class: print_job.printing_class.constantize, collection: print_job.printing_class.constantize.find_by_sql( print_job.print_sql) }
7
+ #
8
+ # TODO args must be mergeable ;)
9
+ # if args.flatten.compact.any?
10
+ # locals.merge! args
11
+ # end
12
+ # html = ActionView::Base.new(Rails.configuration.paths['app/views']).render(
13
+ # file: 'accounts/record.html.haml',
14
+ # # partial: 'test',
15
+ # formats: [:html],
16
+ # handlers: [:erb,:haml],
17
+ # locals: { variable: 'value' }
18
+ # )
19
+ #
20
+
21
+ of = html_file render( file: path, formats: [:html], handlers: [:haml,:erb], locals: locals)
22
+ logit :info, "created a html file: #{of.path}"
23
+ #
24
+ # calls java -jar with the oxen_printer gem lib/java_pdf/barcodeprinter.jar - as in java -jar /Users/walther/Projects/Gems/oxen_printer/lib/java_pdf/barcodeprinter.jar $1 $2
25
+ var = %x[ bin/printer_cmd.sh #{of.path} #{pdf_file_path} ]
26
+ logit :info, "converted the html file to a PDF file: #{pdf_file_path}"
27
+ true
28
+ rescue => e
29
+ logit :error, "Rendering to PDF failed! The error was #{e.message}"
30
+ false
31
+ end
32
+
33
+ def do_print copies
34
+ result = nil
35
+ prn = printer
36
+ unless prn.command.blank?
37
+ pdf_path = pdf_file_path.split("/")[-1]
38
+ pap = paper || prn.paper
39
+ cmd = prn.command.gsub( /\$1/, prn.cups_printer ).gsub( /\$2/, pap ).gsub( /\$3/, pdf_file_path ).gsub( /\$4/, pdf_path )
40
+ if copies > 1
41
+ cmdargs = cmd.split(" ")
42
+ f = cmdargs.pop
43
+ cmdargs.push "-n", copies, f
44
+ cmd = cmdargs.join(" ")
45
+ end
46
+ # Here we start actually printing
47
+ # $1 is the CUPS printer
48
+ # $2 is the PDF file_path_and_name
49
+ # $3 is the PDF filename
50
+ # the command being something along the lines of: lp -d $1 -o media=a4 $2
51
+ return `#{cmd}`
52
+ end
53
+ rescue
54
+ false
55
+ end
56
+
57
+ def file_path
58
+ pdf_file_path
59
+ end
60
+
61
+ def get_file_type
62
+ "application/pdf"
63
+ end
64
+
65
+
66
+ end
@@ -0,0 +1,3 @@
1
+ module OxenPrinter
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,94 @@
1
+ # encoding: UTF-8
2
+ #/* - - - - - - - - - - - - - - - - - - - - -
3
+ #
4
+ # Title : WEB Appliances Crest Inc, Web Form Framework
5
+ # Author : Enrique Phillips
6
+ # URL : http://www.wac.bz
7
+ #
8
+ #- - - - - - - - - - - - - - - - - - - - - */
9
+ require 'action_printer'
10
+
11
+ module PrintDrivers
12
+
13
+ include Exceptions
14
+
15
+ def self.included(base)
16
+
17
+ # build PDF or somehow prepare printer output
18
+ def rendered_on(*args)
19
+ begin
20
+ update_column(:state, "rendering")
21
+
22
+ # TODO 2013-06-08 set the action_printer with respect to the selected output & printer
23
+ action_printer = case print_driver
24
+ when :pdf, "pdf"
25
+ require 'oxen_printer/pdf_printer'
26
+ PdfPrinter.new(printer, paper)
27
+ when :cab, "cab"
28
+ require 'oxen_printer/cab_printer'
29
+ CabPrinter.new(printer, paper)
30
+ when :label, "label"
31
+ require 'oxen_printer/label_printer'
32
+ LabelPrinter.new(printer, paper)
33
+ when :html, "html"
34
+ require 'oxen_printer/html_printer'
35
+ HtmlPrinter.new(printer, paper)
36
+ when :csv, "csv"
37
+ require 'oxen_printer/csv_printer'
38
+ CsvPrinter.new(printer, paper)
39
+ end
40
+ rescue => e
41
+ logit :error, "assigning printer driver failed - #{e.message}"
42
+ return nil
43
+ end
44
+
45
+ # print_job.action_printer.printer = print_job.printer
46
+ # print_job.cycle if
47
+ return action_printer if action_printer.do_render(self,args)
48
+ nil
49
+ end
50
+
51
+ #
52
+ # called from the perform on the print_job
53
+ # print_with will use the action_printer to build the print
54
+ # and return the resulting filepath
55
+ #
56
+ def print_with action_printer
57
+ update_column(:state, "printing")
58
+ if action_printer && action_printer.do_print(copies)
59
+ update_column(:state, 'done')
60
+ action_printer.file_path
61
+ else
62
+ update_column(:state, 'error printing')
63
+ raise PrintJobPrintingError
64
+ end
65
+ end
66
+
67
+ def send_with action_printer, context
68
+ begin
69
+ update_column(:state, 'sending')
70
+ if action_printer && action_printer.send_print_file( context)
71
+ update_column(:state, 'done')
72
+ action_printer.file_path
73
+ else
74
+ update_column(:state, 'error sending')
75
+ raise PrintJobPrintingError
76
+ end
77
+ rescue => e
78
+ end
79
+ end
80
+
81
+ # q%{
82
+ # Problem with CUPS printer definitions - losing knowledge of attached printers
83
+ #
84
+ # D [08/Dec/2008:16:20:25 +0100] cupsdAuthorize: No authentication data provided.
85
+ # D [08/Dec/2008:16:20:25 +0100] Print-Job ipp://localhost/printers/HP_LaserJet_M3035_MPF_192.168.105.78
86
+ # D [08/Dec/2008:16:20:25 +0100] print_job: auto-typing file...
87
+ # D [08/Dec/2008:16:20:25 +0100] print_job: request file type is application/pdf.
88
+ # D [08/Dec/2008:16:20:25 +0100] Print-Job client-error-not-found: The printer or class was not found.
89
+ # D [08/Dec/2008:16:20:25 +0100] cupsdProcessIPPRequest: 8 status_code=406 (client-error-not-found)
90
+ # D [08/Dec/2008:16:20:25 +0100] cupsdCloseClient: 8
91
+ #
92
+ # }
93
+ end
94
+ end