BakaPrince (PDF creator)

Wish to express your thanks and salutations? And PDF's? Find your Novel Series topic here

Moderators: Fringe Security Bureau, Senior Editors, Senior Translators, Alt. Language Translator/Editor, Executive Council, Project Translators, Project Editors

Locked
User avatar
EusthEnoptEron
Project Translator
Posts: 836
Joined: Mon Jul 13, 2009 10:39 am
Favourite Light Novel: Ahouka!
Location: Switzerland

BakaPrince (PDF creator)

Post by EusthEnoptEron »

Hey there, I've been working on (yet another) tool for creating PDFs -- specifically for my own projects -- but I thought I'd share it with you. You feed the tool a *.JSON config file of a LN volume, and it will convert it into a PDF file, using PrinceXML.

Note that you'll need basic knowledge of operating a shell and JSON to use this tool.

Features
  • PDF output
  • Configurable
  • Places (most) pictures correctly within the flow
  • Support for footnotes
  • Compatible with furigana (as far as I could observe)
Motivation
I wanted a more book-like look for my projects, while keeping the PDFs easily updated. I started with a LaTeX approach, but TeX is too much of a monster to use for this kind of task. Also, I wanted to do something.

Requirements
You'll need PrinceXML and the .NET 4.0 framework. Sorry, Linux & Mac enthusiasts. I might consider porting it to PHP, though, for server-side bliss.

Installation
  1. Download and install PrinceXML.
  2. Download and extract BakaPrince.
Usage
It's meant to be used from the command line -- add it to your %PATH% or use it as is, as you like.
To get started, head into the folder you extracted it, kick up a CMD window and try:

Code: Select all

bakaprince convert https://raw.github.com/EusthEnoptEron/BakaPrince/master/configs/tsukumodo1.json
This will create tsukumodo1.pdf in the current working directory. (*cough*covert advertising*cough*)

The complete thing looks like this:

Code: Select all

Usage: bakaprince [OPTIONS]+ [parse|convert] [Project_Name|config.json]
Create a PDF from a Baka-Tsuki project.

Options:
  -f, --force               force re-download of files
  -h, --help                 show this message and exit

  parse:
  -o, --output=VALUE         output path
  -v, --volume=VALUE         volume number

  convert:
  -p, --prince=PATH          the PATH where PrinceXML is located. Leave away
                               to find it automatically.
  -o, --output=VALUE         where to write the resulting PDF
  -s, --stylesheet=VALUE     specify an additional stylesheet to use

Config file
Look here for the specification and here for examples. If you're too lazy to write one, use the parse command to create one automatically (not recommended at the moment).

Code: Select all

bakaprince parse "Kamisama no Memochou" -v 3 -o kami.json
Output
The output looks like this: http://www.mediafire.com/?oi86ba1xc7gclxh

If you don't like the indentation and margins, you can define your own stylesheet (see usage & JSON specification) and do something like:

Code: Select all

p {
   text-indent: 0;
   margin: .4em 0 .5em 0;
}
Also take a look at the CSS properties available if you're interested.



This is still very beta-ish and might be a bit buggy. (The binary was compiled a few minutes before making this post.) If you want to take a look at the source -- or just have a laugh at my expense -- you can find the repository on GitHub.
User avatar
Simon
Editor-in-Chief
Posts: 508
Joined: Wed Dec 28, 2011 9:06 am
Favourite Light Novel:
Location: !=

Re: BakaPrince (PDF creator)

Post by Simon »

Is there a need for 430+ .json files ?
It's not much work to create them as the most info is saved in the DB.
Except, I won't be able to add the artist and editor fields.


On the other hand, why is there an underscore at the end of the value in the prefix ?

Code: Select all

"prefix": "Utsuro_no_Hako:Volume1_"
,
ePUB Generator <<Productive>> : BTE-GEN | Yay, I'm free. Let's see how long it takes for this place to go down.
User avatar
EusthEnoptEron
Project Translator
Posts: 836
Joined: Mon Jul 13, 2009 10:39 am
Favourite Light Novel: Ahouka!
Location: Switzerland

Re: BakaPrince (PDF creator)

Post by EusthEnoptEron »

Simon wrote:Is there a need for 430+ .json files ?
It's not much work to create them as the most info is saved in the DB.
Except, I won't be able to add the artist and editor fields.
Sorry, but I don't quite understand. If it's not much work to create .json files, where's the problem? And why can you not add artist and editor fields?
On the other hand, why is there an underscore at the end of the value in the prefix ?
That's just because I copied the value and "_" is interpreted as a whitespace by MediaWiki. The prefixes are brainlessly prepended to the page names, which is why a space is needed.
User avatar
Simon
Editor-in-Chief
Posts: 508
Joined: Wed Dec 28, 2011 9:06 am
Favourite Light Novel:
Location: !=

Re: BakaPrince (PDF creator)

Post by Simon »

EusthEnoptEron wrote:
Simon wrote:Is there a need for 430+ .json files ?
It's not much work to create them as the most info is saved in the DB.
Except, I won't be able to add the artist and editor fields.
Sorry, but I don't quite understand. If it's not much work to create .json files, where's the problem? And why can you not add artist and editor fields?
I asked if there is a need for these files, to generate the .json files for the complete Novels/Volumes. The ones that can be found in BTE-GEN.
And why I can't add the editors and the artist fields is, because I haven't added these fields in the Tables.
And it would be a pain to search for the editors.
I don't wanna go and find out every editor for every book out there(430+ in my case).
ePUB Generator <<Productive>> : BTE-GEN | Yay, I'm free. Let's see how long it takes for this place to go down.
User avatar
EusthEnoptEron
Project Translator
Posts: 836
Joined: Mon Jul 13, 2009 10:39 am
Favourite Light Novel: Ahouka!
Location: Switzerland

Re: BakaPrince (PDF creator)

Post by EusthEnoptEron »

Aah, now I understand. Thanks for your help. :D

The metadata fields (i.e. editors, artists) are optional and can be omitted. But since most of our projects do already have PDF files and I only intend to use it for my own projects for now, there's not really a need for those files. Feel free to make them, though -- it would be great test data.
User avatar
Simon
Editor-in-Chief
Posts: 508
Joined: Wed Dec 28, 2011 9:06 am
Favourite Light Novel:
Location: !=

Re: BakaPrince (PDF creator)

Post by Simon »

Here, 200 should be enough for tests. I hope that I didn't made an error while setting the comas or other minor things. Also redirected the images to my server, so the B-T won't be stressed by the traffic(names are the same as in B-T).
ePUB Generator <<Productive>> : BTE-GEN | Yay, I'm free. Let's see how long it takes for this place to go down.
User avatar
EusthEnoptEron
Project Translator
Posts: 836
Joined: Mon Jul 13, 2009 10:39 am
Favourite Light Novel: Ahouka!
Location: Switzerland

Re: BakaPrince (PDF creator)

Post by EusthEnoptEron »

Thanks a bunch - looks like I'll have something to play with this weekend. :D
User avatar
Simon
Editor-in-Chief
Posts: 508
Joined: Wed Dec 28, 2011 9:06 am
Favourite Light Novel:
Location: !=

Re: BakaPrince (PDF creator)

Post by Simon »

NP. If there's anything else, just say it.
ePUB Generator <<Productive>> : BTE-GEN | Yay, I'm free. Let's see how long it takes for this place to go down.
User avatar
EusthEnoptEron
Project Translator
Posts: 836
Joined: Mon Jul 13, 2009 10:39 am
Favourite Light Novel: Ahouka!
Location: Switzerland

Re: BakaPrince (PDF creator)

Post by EusthEnoptEron »

In response to:
Simon wrote:Simon, what I wanted to ask. If you have continued since the last time. Is the PDF generator that you've put together, working properly ? In the sense of, do the PDFs look ok ?

IF they do, I would only need to extend bte-gen to pass the information to the application.
Not perfect, but works pretty well. I haven't had much time to work much on it, though. I'm seriously considering porting it to PHP or JavaScript (or Java, or maybe Ruby even?) because C# only really runs on Windows. :O Also, the recent update just broke some of the code, bleh.

By the way, thanks again for the test data. There are a few problems that I noticed though:
1. Some of the files (e.g. those for Haganai) still had Accel World in them.
2. A lot of files contained wrong "name" attributes. (e.g. in A Simple Survey it's "Before_Beginning_the_Survey" instead of "Prologue")
3. B/W pages are in the list of images, which clutters the beginning of the PDF. If you don't discern between B/W and color illustrations, never mind. I *could* add another option to point to the illustrations page (because I don't want to sort out any pictures that are in the "image" keys and I already have a cheap algorithm to parse the page ).
User avatar
Simon
Editor-in-Chief
Posts: 508
Joined: Wed Dec 28, 2011 9:06 am
Favourite Light Novel:
Location: !=

Re: BakaPrince (PDF creator)

Post by Simon »

Well, I wrote that on the fly. So... there are bout to be errors.

But if you talk about porting, I'd prefer JavaScript(Client Side). ePUB, I started writing it a long time ago, but it's on hitaus. As I completely forgot about it.
I've seen some neat libraries that create PDFs in JavaScript, so it might have some advantages.

Either way, I'm off to type some code for btlib. *sigh* 3.5 hours left. Looks like I won't get any sleep.
ePUB Generator <<Productive>> : BTE-GEN | Yay, I'm free. Let's see how long it takes for this place to go down.
User avatar
EusthEnoptEron
Project Translator
Posts: 836
Joined: Mon Jul 13, 2009 10:39 am
Favourite Light Novel: Ahouka!
Location: Switzerland

Re: BakaPrince (PDF creator)

Post by EusthEnoptEron »

I now ported the whole thing to Java (ugh) for portability and because of similar syntax. Here's an online proof of concept, which will probably not be online for too long: http://162.243.43.34:8080/
Locked

Return to “Appreciation & PDF”