XHTML-CSS.com

This is our blog. It's mainly about programming, web developement and design, social web, coding habits and advice and miscellaneous geekery. You can subscribe to the feeds to never miss a bit.

WPTeX: Create a book from your Wordpress blog

Permanant link —Jan 22, 08:10 PM

During the last two days I was working on a php program that I use on another website (wordpress blog) and that I wanted to share it with you, people.

Here’s what it’s about: Imagine you have a Wordpress blog, or that you’re planning to have one. WPTeX will help you generate a PDF ebook from your blog with the best typeseting tool available: LaTeX!

Another use: Imagine that you want to write your book, but you’re very lazy to start it. My advice: Create a wordpress blog, post your articles at your rythm like every blogger do, and when you want to create your book, use WPTeX

Check out the project in its own micro-site and tell me what you think :)

http://xhtml-css.com/wptex

P.S. This is the first release, many features will be added, so stay tuned ! ;-)


Enjoyed this post? please subscribe to our feeds to stay informed.

Comment [27]

Jim · Jan 27, 01:05 AM · #

I just downloaded WPTex and tried running it according it your instructions and all I get is a blank /wptex/index.php page. I’m not really sure why. I tried leaving the index field blank during the setup and got the following error repeated about 50 times:

Warning: Invalid argument supplied for foreach() in /home/opendial/public_html/blog/wptex/libs/functions.php on line 190

This is an ingenious idea, by the way. It just appears to need to have some bugs ironed out.

Luca Beltrame · Jan 27, 09:17 AM · #

There is a bug in the script. If no keywords are specified, it gives an error:

Warning: Invalid argument supplied for foreach() in /[host path]/wptex/libs/functions.php on line 190.
Also the mini-site has some (minor) inconsistencies: in some places the license is stated to be as LGPL, in other GPL. Last but not least, you may want to specify “chmod 775” instead of “chmod 666” for the tmp directory.
Hope this helps.

Luca Beltrame · Jan 27, 09:21 AM · #

Some more suggestions: you might want to use utf8x (from the LaTeX package ucs) as input encoding to avoid having the user changing from applemac to latin1. As most WP blogs are in UTF-8, it makes sense anyway.

Baptiste · Jan 27, 09:40 AM · #

Hi !
I got :
Warning: Invalid argument supplied for foreach() in /home/***wordpress***/wptex/libs/functions.php on line 190
and many html tags were not translated into TeX : the a href, the i, the blockquote….

admin · Jan 27, 12:00 PM · #

Thank you all for the feedback! I’ll work on this issue right now! It seems that you all araised the same error, in line 190 of functions.php. Let’s see that.

@Luca: Yes you’re right, I’ll correct this licence inconsistence. Thanks for spoting it!

@Baptise: Hey! The world is small! :) You once gave me my first gmail invitation! Encore merci!

Giovanni · Jan 27, 01:04 PM · #

Really cool idea but i think you should download and include images in some ways.

admin · Jan 27, 01:25 PM · #

@Giovani : Molto Grazzie! :) Yes I thought about this too! And it’s really doable, all we have to do is copy/download the pics and move them to the directory where the zip will be shiped… Will be available in next major version, I promise! :)

If anyone wants to help! Hey! You’re very welcome! :)

Mythokia · Jan 27, 02:22 PM · #

For me it seemed that I needed to give the tmp directory execute permission on top of read/write in order to work, or else I’ll get thrown a permission denied on line 19, instead of just chmod 666 as the instructions given said.

Luca Beltrame · Jan 27, 06:18 PM · #

You should also put some notes on the LaTeX packages requirement: I saw a reference to “pscal” which is included in pstricks, and also put a warning of some sorts that indicates that the use of certain characters will break LaTeX compilation (unless you escape them).

Robert Nagle · Jan 27, 10:28 PM · #

This is a good idea (and I wish you luck in developing it), but having a pdf converter is less useful than having an .epub converter. The upcoming Adobe reader (Adobe Digital Editions) will support .epub format (which is the new official standard for ebooks). See http://www.idpf.org/specs.htm

gérald · Jan 28, 12:22 AM · #

Hi,

Thank you for this script. I got everything working, but the PDF generated does seems corrupted. I tryed several times – followiing your instructions, but when I double-clic on book.pdf, I get “there was an error opening this document. The file is damaged and could not be repaired”. Too sad. Would you have an idea of what is wrong?

Gérald

admin · Jan 28, 12:30 AM · #

@Robert : Thank you! I humbly think that PDF will still live for a long time, it’s portable, and open.

@Gérald: Bonjour, I’m happy that it worked for you! what tool are you using to generate the pdf? can you please send me the generated zip (if it’s not private, bien sûr!) so I can try using my tools? (on linux and osx) ?

Fredrik · Jan 28, 09:06 AM · #

Hi there, great job. I’ve been looking for something like this – I think.

I downloaded the zip-file, unzipped it, uploaded the wptex directory to the server now I am using the link you recommend, but it says “404 Page not found on this server” the directory is there and I did chmod it to 777…

I am on a Mac

Scurvy Jake · Jan 28, 09:31 PM · #

I had no problem installing WPTeX, but when I run it I get memory allocation errors (my allowed memory size for PHP is 16Mb). I do have about 4.5 years of blogging history. My database dumps (via mysqldump) to a 3Mb file. When I bump the memory_limit directive in php.ini to 32M WPTeX runs fine. Just wanted to let anyone else know if they run in to this problem.

admin · Jan 28, 11:21 PM · #

@Frederik, Could this be an htaccess issue? Have you a special entry in your htaccess file?
Can you please send me a url to your wordpress installation?

@Scurvy Thank you for the recommandation! Yes, it sure is very helpful to know about these limits and how to tweak them to get it working. Thank you!

Fredrik · Jan 29, 05:27 AM · #

Hi there, thanks. I can’t actually find a htaccess file in my installation… I will look closer. And I’ll send you an URL

Fredrik · Jan 29, 10:18 AM · #

Sure, What’s your e-mail?

admin · Jan 29, 11:20 AM · #

Hi Fredrik, You’re welcome! :)
Here’s my email address: contact (at) xhtml-css (dot) com

Please don’t hesitate! :)

— peter · Jan 30, 02:50 AM · #

writebale should be writeable (I think)
:)

Luca Beltrame · Jan 30, 08:25 AM · #

Just to clarify better what I wrote earlier, I think some notes should be put:

- Currently BBCodes and other similar codes used by plugins will break compilation (they’re not put in verbatim blocks, and I doubt it can be done automatically): for example I put a lot of source code posts in my blog and those generate a lot of errors.

- If wptex creates files with pstricks requirement, it should be written somewhere that it will only work with plain latex and not pdflatex.

admin · Jan 31, 01:10 AM · #

@Peter: Thanks! I’ll correct this, please forgive my poor English, it’s my 4th language :)

@Luca: Thank you very much for your insights! I see what you mean about other plugins interfering in WPTeX automatic generation and you’re right, maybe with some smart tricks we’ll be able to resolve some of the specific issues. Would you please give a hand? :)

- I don’t get it when you’re speaking about pstricks, and pdflatex. I currently use pdflatex succesfully and I have people writing me that it works fine for them too. What do you mean, please?

— italways · Jan 31, 07:41 PM · #

does it support wpmu? generate the pdf ebook for a specific blog? thanks!

admin · Jan 31, 09:25 PM · #

@italways : sorry, currently it doesn’t but I guess it won’t be hard to adapt it for this. Can you please help us with this? :)

lieven · Feb 10, 12:31 PM · #

Nice program but i have a few problems with the tex-file. It chokes on markdown i use in my blogposts. For example, i like to like with something like [here the site](http here the address).
would it be difficult to extend your program to include these markdown-syntax?
also i use LatexRender to have tex-symbols in my posts. it is easy enough to do a find-and-replace on opening and closing [ tex ]-tags and replace them with a $-sign, but still it would be nice if the program does it for you…
again thanks for a great program.

Dave Schuler · Feb 16, 02:34 AM · #

First, you’ve made a magnificent start but at this point it’s definitely just a start.

Here are a few things I’ve found in just the first cut:

1. “Table of Contents” appears in French (?)

2. It doesn’t seem to be handling embedded HTML gracefully.

Example: <blockquote>…</blockquote>

appears literally.

3. Escaped characters aren’t being translated.

Example: &#147; (left double quote)

As time allows I may look into the code and propose approaches to solving some of these problems.

But it’s still a good start!

Dave Schuler · Feb 16, 02:56 AM · #

I’ve got a suggestion on handling anchors: they should be handled as footnotes.

admin · Feb 17, 11:42 AM · #

@Dave, @Lieven: Thank you so much for your kind words and for reporting these issues. As you may guess, I work on WPTeX on my spare time, I can’t promise anything actually about its evolution but like any opensource project this one needs other hands, other brains :)

I’ll try to take a look at what you’ve suggested but I really welcome you to modify and improve the code. Please join me on google code!

Again, Thanks! :)

Commenting is closed for this article.

« Previous post:
Next post: »