Skip to content

Commit

Permalink
Merge pull request #420 from jonsgreen/issue/update_metadata_with_tem…
Browse files Browse the repository at this point in the history
…plate_417

Resolves Issue #417: Can't Update / Add MetaData to PDF that uses Templa...
  • Loading branch information
bradediger committed Nov 5, 2012
2 parents 2f56ac3 + a4d15f5 commit 131082a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/prawn/core/document_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def initialize(options)

if options[:template]
@store = Prawn::Core::ObjectStore.new(:template => options[:template])
@store.info.data.merge!(options[:info]) if options[:info]
else
@store = Prawn::Core::ObjectStore.new(:info => options[:info])
end
Expand Down
13 changes: 13 additions & 0 deletions spec/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,19 @@
end
end

it "merges metadata info" do
filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
info = { :Title => "Sample METADATA",
:Author => "Me",
:Subject => "Not Working",
:CreationDate => Time.now }

@pdf = Prawn::Document.new(:template => filename, :info => info)
output = StringIO.new(@pdf.render)
hash = PDF::Reader::ObjectHash.new(output)
info.keys.each { |k| hash[hash.trailer[:Info]].keys.include?(k).should == true }
end

end

describe "Document#start_new_page with :template option" do
Expand Down

0 comments on commit 131082a

Please sign in to comment.