Skip to main content

Ralsina.Me — Roberto Alsina's website

rst2pdf is going to be one day late. But there's a good reason.

Be­sides ev­ery­thing I men­tioned yes­ter­day, to­day I im­ple­ment­ed two rather im­por­tant fea­tures: cas­cad­ing stylesheet­s, and user-de­fined page lay­out­s. Here is a screen­shot:


That neat two-­col­umn lay­out is done by adding this to the stylesheet:

"pageTemplates" : {
  "firstPage": {
      "frames": [
          ["0cm", "0cm", "49%", "100%"],
          ["51%", "0cm", "49%", "100%"]

The name "first­Page" is mag­i­cal right now, and there's no way to change from one tem­plate to an­oth­er (yet), and un­til I do that, I won't be re­leas­ing.

Here's what cas­cad­ing stylesheets does. Sup­pose you want to use A5 pa­per and size 12 Times New Ro­man fonts? Here's all the stylesheet you need:

  "pageSetup" : {
    "size": "A5",
  "fontsAlias" : {
    "stdFont": "Times-Roman",
  "styles" : [
    ["base" , {
      "fontSize": 14,
      "leading": 16

Al­so, you can spec­i­fy as many stylesheets as you want in the com­mand line. So you can have one that sets the pa­per size, one for page lay­out as above, one for font "set­s", etc.

Neat, is­n't it?

Rstpdf wil be released again tomorrow. And it's a good release.

How good? Let me tell you...

  • Sup­­port for PDF ta­ble of con­­tents

  • Sec­­tion names and num­bers in head­­er­s/­­foot­ers

  • Com­­pressed PDFs (or not)

  • Guess im­age sizes. Spe­­cial­­ly if you meant to use them in a web page and de­­clared just ":width: 50%"

  • Gut­ter mar­­gin sup­­port

  • Raw di­rec­­tive (in­sert page­breaks and ver­ti­­cal space man­u­al­­ly)

  • Of­fers a do­cu­til­s-­­com­­pli­ant API (and an­oth­er API, too)

  • In­­­clude full or par­­tial files for code-block. That means you can ex­­tract code and show it in your doc­u­­men­t!

  • Huge code cleanup lead by Nico­las Lau­rance.

  • Work­ing mul­ti­lin­gual hy­phen­a­tion. You can have a per-­­para­­graph lan­guage and hy­phen­ate it cor­rec­t­­ly.

How pretty is rst2pdf's output? Take a look.

I am a big Alexan­dre Du­mas fan. He's the di­rect an­ces­tor of Neal Stephen­son, so many of you should like him too. So I used one of his best books to try some au­to­mat­ic type­set­ting of project guten­berg texts.

No, the whole book did not con­vert with­out er­rors, and yes, there is some man­u­al work in what you are about to see, but hey, take a look.

Here's a far look of the first two pages:


And here's some de­tail of the typset­ting:


Yes, the type­set­ting is not re­al­ly La­TeX qual­i­ty, but it's not bad, ei­ther.

Com­pare it with the HTML ver­sion at project Guten­berg. The type­set­ting is a thing of beau­ty com­pared to that :-(

The im­age is a pic­ture of Chateau d'If from flick­r, re­leased un­der Cre­ative Com­mon­s. The ti­tle font is Scripti­na, I chose it be­cause it looks 19th cen­tu­ry but mod­ern.

rst2pdf: release fever!

I did a re­lease yes­ter­day, and an­oth­er to­day of my rst-­to-pdf-with­out-la­tex tool. What's new? Here's an in­com­plete list:

New in 0,4

  • Fixed bul­let and item lists in­­­den­­ta­­tion/nest­ing.

  • Im­­ple­­men­t­ed ci­­ta­­tions

  • Work­ing links be­tween foot­notes and its re­f­er­ences

  • Jus­ti­­fi­­ca­­tion en­abled by de­­fault

  • Fixed ta­ble bug (de­­mo.txt works now)

  • Ti­­tle and au­thor sup­­port in PDF prop­er­ties

  • Sup­­port for doc­u­­ment ti­­tle in head­­er/­­foot­er

  • Cus­­tom page sizes in stylesheet

New in 0.3

  • Font em­bed­d­ing (use any True Type font in your PDF­s)

  • Syn­­tax high­­­lighter us­ing Pyg­­ments

  • User's man­u­al

  • Ex­ter­­nal/­­cus­­tom stylesheets

  • Sup­­port for page num­bers in head­­er/­­foot­er

Of course, since I said I would re­lease some­thing ev­ery fri­day, this means I need to find some­thing else to re­lease? ;-)

rstpdf love: syntax highlighting

This mini-sprint is do­ing won­ders for rst2pdf. Now on SVN: pyg­ments-based syn­tax high­light­ing. Ex­am­ple here: rst2pdf's code, in a PDF by rst2pdf.

Contents © 2000-2024 Roberto Alsina