Exemplo n.º 1
0
    def __init__(self, **kwargs):
        BaseBusinessCard.__init__(self, **kwargs)

        context = self.doc.context
        mood = self.idData['theme'].mood

        bodyStyle = mood.getStyle('body')
        captionStyle = mood.getStyle('caption')
        logoStyle = mood.getStyle('logo')

        page = self.getDocument(name='BaseBusinessCard')[1]
        page.padding = self.padding = p(1)

        bs = context.newString(self.idData['logo'], style=logoStyle)
        bs += context.newString(' ' + self.idData['name'], style=bodyStyle)
        tw, th = bs.size
        e = newTextBox(bs,
                       parent=page,
                       w=tw,
                       stroke=noColor,
                       fill=0.7,
                       conditions=[Left2Left(), Top2Top()])
        print('===', e.x, tw, th, e.w, e.h)

        bs = context.newString(self.person['name'], style=bodyStyle)
        bs += context.newString('\n' + self.person['position'],
                                style=captionStyle)
        bs += context.newString('\n\n' + self.person['addressStreet'],
                                style=captionStyle)
        bs += context.newString('\n' + self.person['addressCity'],
                                style=captionStyle)
        bs += context.newString('\n' + self.person['addressTelephone'],
                                style=captionStyle)
        newTextBox(bs,
                   parent=page,
                   fill=noColor,
                   stroke=noColor,
                   conditions=[Left2Left(),
                               Fit2Width(),
                               Middle2Middle()])

        self.showFrame = True
        self.showPadding = True
        self.showCropMarks = True
        self.showRegistrationMarks = True
        self.viewCropMarkSize = pt(16)
        self.viewCropMarkDistance = pt(8)

        page.solve()
        print('+++', e.x)
Exemplo n.º 2
0
# In multipage documents this also can be done in the document, so pages inherit.
page.padding = PAD, PAD, 2 * PAD, PAD
# Create rectangles. Default position and size is (0, 0, 100, 100). The conditions define the layout.
newRect(fill=color(1, 0, 0),
        parent=page,
        h=pt(62),
        conditions=(Left2Left(), Float2Top(), Fit2Right()))
newRect(fill=color(1, 0, 1),
        parent=page,
        conditions=(Left2LeftSide(), Float2Top()))
newRect(fill=color(spot=300),
        parent=page,
        conditions=(Right2Right(), Float2Top(), Float2Left(), Fit2Right()))

# Add a floating text box.
newTextBox('BB',
           parent=page,
           x=100,
           y=150,
           w=300,
           h=400,
           fill=color(spot=400),
           fontSize=p(8),
           font='Verdana',
           textFill=color(spot=120))

# Solve the conditions of the layout in defined order.
doc.solve()
# Export to PDF.
doc.export('_export/SimpleDocument.pdf')
Exemplo n.º 3
0
# -----------------------------------------------------------------------------
#
#     ElementConditions.py
#
#     Position elements by their page padding position with conditions
#
# Document is the main instance holding all information about
# the document togethers (pages, styles, etc.)
from pagebot.document import Document
from pagebot.elements import newRect
from pagebot.toolbox.units import p, pt
from pagebot.toolbox.color import color
from pagebot.conditions import *

W = H = pt(500)
PADDING = p(4)
w = p(8)

doc = Document(w=W, h=H, originTop=False)
page = doc[1]  # Get the single page from te document.
page.padding = PADDING

page.showPadding = True

newRect(parent=page,
        w=w,
        h=w,
        fill=color('red'),
        conditions=[Left2Left(), Bottom2Bottom()])
newRect(parent=page,
        w=w,
Exemplo n.º 4
0
#     on vertical position page.h/2

from pagebot import getContext
from pagebot.fonttoolbox.objects.font import findFont
from pagebot.document import Document
from pagebot.elements import *  # Import all types of page-child elements for convenience
from pagebot.toolbox.color import color
from pagebot.toolbox.units import em, p, pt
from pagebot.conditions import *  # Import all conditions for convenience.
from pagebot.constants import *

context = getContext()

W = H = pt(1000)  # Document size
PADDING = pt(100)  # Page padding on all sides
G = p(2)  # 2 Pica gutter
PW = W - 2 * PADDING  # Usable padded page width
PH = H - 2 * PADDING  # Usable padded page height
CW = (PW - G) / 2  # Column width
CH = PH
# Hard coded grid, will be automatic in later examples.
GRIDX = ((CW, G), (CW, G))
GRIDY = ((CH, 0), )

# Dummy text, used several times to create the length we need for this example
text = """Considering the fact that the application allows individuals to call a phone number and leave a voice mail, which is automatically translated into a tweet with a hashtag from the country of origin. """

font = findFont('Roboto-Regular')

style = dict(font=font,
             fontSize=24,
Exemplo n.º 5
0
#
import os
from pagebot import getContext
from pagebot.filepaths import *
from pagebot.constants import *  # Containing page sizes and other contants.
from pagebot.conditions import *
from pagebot.elements import *
from pagebot.toolbox.color import whiteColor, color
from pagebot.toolbox.units import pt, p
from pagebot.fonttoolbox.objects.font import findFont
from pagebot.toolbox.finder import Finder  #
from pagebot.publications.magazine.magazine import Magazine

W, H = A4Rounded

BLEED_RIGHT = p(1, 1, 1, 0)
BLEED_LEFT = p(1, 0, 1, 1)

PADDING = PT, PR, PB, PL = pt(40, 30, 30, 50)
G = pt(12)
COLUMNS = 4
CW = (W - PL - PR - G) / COLUMNS - G
CW2 = CW + G + CW
CW3 = CW2 + G + CW
CW4 = CW3 + G + CW

GH = pt(1)
COLUMNS = 4
RH = ()
GRID_X = ((CW, G), (CW, G), (CW, G), (CW, 0))
Exemplo n.º 6
0
#     www.pagebot.io
#
#     P A G E B O T
#
#     Licensed under MIT conditions
#
#     Supporting DrawBot, www.drawbot.com
#     Supporting Flat, xxyxyz.org/flat
# -----------------------------------------------------------------------------
#
#     metrics.py
#
from pagebot.toolbox.units import inch, p, pt

W, H = inch(8, 10.875)
BLEED_LEFT = p(1), 0, p(1), p(1)  # 1 Pica bleed on top, left bottom
BLEED_RIGHT = p(1), p(1), p(1), 0  # 1 Pica bleed in top, right, bottom
GUTTER = p(2)
ML, MR = p(5, 6)
CW = (W - ML - MR - 3 * GUTTER) / 4
CH = p(5.5)
BASELINE = pt(12)
BASELINE_START = pt(44)

PADDING_LEFT = '3p1.5', ML, '4p1.5', MR
PADDING_RIGHT = '3p1.5', MR, '4p1.5', ML

GRIDX = (CW, GUTTER), (CW, GUTTER), (CW, GUTTER), (CW, GUTTER)
GRIDY = (CH, GUTTER), (CH, GUTTER), (CH, GUTTER), (CH, GUTTER), (CH, GUTTER), (
    CH, GUTTER), (CH, GUTTER), (CH, 0)
Exemplo n.º 7
0
# -----------------------------------------------------------------------------
#
#     ElementPaddingPositions.py
#
#     Position elements by their sides
#
# Document is the main instance holding all information about
# the document togethers (pages, styles, etc.)
from pagebot.document import Document
from pagebot.elements import newRect
from pagebot.toolbox.units import p
from pagebot.toolbox.color import color
from pagebot.conditions import *

W = H = 500
PADDING = p(5)

doc = Document(w=W, h=H, originTop=False)
page = doc[1] # Get the single page from te document.
page.padding = PADDING

page.showPadding = True

e = newRect(parent=page, fill=color('red'))
e.left = page.pl
e.bottom = page.pb

e = newRect(parent=page, fill=color('green'))
e.top = page.h - page.pt
e.center = page.w/2
Exemplo n.º 8
0
    style = mood.getStyle('body')
    style['font'] = 'Upgrade-Medium'
    style['leading'] = em(1.2)
    style['xTextAlign'] = CENTER

    style = mood.getStyle('caption')
    style['font'] = 'Upgrade-Italic'
    style['leading'] = em(1.1)
    style['xTextAlign'] = CENTER

    ci = CorporateIdentity(name=name, theme=theme)

    w, h = BusinessCard
    sheetH, sheetW = A4

    sheet = SheetOfCards(w=sheetW, h=sheetH, name=name, theme=theme)
    sheetDoc = sheet.newDocument(w=sheetW, h=sheetH, padding=p(4, 3, 5, 3))
    persons = getPersonRecords(PERSON_COUNT)

    for person in persons:
        sheet.newCard(w=w, h=h, idData=idData, person=person)

    sheetDoc.export('_export/BusinessCards-%s.pdf' % name.replace(' ', '-'))

# =============================================================================
#    Create a series of identities, as input data forExport to PDF or other file formats
# .............................................................................

#doc.export('_export/TheVariableGlobe.pdf')
#     Supporting Flat, xxyxyz.org/flat
# -----------------------------------------------------------------------------
#
#     TextBoxBaselinePaddingMargin.py
#
#     Show element padding and margin
#
from pagebot.document import Document
from pagebot.elements import newTextBox
from pagebot.toolbox.units import p, pt
from pagebot.toolbox.color import color
from pagebot.conditions import *
from pagebot.fonttoolbox.objects.font import findFont

W = H = 500
PADDING = p(2)
MARGIN = p(1)
BASELINE_GRID = pt(48)

font = findFont('PageBot-Regular')

doc = Document(w=W, h=H, originTop=False,
    baselineGrid=BASELINE_GRID)
view = doc.view
view.showPadding = True # Show padding and margin on page

page = doc[1] # Get the single page from te document.
page.margin = page.bleed = MARGIN
page.padding = PADDING
page.showBaselineGrid = True
Exemplo n.º 10
0
GUTTER = 2 # Gutter width
COLS = 3 # Number of columns
PADDING = 5 # Padding of the page
PS = 16 # Fontsize of body text
LEADING = 1.4*PS

# Calculate the width of the page from the column measures
W = COLS * COL + (COLS-1) * GUTTER + 2*PADDING
H = 1000 # Fixed height

GRIDX = [] # Construct the column grid measures

for n in range(COLS-1):
    GRIDX.append((COL, GUTTER))

GRIDX.append((COL, p(0))) # Last column does not have gutter

font = findFont('Verdana')

h1Style = dict(font=font, fontSize=1.5*PS, textFill=(1, 0, 0), leading=LEADING)
h2Style = dict(font=font, fontSize=1.2*PS, textFill=(1, 0, 0.5), leading=LEADING,
    paragraphTopSpacing=LEADING)
pStyle = dict(font=font, fontSize=PS, leading=LEADING)
liStyle = dict(font=font, fontSize=PS, indent=pt(8), firstLineIndent=0, leading=LEADING)
styles = dict(font=font, h1=h1Style, h2=h2Style, p=pStyle, li=liStyle, ul=liStyle, bullet=liStyle)

# Create a document with these attributes, single page.
doc = Document(w=W, h=H, padding=PADDING, gridX=GRIDX, originTop=False, styles=styles,
    baselineGrid=LEADING, language=LANGUAGE_EN)
view = doc.view
view.showTextBoxY = True
Exemplo n.º 11
0
#     Supporting DrawBot, www.drawbot.com
#     Supporting Flat, xxyxyz.org/flat
# -----------------------------------------------------------------------------
#
#     ElementPaddingMargin.py
#
#     Show element padding and margin
#
from pagebot.document import Document
from pagebot.elements import newRect
from pagebot.toolbox.units import p, pt
from pagebot.toolbox.color import color
from pagebot.conditions import *

W = H = 500
PADDING = p(2)
MARGIN = p(1)

doc = Document(w=W, h=H, originTop=False)
view = doc.view
view.padding = p(4)
view.showCropMarks = True
view.showFrame = True
view.showPadding = True  # Show padding and margin on page
view.showMargin = True

page = doc[1]  # Get the single page from te document.
page.margin = page.bleed = MARGIN
page.padding = PADDING

# Add element without conditions. Hard positioning from bottom-left
Exemplo n.º 12
0
# -----------------------------------------------------------------------------
#
#     ElementBleedConditions.py
#
#     Position elements by their bleed sides with conditions
#
# Document is the main instance holding all information about
# the document togethers (pages, styles, etc.)
from pagebot.document import Document
from pagebot.elements import newRect
from pagebot.toolbox.units import p, pt
from pagebot.toolbox.color import color
from pagebot.conditions import *

W = H = pt(500)
PADDING = p(8)
BLEED = p(1)
w = PADDING + BLEED  # Square fills bleed and padding

doc = Document(w=W, h=H, originTop=False)
doc.view.padding = p(6)  # View padding around the page.

page = doc[1]  # Get the single page from te document.
page.padding = PADDING

page.showPadding = True
page.showFrame = True
page.showCropMarks = True
page.bleed = BLEED

newRect(parent=page,
Exemplo n.º 13
0
# -----------------------------------------------------------------------------
#
#     ElementConditions.py
#
#     Position elements by their page padding position with conditions
#
# Document is the main instance holding all information about
# the document togethers (pages, styles, etc.)
from pagebot.document import Document
from pagebot.elements import newRect
from pagebot.toolbox.units import p, pt
from pagebot.toolbox.color import color
from pagebot.conditions import *

W = H = pt(500)
PADDING = p(8)
w = p(8)

doc = Document(w=W, h=H, originTop=False)
page = doc[1]  # Get the single page from te document.
page.padding = PADDING

page.showPadding = True

# Position on the outside of the page padding
newRect(parent=page,
        w=w,
        h=w,
        fill=color('red'),
        conditions=[Right2Left(), Top2Bottom()])
newRect(parent=page,
Exemplo n.º 14
0
# -----------------------------------------------------------------------------
#
#     ElementSideConditions.py
#
#     Position elements by their page sides with conditions
#
# Document is the main instance holding all information about
# the document togethers (pages, styles, etc.)
from pagebot.document import Document
from pagebot.elements import newRect
from pagebot.toolbox.units import p, pt
from pagebot.toolbox.color import color
from pagebot.conditions import *

W = H = pt(500)
PADDING = w = p(10)  # Make square will the page padding

doc = Document(w=W, h=H, originTop=False)
page = doc[1]  # Get the single page from te document.
page.padding = PADDING

page.showPadding = True

newRect(parent=page,
        w=w,
        h=w,
        fill=color('red'),
        conditions=[Left2SideLeft(), Bottom2SideBottom()])
newRect(parent=page,
        w=w,
        h=w,
Exemplo n.º 15
0
    context = DrawBotContext()
    EXPORT_PATHS = ['_export/Image.pdf']

font = findFont('Upgrade-Medium')  # Is available in Adobe
styles = {}
styles['h0'] = dict(name='h0',
                    font=font,
                    fontSize=pt(48),
                    leading=em(0.9),
                    textFill=color(1, 0, 0))
styles['h1'] = dict(name='h1',
                    font=font,
                    fontSize=pt(24),
                    leading=em(0.9),
                    textFill=color(1, 0, 0))
doc = Document(w=510, h=720, context=context, autoPages=8, padding=p(4))
doc.styles = styles  # Overwrite all default styles.
page = doc[2]
scaleType = None  #SCALE_TYPE_FITWH # for non-proportional
e = Image('resources/images/cookbot10.jpg',
          parent=page,
          x=page.pl,
          y=page.pt,
          w=page.pw,
          h=page.pw,
          scaleImage=False,
          fill=color(0.5),
          scaleType=scaleType)
page = doc[3]
e = Image('resources/images/cookbot10.jpg',
          parent=page,