Create a PDF or ePub in runtime

Started by rmonic79, Thu 31/03/2016 10:42:50

Previous topic - Next topic

rmonic79

Hi guys we are wondering if there's a method to create and write a Pdf or an epub file in runtime without stop the game.
I know it's a strange question but if someone could help we will be grateful a lot. :)

Scavenger

The answer is "technically yes" but put the world's largest asterisk next to the yes.

Going purely off of the epub format, AGS does let you write raw chunks of data to a file, but it doesn't come with any libraries to write the ZIP specification, or any file format other than bmp/pcx. You'd need to write:

- A ZIP file reader/writer. Even if you're not planning on compressing the files with zip, you still need to know the specifications of the ZIP format.
- A PNG file reader/writer (if you want images)
- A HTML5/CSS/XML writer. This is the easiest part, it's just plaintext, but it's required for the majority of the epub.

And any one of these would be a pretty big undertaking if you've never done it before. I mean, it would be POSSIBLE. But just not EASY. It depends what you want to achieve in the end.

If you just want to dump text to an epub, like a player's journal, you could make a framework around which you build the end file (by putting static files you want to include in it in the game folder and just copying their data over when the time comes rather than dynamically creating that content), and write the relevant text in the middle. As individual chapters are just XHTML files, apparently, this might be the most workable solution - you'd just need a way to place all the files into a ZIP container.

As for writing a PDF file, I wouldn't even begin to know how to touch that format, it's labyrinthine and inscrutable.

rmonic79

Thanks Scavanger we will give it a try ;)

SMF spam blocked by CleanTalk