Class: Uniword::Mhtml::MhtmlPackage
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Uniword::Mhtml::MhtmlPackage
- Defined in:
- lib/uniword/mhtml/mhtml_package.rb
Overview
MHTML Package — MIME-based Word format (.mht, .mhtml, .doc).
IMPORTANT: This is COMPLETELY SEPARATE from OOXML Docx::Package.
-
OOXML uses ZIP + XML parts
-
MHTML uses MIME + HTML content
-
They share NO classes!
Instance Attribute Summary collapse
-
#filelist_xml ⇒ Object
Returns the value of attribute filelist_xml.
-
#images ⇒ Object
Returns the value of attribute images.
-
#raw_html_content ⇒ Object
Legacy accessors for backward compatibility.
Class Method Summary collapse
-
.from_file(path) ⇒ Document
Load MHTML file and return a populated Document model.
- .supported_extensions ⇒ Object
-
.to_file(document, path) ⇒ Object
Save MHTML Document to file.
Instance Method Summary collapse
-
#to_mime_parts ⇒ Object
Legacy compatibility: convert to MIME parts hash.
Instance Attribute Details
#filelist_xml ⇒ Object
Returns the value of attribute filelist_xml.
28 29 30 |
# File 'lib/uniword/mhtml/mhtml_package.rb', line 28 def filelist_xml @filelist_xml end |
#images ⇒ Object
Returns the value of attribute images.
28 29 30 |
# File 'lib/uniword/mhtml/mhtml_package.rb', line 28 def images @images end |
#raw_html_content ⇒ Object
Legacy accessors for backward compatibility
27 28 29 |
# File 'lib/uniword/mhtml/mhtml_package.rb', line 27 def raw_html_content @raw_html_content end |
Class Method Details
.from_file(path) ⇒ Document
Load MHTML file and return a populated Document model.
34 35 36 37 |
# File 'lib/uniword/mhtml/mhtml_package.rb', line 34 def self.from_file(path) parser = Infrastructure::MimeParser.new parser.parse(path) end |
.supported_extensions ⇒ Object
51 52 53 |
# File 'lib/uniword/mhtml/mhtml_package.rb', line 51 def self.supported_extensions [".mht", ".mhtml", ".doc"] end |
.to_file(document, path) ⇒ Object
Save MHTML Document to file.
43 44 45 46 47 48 49 |
# File 'lib/uniword/mhtml/mhtml_package.rb', line 43 def self.to_file(document, path) # Convert OOXML DocumentRoot to Mhtml::Document if needed document = Transformation::Transformer.new.docx_to_mhtml(document) if document.is_a?(Uniword::Wordprocessingml::DocumentRoot) packager = Infrastructure::MimePackager.from_document(document) packager.package(path) end |
Instance Method Details
#to_mime_parts ⇒ Object
Legacy compatibility: convert to MIME parts hash
56 57 58 59 60 61 62 |
# File 'lib/uniword/mhtml/mhtml_package.rb', line 56 def to_mime_parts { "html" => raw_html_content, "filelist" => filelist_xml, "images" => images || {}, } end |