View Full Version : rtf2lrf


kovidgoyal
07-02-2007, 04:39 PM
In libprs500 (http://libprs500.kovidgoyal.net) version 0.3.64


rtf2lrf mybook.rtf


Needs testing.

sammykrupa
07-02-2007, 04:57 PM
Supports pictures I presume? Wouldn't be too useful otherwise.

NatCh
07-02-2007, 05:01 PM
I s'pose we could try it and see. :grin3:

kovidgoyal
07-02-2007, 05:03 PM
Supports pictures I presume? Wouldn't be too useful otherwise.

Yeah it should, but I haven't tested it, since I don't use RTF.

bkilian
07-03-2007, 03:38 AM
C:\Users\Bryan\Documents\My Books\New>rtf2lrf -t "The Stars at War" -a "David Weber and Steve White" --cover="stars1.jpg" The_Stars_at_War.rtf
Converting to HTML...This is UnRTF, version 0.19.3
By Dave Davey and Marcos Serrou do Amaral
Original Author: Zach T. Smith
Processing C:\Users\Bryan\Documents\My Books\New\The_Stars_at_War.rtf...
Done.
32248 words were hashed.
done
Processing tmpbvht5b.html
Parsing HTML... done
Converting to BBeB...
Traceback (most recent call last):
File "convert_from.py", line 113, in <module>
File "convert_from.py", line 107, in main
File "shutil.pyo", line 174, in rmtree
File "shutil.pyo", line 172, in rmtree
WindowsError: [Error 32] The process cannot access the file because it is being used by another process: 'c:\\users\\bryan\\appdata\\local\\temp\\rtf2lrf_c qjvhu\\pict001.wmf'

C:\Users\Bryan\Documents\My Books\New>rtf2lrf --version
libprs500 0.3.64

This is on Windows Vista. I don't get any errors when using lit2lrf or html2lrf on the same book (in the other versions, of course :))

kovidgoyal
07-03-2007, 11:27 AM
Can you send me the RTF?

JSWolf
07-03-2007, 11:33 AM
C:\Users\Bryan\Documents\My Books\New>rtf2lrf -t "The Stars at War" -a "David Weber and Steve White" --cover="stars1.jpg" The_Stars_at_War.rtf
Converting to HTML...This is UnRTF, version 0.19.3
By Dave Davey and Marcos Serrou do Amaral
Original Author: Zach T. Smith
Processing C:\Users\Bryan\Documents\My Books\New\The_Stars_at_War.rtf...
Done.
32248 words were hashed.
done
Processing tmpbvht5b.html
Parsing HTML... done
Converting to BBeB...
Traceback (most recent call last):
File "convert_from.py", line 113, in <module>
File "convert_from.py", line 107, in main
File "shutil.pyo", line 174, in rmtree
File "shutil.pyo", line 172, in rmtree
WindowsError: [Error 32] The process cannot access the file because it is being used by another process: 'c:\\users\\bryan\\appdata\\local\\temp\\rtf2lrf_c qjvhu\\pict001.wmf'

C:\Users\Bryan\Documents\My Books\New>rtf2lrf --version
libprs500 0.3.64

This is on Windows Vista. I don't get any errors when using lit2lrf or html2lrf on the same book (in the other versions, of course :))

Do you by any chance have Word running at the same time as you are trying to convert the RTF? If so, Word might be keeping some files in use.

kovidgoyal
07-04-2007, 12:38 AM
Fixed in 0.3.65

bkilian
07-04-2007, 03:36 AM
Fixed in 0.3.65Partly, now it converts the file, but loses the image, I get this error:
Processing tmp6gjcy6.html
Parsing HTML... done
Converting to BBeB...Unable to process: c:\users\bryan\appdata\local\temp\rtf2lrf_2wl-f7\pict001.wmf cannot identify image file
done

lit2lrf does a good job, so I don't really need the rtf one, but I'm always willing to fiddle :).

Would it be possible to add an option to your tools (lit2 and rtf2) that write out the intermediate html file they create? Similar to your lrs output. (And do you have a lrs2lrf, I don't see what I would use to convert a modified LRS that your tool had output in your program folder)

kovidgoyal
07-04-2007, 03:46 AM
Yeah the python imaging library doesn't support the wmf format so there isn't going to be support for it.

lit2lrf just calls clit file.lit destdir/ to create the html
and rtf2lrf call unrtf file.rtf
They're on your apth so you can call them manually.

I don't provide a lrs2lrf converter but there is one available see the LRF generation tools sticky.

pwalker8
07-04-2007, 02:20 PM
I notice that the mac version seems to have problems with the lrx files that come from the connect store. When I try to copy an lrx file onto my eReader device, it bombs. I suspect because the file is encrypted so you can't read the metadata. Other than that, it works great for me. I had no problems with the rtf, pdf and lrf files.
pww

kovidgoyal
07-04-2007, 02:25 PM
Exactly how does it bomb?

pwalker8
07-04-2007, 05:19 PM
It just dies. Here is the opening part of the report that gets generated


Date/Time: 2007-07-04 16:17:42.820 -0400
OS Version: 10.4.10 (Build 8R2218)
Report Version: 4

Command: libprs500
Path: /Applications/libprs500.app/Contents/MacOS/libprs500
Parent: WindowServer [97]

Version: 0.3.65 (libprs500 0.3.65)

PID: 739
Thread: 0

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x6c727535

Thread 0 Crashed:
0 QtGui 0x1280e213 QClipboard::event(QEvent*) + 645
1 QtGui 0x1280e6d1 QClipboard::event(QEvent*) + 1859
2 QtGui 0x12815710 QDragManager::drag(QDrag*) + 1154
3 QtGui 0x127d0ae6 QDrag::start(QFlags<Qt::DropAction>) + 68
4 QtGui.so 0x122ca845 sipQDrag::sipProtectVirt_disconnectNotify(bool, char const*) + 3247
5 org.python.python 0x0049942a PyEval_EvalFrameEx + 24563
6 org.python.python 0x004994d8 PyEval_EvalFrameEx + 24737
7 org.python.python 0x00499cdc PyEval_EvalCodeEx + 1819
8 org.python.python 0x0042f537 PyFunction_SetClosure + 2019
9 org.python.python 0x0040e278 PyObject_Call + 45
10 org.python.python 0x00415ee5 PyMethod_New + 2432
11 org.python.python 0x0040e278 PyObject_Call + 45
12 org.python.python 0x004925b2 PyEval_CallObjectWithKeywords + 112
13 sip.so 0x00697ab1

kovidgoyal
07-04-2007, 05:24 PM
GUI bug should be fixed in 0.4.0.

pwalker8
07-04-2007, 06:40 PM
Great, thanks. If it weren't for you and some of the other developers putting out such great products, I would feel a lot more unhappy about the lack of action by Sony with regards to the eReader. Between your product, the Docudesk PRS Browser, the Book Designer and the universal flasher, I feel like my eReader is going to continue to be of use to me for several years.

KaiGoth
08-04-2007, 11:58 PM
Anyone else have the below problem?

mymac:~/eBooks/Assiti Shards$ rtf2lrf 1633.rtf

Converting to HTML...
Traceback (most recent call last):
File "/Applications/libprs500.app/Contents/Resources/rtf2lrf.py", line 9, in <module>
main()
File "libprs500/ebooks/lrf/rtf/convert_from.pyo", line 66, in main
File "libprs500/ebooks/lrf/rtf/convert_from.pyo", line 48, in generate_html

libprs500.ebooks.Conversion Error?: unrtf failed with error code: -11

kovidgoyal
08-05-2007, 12:09 AM
send me the rtf.

KaiGoth
08-05-2007, 12:19 AM
send me the rtf.

Attached to ticket #134 (exceeds MR rtf size limit).

This seems to happen with just about every BAEN rtf I have. I thought I'd go through and convert all of the RTF versions from the CDs to LRF tonight. Maybe I'll try the lit2lrf and see if that works.

Any recommendations on the best format to convert FROM using the libprs500 utilities? BTW, thanks for an awesome set of tools. Really appreciate it!

kovidgoyal
08-05-2007, 12:26 AM
html is the best.

KaiGoth
08-05-2007, 12:32 AM
html is the best.

What if the html is broken into multiple pages?

For example:

http://www.webscription.net/chapters/0671319728/0671319728_toc.htm

KaiGoth
08-05-2007, 03:20 AM
Thanks for updating to 0.3.86!

Tried the change, now get a different error message (looks like I'm not importing some images)...

mymac:~/eBooks/Assiti Shards$ rtf2lrf 1632.rtf
Converting to HTML... done
Processing tmp7MBsNN.html
Parsing HTML... done
Converting to BBeB...Unable to process: /private/tmp/rtf2lrf_iUcnOD/pict001.wmf cannot identify image file
Unable to process: /private/tmp/rtf2lrf_iUcnOD/pict002.wmf cannot identify image file
Unable to process: /private/tmp/rtf2lrf_iUcnOD/pict003.wmf cannot identify image file
done
Output written to /Users/tdykstra/eBooks/Assiti Shards/1632.lrf

Anyways, I noticed that it doesn't pull meta-data from the source file like lit2lrf. I'm assuming this is because RTF doesn't contain any, but I thought I'd ask just in case.

kovidgoyal
08-05-2007, 03:26 AM
you can check rtf metadata with the command rtf-meta. The warnings are because the python imaging library doesn't support wmf format images.

KaiGoth
08-05-2007, 03:36 AM
you can check rtf metadata with the command rtf-meta. The warnings are because the python imaging library doesn't support wmf format images.

OK, thanks!

Looks like I'm having problems with rtf-meta as well.

mymac:~/eBooks/Assiti Shards$ rtf-meta 1632.rtf
Traceback (most recent call last):
File "/Applications/libprs500.app/Contents/Resources/rtf-meta.py", line 9, in <module>
main()
File "libprs500/ebooks/metadata/rtf.pyo", line 151, in main
File "libprs500/ebooks/metadata/rtf.pyo", line 102, in set_metadata
TypeError: object of type 'NoneType' has no len()

mymac:~/eBooks/Assiti Shards$ rtf-meta -t 1632 1632.rtf
Traceback (most recent call last):
File "/Applications/libprs500.app/Contents/Resources/rtf-meta.py", line 9, in <module>
main()
File "libprs500/ebooks/metadata/rtf.pyo", line 151, in main
File "libprs500/ebooks/metadata/rtf.pyo", line 102, in set_metadata
TypeError: object of type 'NoneType' has no len()

kovidgoyal
08-05-2007, 03:53 AM
That rtf file has no metadata, but rtf-meta shouldn't crash. Will be fixed in next release.

KaiGoth
08-05-2007, 03:59 AM
That rtf file has no metadata, but rtf-meta shouldn't crash. Will be fixed in next release.

Cool, thank you!

JSWolf
08-05-2007, 04:28 AM
What if the html is broken into multiple pages?

For example:

http://www.webscription.net/chapters/0671319728/0671319728_toc.htm
html2lrf will traverse the links and sort it all out for you into one nice LRF.

KaiGoth
08-05-2007, 04:41 AM
html2lrf will traverse the links and sort it all out for you into one nice LRF.

Thanks, I'll keep that in mind for some of my other stuff. I must admit though, I'm pretty pleased with the way lit2lrf has been working on the Baen products. The maps and images come out great. (Also for some strange reason Baen puts maps and TOC at the back of html versions, but not lit).

I have a bunch of html formatted stuff from reading on my old Treo and xv6700 though, and I'm looking forward to trying it on those.

kovidgoyal
08-05-2007, 12:16 PM
All the 2lrf tools use html2lrf under the hood. The reason I say html is best is that it allows you the greatest control over the conversion process.

ZeBuddha
08-30-2007, 02:41 PM
The following is an error message I've gotten a LOT of times.

Traceback (most recent call last):
File "convert_from.py", line 94, in <module>
File "convert_from.py", line 69, in main
File "convert_from.py", line 50, in generate_html
libprs500.ebooks.ConversionError: unrtf failed with error code: -1073741819


It doesn't happen with each *.rtf file, but I don't think it'd be an exaggeration to say it happens with about half of them.

The version of UnRTF it shows in the command prompt is 0.19.3... is that the latest one?

JSWolf
08-30-2007, 10:23 PM
The following is an error message I've gotten a LOT of times.

Traceback (most recent call last):
File "convert_from.py", line 94, in <module>
File "convert_from.py", line 69, in main
File "convert_from.py", line 50, in generate_html
libprs500.ebooks.ConversionError: unrtf failed with error code: -1073741819


It doesn't happen with each *.rtf file, but I don't think it'd be an exaggeration to say it happens with about half of them.

The version of UnRTF it shows in the command prompt is 0.19.3... is that the latest one?
What version libprs500 are you using?

ZeBuddha
08-31-2007, 08:07 AM
0.3.95 - sorry, forgot to mention that...

JSWolf
08-31-2007, 09:19 AM
0.3.95 - sorry, forgot to mention that...
You are WAY behind in versions. Try 0.3.106 and see what happens and then if need be posted a bug report.

kovidgoyal
08-31-2007, 04:33 PM
You;ll have to bug the authors of unrtf about this as it's an unrtf problem as far as i can tell.

nerys
09-07-2007, 02:47 AM
OK maybe I am just really dense :-) but this program has NO right click options and only 3 buttons Add Delete and Edit Meta Information

Where exactly is the "convert this" to lrf button?? ie HOW are you converting files??

----Edit----

Ahh there is none (found these files called xxx2lrf.exe's :-)

SO I dragged one of my files onto this and hey that works. One problem. I tried a lit file it processes does its thing finishes then does parsing html than converting to bbeb and stays there. I am going to let it run (4-5 minutes now) does it take that long? (ok it finished but ??? no file? the window just goes away (completed task) but there is no file? where does it store the file? I would assume same directory as the original file?

the rtf2lrf crashes on EVERY single RTF I have tried so far. No error just crashes.

this is latest version (downloaded 10 minutes ago) in XP Pro.

Would love to get this working :-) I hate waiting forever for the reader to "format" a book and then hope it works :-)

kovidgoyal
09-07-2007, 09:02 AM
Open a terminal Start->Run type cmd.exe
Type libprs500-beta and press enter now you will have a convert button.

nerys
09-09-2007, 11:47 AM
Hey buttons :-) will try it and see what happens.

ricdiogo
09-10-2007, 06:55 PM
I don't have a Reader so I've never given much attention to this thread. But if the Reader supports RTF why do you feel the need to convert it? (Sure because it displays better.) Just uploading RTF files to the Reader isn't enough? aren't there any formatting tips for making an improved RTF without the need convert it (fonts, sizes, margins... etc)?

(Since my decision on which device I should buy is going to be determined by the RTF readability, that's why I ask you this, specially in order to compare Sony's and Cybook's RTF readability).

kovidgoyal
09-10-2007, 06:56 PM
the sony reader rtf viewer doesn't support images, links. I personally detest RTF as a format.

ricdiogo
09-10-2007, 07:09 PM
Oh I see :knife: Thanks

JSWolf
09-10-2007, 07:12 PM
Oh I see :knife: Thanks
But we have no idea what will happen with the new Sony Reader due out in October. So I'd wait to find out how it displays RTF. If you like, once the local SonyStyle has them in stock, I can pop an RTF (one of your choice if you want) on an SD card and take it with me to see how it displays.

irishjew
10-14-2007, 08:56 PM
When I try to use rtf2lrf for any file, Unrtf crashes on me, and then I get the log error:

ConversionError: unrtf failed with error code: -1073741819
Failed to perform job: Convert book:Absalom, Absalom
Detailed traceback:
Traceback (most recent call last):
File "libprs500\gui2\jobs.pyo", line 97, in run
File "libprs500\ebooks\lrf\any\convert_from.pyo", line 140, in main
File "libprs500\ebooks\lrf\any\convert_from.pyo", line 117, in process_file
File "libprs500\ebooks\lrf\rtf\convert_from.pyo", line 67, in process_file
File "libprs500\ebooks\lrf\rtf\convert_from.pyo", line 52, in generate_html
ConversionError: unrtf failed with error code: -1073741819
Log:
[INFO] convert_from.pyo:38: Converting to HTML...
[CRITICAL] convert_from.pyo:51:


Please help. I'd be happy to convert the file to html or txt, but when I do that, I lose all paragraph breaks.

kovidgoyal
10-14-2007, 10:26 PM
Try it from the commandline using rtf2lrf and post the result.

irishjew
10-14-2007, 11:38 PM
This is what I come up with:

C:\Program Files\libprs500>rtf2lrf C:\a.rtf
Converting to HTML...

Traceback (most recent call last):
File "convert_from.py", line 104, in <module>
File "convert_from.py", line 98, in main
File "convert_from.py", line 67, in process_file
File "convert_from.py", line 52, in generate_html
libprs500.ebooks.ConversionError: unrtf failed with error code: -1073741819

C:\Program Files\libprs500>

kovidgoyal
10-14-2007, 11:44 PM
hmm send me the rtf file.

irishjew
10-14-2007, 11:55 PM
I mean, it happens with all rtf files, so it's probably a problem with my computer. Do you need Microsoft Office for this to run properly?

kovidgoyal
10-15-2007, 12:19 AM
no it doesn't need any dependencies. unrtf does segfault on all windows installations, but usually it first manages to create the HTML so it doesn't matter.

If you run unrtf myfile.rtf does it produce the HTML?