itext-jruby 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,16 +5,17 @@ IText Pdf generation static java build packed to gem with some additional Ruby m
5
5
  == Usage
6
6
 
7
7
  === Instalation
8
- require 'itext-jruby'
8
+ require 'itext-jruby'
9
9
 
10
10
  == Example
11
- @source_pdf = File.expand_path('pdf_demo.pdf')
12
- @sample_image = File.expand_path('ja.jpg')
13
- @output_pdf = File.expand_path('out.pdf')
14
11
 
15
- @pdf_document = Itext.new(path: @path)
16
- @pdf_document.add_attachment @pathb
17
- @pdf_document.save(@out)
12
+ @source_pdf = File.expand_path('pdf_demo.pdf')
13
+ @sample_image = File.expand_path('ja.jpg')
14
+ @output_pdf = File.expand_path('out.pdf')
15
+
16
+ @pdf_document = Itext.new(path: @path)
17
+ @pdf_document.add_attachment @pathb
18
+ @pdf_document.save(@out)
18
19
 
19
20
  Find more examples in test directory.
20
21
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "itext-jruby"
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ernest Bursa"]
@@ -48,11 +48,18 @@ module Itext::Attachments
48
48
  def process_attachments
49
49
  @writer = @stamper.getWriter.to_java(Java::ComLowagieTextPdf::PdfWriter)
50
50
 
51
- @attachments.each do |attachment_path|
52
- attachment_name = Pathname.new(attachment_path).basename.to_s.to_java_string
51
+ @attachments.each do |attachment|
52
+ if attachment.is_a?(Hash)
53
+ attachment_path = attachment[:path]
54
+ attachment_name = attachment[:file_name]
55
+ elsif attachment.is_a?(String)
56
+ attachment_path = attachment
57
+ attachment_name = Pathname.new(attachment_path).basename
58
+ end
59
+
53
60
  attachment_spec = Java::ComLowagieTextPdf::PdfFileSpecification.fileEmbedded @writer,
54
- attachment_path.to_java_string,
55
- attachment_name,
61
+ attachment_path.to_s.to_java_string,
62
+ attachment_name.to_s.to_java_string,
56
63
  nil
57
64
  attachment_spec.addDescription attachment_name, false.to_java(:boolean)
58
65
  @stamper.addFileAttachment attachment_name, attachment_spec
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: itext-jruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ernest Bursa