! Copyright (C) 2011-2012 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: accessors assocs calendar combinators environment fonts
formatting fry io io.streams.string kernel literals locals make
math math.order math.ranges pdf.canvas pdf.values pdf.wrap
sequences sequences.extras sorting splitting ui.text
xml.entities ;
FROM: pdf.canvas => draw-text ;
IN: pdf.layout
! TODO: inset, image
! Insets:
! before:
! y += inset-height
! margin-left, margin-right += inset-width
! after:
! y += inset-height
! margin-left, margin-right -= inset-width
! TUPLE: pre < p
! C:
pre
! TUPLE: spacer width height ;
! C: spacer
! TUPLE: image < span ;
! C: image
! Outlines (add to catalog):
! /Outlines 3 0 R
! /PageMode /UseOutlines
! Table of Contents
! Thumbnails
! Annotations
! Images
! FIXME: spacing oddities if run multiple times
! FIXME: make sure highlights text "in order"
! FIXME: don't modify layout objects in pdf-render
! FIXME: make sure unicode "works"
! FIXME: only set style differences to reduce size?
! FIXME: gadget. to take a "screenshot" into a pdf?
! FIXME: compress each pdf object to reduce file size?
GENERIC: pdf-render ( canvas obj -- remain/f )
M: f pdf-render 2drop f ;
GENERIC: pdf-width ( canvas obj -- n )
] when ] keep
] while drop ;
PRIVATE>
: pdf-layout ( seq -- pages )
[