Search code examples
c++htmlmime

How to generate mhtml file in C++?


I want to generate multimedia documents(so called MIME) defined by Html.
So I can pack associated files (e.g. htm, images…) in a single mhtml (MIME) file here(like: mime_example.doc).
But I only got php implementation here: A basic MIME 1.0 class helper
(in the "A basic MIME 1.0 class helper" section)
And the method to generate the mhtml file:

header('Content-Type: application/msword');
header('Content-disposition: filename=mydocument.doc')
$doc = New mime10class();
$doc->addFile('mydocument.htm','text/html; charset="utf-8"','Hello, world !');
$doc->addFile('subdir\anotherfile.htm','text/html; charset="utf-8"','Hi there.');
echo $doc->getFile(); 

But how to implement this using c++?
(Helpful link: MIME Encapsulation of Aggregate Documents, such as HTML (MHTML))


Solution

  • I am not sure whether is a separate opensource library which do this, but https://github.com/coolwanglu/pdf2htmlEX it convert PDF to html and it got option to pack associated files (e.g. htm, images…) in a single html file (by default it does not), may be you can use code from this project as its opensource!