Example: /Compression/Old ZipMBS class/create epub file

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/Compression/Old ZipMBS class/create epub file


Required plugins for this example: MBS Compression Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Compression/Old ZipMBS class/create epub file

This example is the version from Sun, 17th Mar 2012.

Project "create epub file.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
Const Container = "<?xml version=""1.0"" encoding=""UTF-8""?>\r <container\r xmlns=""urn:oasis:names:tc:opendocument:xmlns:container""\r version=""1.0"">\r <rootfiles>\r <rootfile\r full-path=""content.opf""\r media-type=""application/oebps-package+xml""/>\r </rootfiles>\r </container>"
Const Content_NCX = "<?xml version=""1.0"" encoding=""UTF-8""?>\r <!DOCTYPE ncx \r PUBLIC ""-//NISO//DTD ncx 2005-1//EN"" ""http://www.daisy.org/z3986/2005/ncx-2005-1.dtd"">\r <ncx\r xmlns=""http://www.daisy.org/z3986/2005/ncx/""\r version=""2005-1""\r xml:lang=""de-DE"">\r <head>\r <meta name=""dc:Title"" content=""Hello World""/>\r <meta name=""dtb:uid"" content=""id_Hello_World""/>\r </head>\r <docTitle>\r <text>Hello World</text>\r </docTitle>\r <navMap>\r <navPoint playOrder=""1"" id=""id_Hello_World_01"">\r <navLabel>\r <text>Hello World</text>\r </navLabel>\r <content src=""content.xhtml""/>\r </navPoint>\r </navMap>\r </ncx>"
Const Content_OPF = "<?xml version=""1.0"" encoding=""UTF-8""?>\r <package\r xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""\r xmlns:dc=""http://purl.org/dc/elements/1.1/""\r xmlns:opf=""http://www.idpf.org/2007/opf""\r xmlns=""http://www.idpf.org/2007/opf""\r version=""2.0""\r unique-identifier=""BookId"">\r <metadata>\r <dc:language xsi:type=""dcterms:RFC3066"">de-DE</dc:language>\r <dc:title>Hello World</dc:title>\r <dc:identifier id=""BookId"">id_Hello_World</dc:identifier>\r </metadata>\r <manifest>\r <item id=""ncx"" href=""content.ncx"" media-type=""application/x-dtbncx+xml""/>\r <item id=""Datei_1"" href=""content.xhtml"" media-type=""application/xhtml+xml""/>\r </manifest>\r <spine toc=""ncx"">\r <itemref idref=""Datei_1""/>\r </spine>\r </package>"
Const Content_XML = "<?xml version=""1.0"" encoding=""UTF-8""?>\r <!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.1//EN"" \r ""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"">\r <html xmlns=""http://www.w3.org/1999/xhtml"">\r <head>\r <meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8""/>\r <link rel=""schema.DC"" href=""http://purl.org/dc/elements/1.1/""/>\r <title>Hello World</title>\r <meta name=""DC.identifier"" content=""id_Hello_World""/>\r </head>\r <body>\r <h1>Hello World</h1>\r <p>Ein Beispieltext.</p>\r </body>\r </html>"
EventHandler Sub Open() dim s as FolderItem = SpecialFolder.Desktop.Child("test.epub") dim z as new ZipMBS(s,0) AddFile z, "mimetype", "application/epub+zip", false // identifier AddFile z, "META-INF/container.xml", Container, true // points to content files below AddFile z, "content.opf", Content_OPF, true AddFile z, "content.ncx", Content_NCX, true // table of content AddFile z, "content.xhtml", Content_XML, true // actual content z.Close quit End EventHandler
Sub AddFile(z as ZipMBS, path as string, content as string, Compress as Boolean) dim d as new date dim info as ZipFileInfoMBS info=new ZipFileInfoMBS info.SetDate d info.ExternalFileAttributes=0 info.InternalFileAttributes=0 info.DosDate=0 if Compress then z.CreateFile path, info, "", "", "", z.MethodDeflated, z.CompressionBestCompression else z.CreateFile path, info, "", "", "", z.MethodNone, 0 end if z.Write content z.CloseFile End Sub
End Class
End Project

See also:

The items on this page are in the following plugins: MBS Compression Plugin.


💬 Ask a question or report a problem