Sunday, August 2, 2009

New Tool: Convert .FB2 files to PDF

ereader

It all started a couple of months ago when my wife, @othraen, got her Sony eReader. She loves it, and reads a couple of books a week on it. I can definitely see why she likes it – it’s slick, simple, and very pleasant to read on. Great toy, if you like books!

Anyway, with the speed she’s reading, not even the 5000000000000000 (or whatever count they reached now) free titles at Google Books is enough, and she’s started looking online for public domain Russian language books (most Russian is like Greek to me, but she likes it :-) ). As it turns out most of the Russian e-books online are in the FictionBook 2 format (.FB2). It’s an open XML format, probably defined by a league of Russian e-book publishers or so – it doesn’t seem to be all that popular in the rest of the world.

As you might imagine, the friendly people at Sony didn’t take this into consideration when planning on which formats to use in the eReader, so it is not supported. However, our friend, good old reliable PDFs are of course supported. It didn’t take many Google searches to find the fb2pdf.com website – a site devoted to converting fb2 files to PDF. It worked great on the first book….And on the second book. But later on, several of the books she tried to convert wouldn’t work. It would just freeze up and we could wait for ever and ever. As it so often happens, this resulted in the statement I fear so much “Honey, can’t you spend a little less time playing around with that programming stuff and a little more helping me get this book I want to read on my ereader??!” (yes, one of those questions where there’s only one right answer). In this case it would have made sense to simply drop a mail to the owners of the before mentioned website, asking them to fix whatever bug that caused the conversion to fail – but I was determined not to let this be the first time I give in to common sense :-)

image Instead this was a perfect opportunity to take a closer look at FB2, PDFs, the iTextSharp library, SharpZipLib and ClickOnce deployment. At the same time, I’d get to program in my spare time – and with a perfect excuse – helping her :-)

It didn’t take much more than a couple of hours before I had a working windows application, that can load .fb2 files (or zip-files containing 1 .fb2 file), correct / change their Author / Title (since the ereader doesn’t seem to support Cyrillic characters in the title browsing menu), and convert into a PDF. It’s a ClickOnce application, which means you can install it directly from it’s online source – and it will automatically get updated if I upload a new version. The only tricky thing in developing it was actually embedding a font to show the Cyrillic Unicode characters that most Russian books are comprised of.

[UPDATE 2009-12-20] I finally found some time to fix a few bugs and add two new check-boxes: "Optimize for Sony Reader" and "Optimize for Kindle". Right now, all they do is to optimize page-sizes, so it should work better on the respective devices - but in the future they might also adjust font, font-sizes, etc. Let me know how well it works - I don't have a kindle, so I can't test it myself. Update should install itself.

Install the FB2 to PDF Converter tool from here.

21 comments:

Alex said...

Hi Allan,

Thanks for the converter. It works fine. However, I am not sure it is going to make your wife happy. The problem is that, in order to be readable on Sony e-Book reader, a .pdf file should comply some special requirements described here: http://www.mobileread.com/forums/showthread.php?t=9562 (look for an attached pdf file at the bottom). Briefly, page size of a Sony readable pdf file has to be 3.47" x 4.54". Could you change your converter to create such files?

Thanks.

Alex

Allan Thræn said...

Hi Alex

Thanks for your comment and the link. My wife tells me they work fine in her sony reader (the 505), in "m" magnification. However in the next update I'll make sure to include a size selection where it's possible to choose 3.47'' x 4.54''

Anonymous said...

Application crashes:
EventType:clr20r3 P1:fb2pdf.exe
P2:1.0.0.0
P3:4a74f616
P4:itextsharp
P5:4.1.6.0
P6:4a52ea49
P7:10a2
P8:90
P9:system.io.ioexeption
WindowsXP,Sp3,german

Christian said...

Nice work,

I'm hoping, while you are at it, you might consider making your program work both ways.

I have a Nokia Xpress Music 5800 and the best reader for it actually use FB2 format.

Most of the books I already have are in PDF so it would be great for me and, I'm sure, a lot of other people if you could manage this.

Hopefully it is not too much work and you could make some profit out of it :)

Thanks,

Allan Thræn said...

Hi Christian

Thanks for your comment. Unfortunately it's a lot harder to extract text from PDF in a read-able way than creating a PDF - so I don't see the reverse process happing soon.

Anonymous said...

thenk you
very help
nice and fest program

Living in London said...

This is a great utility. Is there any way to increase the font when converting? It appears tiny on the Kindle. Thanks

Allan Thræn said...

It's now updated to work better with Kindle and Sony Reader.

Anonymous said...

Hello there,
Great utility, very useful.
However, would it be possible to compact the text a little, so that more lines and smaller fonts are displayed on one page of the Sony reader? From this point of view the online converter works better, the pdf pages are more compact, therefore they don't require so much page-changing, but unfortunately it doesn't always work... :-(
Keep up the good work!

Allan Thræn said...

If you dont check any of the "Optimize for" boxes, it should create something which fits pretty well on the sony reader.
The "Optimize for Sony Reader" makes it follow the suggested pagesizes for the reader which I dont always like.
Anyway - next update I'll make it configurable which font-size to use, margins, spacings, etc.

Evgueni said...

Thank you very much! I suspect your great program doesn't transfer images,illustrations to pdf- maybe you can fix that? Would be also great to have option to convert to rtf.Thanks again!

Evgueni said...

And maybe possible to make files load automatically after selection and the whole bunch of them in the folder? -I guess i'm being oldman from russian tail about Goldfish... :)

Timothy Takemoto said...

Thank you very much for making this available but, I get

"Can not download the application. The application is missing the required files. "

I am using Windows 2000. Perhaps that is my problem.

Tim

Boris said...

Thank you for this wonderful tool. Both I and my wife are thankful. Was very easy to use and download. Works perfectly. Was referred to your website by friendly people from Office Depot. Went there to buy a converter, they had none and one of the sales reps. said that he has both Sony and Kindle and gave your info. The only thing that is not working for me is change the name and authors name of the book. I am using windows 7, and in the process of conversion both fields are not accessible. Any suggestions?
Thanks again.
Boris

bioss said...

hi, I am using Windows 7 - while the installation does not trigger any errors, I am unable to convert any file - as soon as the conversion starts (i.e. file is created) the application crashes - I have all admin rights, though. Any clues?

klaus said...

Hi Allan,

Any chance of a fb2 converter to pdf for MacIntosh in the future?

thanks,
Klaus Schoenberger
Klaus@smlspipe.ca

Ivan said...

Tnx a lot mate!!!! awesome software!!

^_^

Victor said...

Thanks Alex.
it works great!!!!
I wish though you make an option
for Kindle DX screen, which is 9.7" size. I am using your converter happily, but on my large screen letters are to big. Can it be fixed?
Thanks from Russian reader, Victor

Vanny said...

Your program works :) I have converted 2 fb2 files and I'm reading them now in PDF. Thanks!

Windows 7. Reader: Kindle

brian5plus5 said...

Hi, I managed to install it but now as soon as I click 'convert' it crashes and I get the message "FB2Pdf has encountered a problem and needs to close. We are sorry for the inconvenience." Any suggestions?

SinclairPeters said...

Just pure Genius!! I've been at this for 2 days and the language plus alphabet problem is tricky! You should work for Google or something!
Thanks
Andrew & Marina