Post by code on Apr 26, 2022 3:36:02 GMT
Hi,
To build a simple ebook(.epub) you have to zip some files
(book.opf ,book.ncx etc)Look on the internet for the epub
format.
I build a simple program(ep.exe)wich zip to 8 chapters
(chapter1,chapter2,etc)
The ep.exe(see attachment) has to be in the same
directory as your .bas file
I may not so clear about this....(its the way it is for now)
The .bas file :
The ep.exe(see attachment) is free to use/spread/redistribute
the .bas file will produce two chapters...and the output will be ebook123.epub (RUN"ep ebook123.epub")
Good luck!
ep.exe (268.03 KB)
Regards,
code
To build a simple ebook(.epub) you have to zip some files
(book.opf ,book.ncx etc)Look on the internet for the epub
format.
I build a simple program(ep.exe)wich zip to 8 chapters
(chapter1,chapter2,etc)
The ep.exe(see attachment) has to be in the same
directory as your .bas file
I may not so clear about this....(its the way it is for now)
The .bas file :
nomainwin
WindowWidth=800
WindowHeight=600
button #scr, "Make epub... ", [b1], UL, 550, 500
texteditor #scr.te, 10, 10, 600, 280
texteditor #scr.te2, 10, 300, 600, 300
open "epub..." for graphics_nsb as #scr
print #scr.te, "Type here some text..."
print #scr.te2, "Chapter2..."
print #scr.te2, "<p><a href='http://www.justbasic.com'>http://www.justbasic.com</a></p>"
print #scr, "fill brown"
print #scr, "flush"
wait
[b1]
open "container.xml" for output as #tf2
print #tf2,"<?xml version="+chr$(34)+"1.0"+chr$(34)+" encoding="+chr$(34)+"utf-8"+chr$(34)+"?>"
print #tf2,"<container version="+chr$(34)+"1.0"+chr$(34)+" xmlns="+chr$(34)+"urn:oasis:names:tc:opendocument:xmlns:container"+chr$(34)+">"
print #tf2," <rootfiles>"
print #tf2," <rootfile full-path="+chr$(34)+"OEBPS/book.opf"+chr$(34)+" media-type="+chr$(34)+"application/oebps-package+xml"+chr$(34)+"/>"
print #tf2," </rootfiles>"
print #tf2,"</container>"
close #tf2
open "mimetype" for output as #tf
print #tf,"application/epub+zip"
close #tf
open "book.opf" for output as #tf3
print #tf3,"<?xml version="+chr$(34)+"1.0"+chr$(34)+" encoding="+chr$(34)+"utf-8"+chr$(34)+"?>"
print #tf3,"<package version="+chr$(34)+"2.0"+chr$(34)+" xmlns="+chr$(34)+"http://www.idpf.org/2007/opf"+chr$(34)+" unique-identifier="+chr$(34)+"abcdef"+chr$(34)+">"
print #tf3,"<metadata xmlns:dc="+chr$(34)+"http://purl.org/dc/elements/1.1/"+chr$(34)+" xmlns:opf="+chr$(34)+"http://www.idpf.org/2007/opf"+chr$(34)+">"
print #tf3," <dc:title>Hello</dc:title>"
print #tf3," <dc:creator opf:role="+chr$(34)+"aut"+chr$(34)+">not set</dc:creator>"
print #tf3," <dc:language>en-US</dc:language>"
print #tf3," <dc:identifier id="+chr$(34)+"abcdef"+chr$(34)+">abcdef</dc:identifier>"
print #tf3," </metadata>"
print #tf3,"<manifest>"
print #tf3," <item id="+chr$(34)+"chapter1"+chr$(34)+" href="+chr$(34)+"chapter1.xhtml"+chr$(34)+" media-type="+chr$(34)+"application/xhtml+xml"+chr$(34)+" />"
print #tf3," <item id="+chr$(34)+"chapter2"+chr$(34)+" href="+chr$(34)+"chapter2.xhtml"+chr$(34)+" media-type="+chr$(34)+"application/xhtml+xml"+chr$(34)+" />"
print #tf3," <item id="+chr$(34)+"ncx"+chr$(34)+" href="+chr$(34)+"book.ncx"+chr$(34)+" media-type="+chr$(34)+"application/x-dtbncx+xml"+chr$(34)+" />"
print #tf3,"</manifest>"
print #tf3," <spine toc="+chr$(34)+"ncx"+chr$(34)+">"
print #tf3," <itemref idref="+chr$(34)+"chapter1"+chr$(34)+" />"
print #tf3," <itemref idref="+chr$(34)+"chapter2"+chr$(34)+" />"
print #tf3," </spine>"
print #tf3,"</package>"
close #tf3
open "book.ncx" for output as #tf4
print #tf4,"<?xml version="+chr$(34)+"1.0"+chr$(34)+" encoding="+chr$(34)+"utf-8"+chr$(34)+"?>"
print #tf4,"<ncx version="+chr$(34)+"2005-1"+chr$(34)+" xml:lang="+chr$(34)+"en"+chr$(34)+" xmlns="+chr$(34)+"http://www.daisy.org/z3986/2005/ncx/"+chr$(34)+">"
print #tf4," <head>"
print #tf4," <meta name="+chr$(34)+"dtb:uid"+chr$(34)+" content="+chr$(34)+"abcdef"+chr$(34)+" />"
print #tf4," <meta name="+chr$(34)+"dtb:depth"+chr$(34)+" content="+chr$(34)+"1"+chr$(34)+" />"
print #tf4," <meta name="+chr$(34)+"dtb:totalPageCount"+chr$(34)+" content="+chr$(34)+"0"+chr$(34)+" />"
print #tf4," <meta name="+chr$(34)+"dtb:maxPageNumber"+chr$(34)+" content="+chr$(34)+"0"+chr$(34)+" />"
print #tf4," </head>"
print #tf4,"<docTitle>"
print #tf4," <text>Book...</text>"
print #tf4," </docTitle>"
print #tf4," <navMap>"
print #tf4," <navPoint id="+chr$(34)+"chapter1"+chr$(34)+" playOrder="+chr$(34)+"1"+chr$(34)+">"
print #tf4," <navLabel><text>Chapter 1</text></navLabel>"
print #tf4," <content src="+chr$(34)+"chapter1.xhtml"+chr$(34)+"/>"
print #tf4," </navPoint>"
print #tf4," <navPoint id="+chr$(34)+"chapter2"+chr$(34)+" playOrder="+chr$(34)+"1"+chr$(34)+">"
print #tf4," <navLabel><text>Chapter 2</text></navLabel>"
print #tf4," <content src="+chr$(34)+"chapter2.xhtml"+chr$(34)+"/>"
print #tf4," </navPoint>"
print #tf4," </navMap>"
print #tf4,"</ncx>"
close #tf4
print #scr.te, "!contents? vc1$";
open "chapter1.xhtml" for output as #tf9
print #tf9,"<?xml version="+chr$(34)+"1.0"+chr$(34)+" encoding="+chr$(34)+"utf-8"+chr$(34)+"?>"
print #tf9,"<!DOCTYPE html PUBLIC "+chr$(34)+"-//W3C//DTD XHTML 1.1//EN"+chr$(34)+" "+chr$(34)+"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"+chr$(34)+">"
print #tf9,"<html xmlns="+chr$(34)+"http://www.w3.org/1999/xhtml"+chr$(34)+" xml:lang="+chr$(34)+"en"+chr$(34)+">"
print #tf9," <head>"
print #tf9,"<meta http-equiv="+chr$(34)+"Content-Type"+chr$(34)+" content="+chr$(34)+"application/xhtml+xml; charset=utf-8"+chr$(34)+" />"
print #tf9," <title>Simple ePub.... </title>"
print #tf9," </head>"
print #tf9,"<body>"
print #tf9, vc1$
print #tf9,"</body>"
close #tf9
print #scr.te2, "!contents? vc2$";
open "chapter2.xhtml" for output as #tf99
print #tf99,"<?xml version="+chr$(34)+"1.0"+chr$(34)+" encoding="+chr$(34)+"utf-8"+chr$(34)+"?>"
print #tf99,"<!DOCTYPE html PUBLIC "+chr$(34)+"-//W3C//DTD XHTML 1.1//EN"+chr$(34)+" "+chr$(34)+"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"+chr$(34)+">"
print #tf99,"<html xmlns="+chr$(34)+"http://www.w3.org/1999/xhtml"+chr$(34)+" xml:lang="+chr$(34)+"en"+chr$(34)+">"
print #tf99," <head>"
print #tf99,"<meta http-equiv="+chr$(34)+"Content-Type"+chr$(34)+" content="+chr$(34)+"application/xhtml+xml; charset=utf-8"+chr$(34)+" />"
print #tf99," <title>Simple ePub.... </title>"
print #tf99," </head>"
print #tf99,"<body>"
print #tf99, vc2$
print #tf99,"</body>"
close #tf99
run"ep ebook123.epub"
b$ = "ebook123.epub"
RUN "rundll32.exe url.dll,FileProtocolHandler ";b$
wait
The ep.exe(see attachment) is free to use/spread/redistribute
the .bas file will produce two chapters...and the output will be ebook123.epub (RUN"ep ebook123.epub")
Good luck!
ep.exe (268.03 KB)
Regards,
code