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:

montecristo-3

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?


Contents © 2000-2024 Roberto Alsina