Page 1 of 1

Write a EPUB creator problems

Posted: Sat Jan 17, 2026 2:42 pm
by Allen
Hi,

I want to use PureBasic to write a simple EPUB creator that I can convert some text files to a EPUB and read on my Ereader.

A EPUB is basically a zip file, however, the order of files are important. One particlar uncompressed file must be the first file in the ZIP, following by other compressed folders.

My original idea is to create a ZIP file (use createPack()) with only one uncompressed file, then I reopen this ZIP file(use OpenPack()), add other compressed folders.

However, AddPackDirectory () can only follow a CreatePack() and I also do not know how to change the compression ratio of other folders..

Any suggestions are appreciated.

Thanks.

Allen

Re: Write a EPUB creator problems

Posted: Sat Jan 17, 2026 5:28 pm
by boddhi
Hello,

Uncompress your file in a temp dir. Then add new files, delete or modify existing files and create a new archive/epub with compression ratio.

I proceeded in this way to analyze and modify the content of my EPUB files.

Re: Write a EPUB creator problems

Posted: Sun Jan 18, 2026 3:27 am
by Allen
Hi boddhi,

Thanks for the suggestion. I think you are right, current packer function cannot add new files to a existing zip. The only way is to unzip , and re-zip with additional files. Also it seems only one compression ratio is allowed that is specifyied when the zip is created.

If I want files with different compression ratio, I may need to use runprogram to call external zip program such as 7-zip. Maybe AddPackFile() can add a compression level parameter in future version.

Thanks

Allen