-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Hey, awesome project! Will probably end up using it some time soon. In the README you write
This does not contain any code to attach the XML to a PDF file, mainly because I have yet to find a ruby library to do that.
HexaPDF can do that.
Attaching is easy. See the documentation or unit tests.
Extraction:
irb(main):001> require "hexapdf"
=> true
irb(main):002> pdf = HexaPDF::Document.open("corpus-master/ZUGFeRDv2/correct/Mustangproject/MustangGnuaccountingBeispielRE-20190610_507.pdf")
=> <HexaPDF::Document:21960>
irb(main):003> pdf.files
=> #<HexaPDF::Document::Files:0x000000010337fbf0 @document=<HexaPDF::Document:21960>>
irb(main):004> pdf.files.each { |f| puts f }
#<HexaPDF::Type::FileSpecification:0x000000010337cc70>
=> #<HexaPDF::Document::Files:0x000000010337fbf0 @document=<HexaPDF::Document:21960>>
irb(main):005> pdf.files.first
=> #<HexaPDF::Type::FileSpecification [8, 0] value={:Type=>:Filespec, :F=>"zugferd-invoice.xml", :AFRelationship=>:Alternative, :UF=>"zugferd-invoice.xml", :Desc=>"Invoice metadata conforming to ZUGFeRD standard (http://www.ferd-net.de/front_content.php?idcat=231&lang=4)", :EF=>#<HexaPDF::Reference [17, 0]>}>
irb(main):006> pdf.files.first.embedded_file_stream
=> #<HexaPDF::Type::EmbeddedFile [107, 0] value={:Length=>10338, :Type=>:EmbeddedFile, :Subtype=>:"text/xml", :Params=>#<HexaPDF::Reference [239, 0]>}>fiber = obj.embedded_file_stream.stream_decoder
while fiber.alive? && (data = fiber.resume)
file << data
endI don't think it should be secretariat's job to do that, just wanted to let you (and others) know.
Metadata
Metadata
Assignees
Labels
No labels