"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xhtml2pdf/context.py" between
xhtml2pdf-0.2.6.tar.gz and xhtml2pdf-0.2.7.tar.gz

About: xhtml2pdf is a HTML/CSS to PDF converter written in Python.

context.py  (xhtml2pdf-0.2.6):context.py  (xhtml2pdf-0.2.7)
skipping to change at line 37 skipping to change at line 37
from reportlab.lib.styles import ParagraphStyle from reportlab.lib.styles import ParagraphStyle
from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfbase.ttfonts import TTFont
from reportlab.platypus.frames import Frame, ShowBoundaryValue from reportlab.platypus.frames import Frame, ShowBoundaryValue
from reportlab.platypus.paraparser import ParaFrag, ps2tt, tt2ps from reportlab.platypus.paraparser import ParaFrag, ps2tt, tt2ps
import xhtml2pdf.default import xhtml2pdf.default
import xhtml2pdf.parser import xhtml2pdf.parser
from xhtml2pdf.files import getFile, pisaFileObject from xhtml2pdf.files import getFile, pisaFileObject
from xhtml2pdf.util import (arabic_format, copy_attrs, frag_text_language_check, getColor, getCoords, from xhtml2pdf.util import (arabic_format, copy_attrs, frag_text_language_check, getColor, getCoords,
getFrameDimensions, getSize, set_asian_fonts, set_va lue) getFrameDimensions, getSize, set_asian_fonts, set_va lue, getFloat)
from xhtml2pdf.w3c import css from xhtml2pdf.w3c import css
from xhtml2pdf.xhtml2pdf_reportlab import (PmlPageCount, PmlPageTemplate, PmlPar agraph, from xhtml2pdf.xhtml2pdf_reportlab import (PmlPageCount, PmlPageTemplate, PmlPar agraph,
PmlParagraphAndImage, PmlTableOfConte nts) PmlParagraphAndImage, PmlTableOfConte nts)
import urllib.parse as urlparse import urllib.parse as urlparse
TupleType = tuple TupleType = tuple
ListType = list ListType = list
rl_settings.warnOnMissingFontGlyphs = 0 rl_settings.warnOnMissingFontGlyphs = 0
log = logging.getLogger("xhtml2pdf") log = logging.getLogger("xhtml2pdf")
skipping to change at line 203 skipping to change at line 203
if type(attr) in (list, tuple): if type(attr) in (list, tuple):
for a in attr: for a in attr:
if a in data: if a in data:
return func(data[a]) return func(data[a])
return default return default
else: else:
if attr in data: if attr in data:
return func(data[attr]) return func(data[attr])
return default return default
def get_background_context(self, data):
dev = {}
object_position = data.get('background-object-position', None)
height=data.get('background-height', None)
width=data.get('background-width', None)
opacity=data.get('background-opacity', None)
dev['step']=getFloat(data.get('background-page-step', 1))
if object_position:
dev['object_position'] = [getSize(object_position[0]), getSize(objec
t_position[1])]
if height:
dev['height'] = getSize(height)
if width:
dev['width'] = getSize(width)
if opacity:
dev['opacity'] = getFloat(opacity)
return dev
def atPage(self, name, pseudopage, data, isLandscape, pageBorder): def atPage(self, name, pseudopage, data, isLandscape, pageBorder):
c = self.c c = self.c
name = name or "body" name = name or "body"
if name in c.templateList: if name in c.templateList:
log.warning( log.warning(
self.c.warning("template '%s' has already been defined", name)) self.c.warning("template '%s' has already been defined", name))
padding_top = self._getFromData(data, 'padding-top', 0, getSize) padding_top = self._getFromData(data, 'padding-top', 0, getSize)
padding_left = self._getFromData(data, 'padding-left', 0, getSize) padding_left = self._getFromData(data, 'padding-left', 0, getSize)
skipping to change at line 278 skipping to change at line 295
showBoundary=frame_border) showBoundary=frame_border)
if static: if static:
frame.pisaStaticStory = [] frame.pisaStaticStory = []
c.frameStatic[static] = [frame] + c.frameStatic.get(static, []) c.frameStatic[static] = [frame] + c.frameStatic.get(static, [])
staticList.append(frame) staticList.append(frame)
else: else:
frameList.append(frame) frameList.append(frame)
background = data.get("background-image", None) background = data.get("background-image", None)
background_context = self.get_background_context(data)
if background: if background:
# should be relative to the css file # should be relative to the css file
background = self.c.getFile( background = self.c.getFile(
background, relative=self.c.cssParser.rootPath) background, relative=self.c.cssParser.rootPath)
if not frameList: if not frameList:
log.warning( log.warning(
c.warning("missing explicit frame definition for content or just static frames")) c.warning("missing explicit frame definition for content or just static frames"))
fname, static, border, x, y, w, h, data = self._pisaAddFrame(name, d ata, first=True, border=pageBorder, fname, static, border, x, y, w, h, data = self._pisaAddFrame(name, d ata, first=True, border=pageBorder,
size=c. pageSize) size=c. pageSize)
skipping to change at line 316 skipping to change at line 334
showBoundary=frame_border)) showBoundary=frame_border))
pt = PmlPageTemplate( pt = PmlPageTemplate(
id=name, id=name,
frames=frameList, frames=frameList,
pagesize=c.pageSize, pagesize=c.pageSize,
) )
pt.pisaStaticList = staticList pt.pisaStaticList = staticList
pt.pisaBackground = background pt.pisaBackground = background
pt.pisaBackgroundList = c.pisaBackgroundList pt.pisaBackgroundList = c.pisaBackgroundList
pt.backgroundContext = background_context
if isLandscape: if isLandscape:
pt.pageorientation = pt.LANDSCAPE pt.pageorientation = pt.LANDSCAPE
c.templateList[name] = pt c.templateList[name] = pt
c.template = None c.template = None
c.frameList = [] c.frameList = []
c.frameStaticList = [] c.frameStaticList = []
return {}, {} return {}, {}
skipping to change at line 370 skipping to change at line 389
return result return result
class pisaContext(object): class pisaContext(object):
""" """
Helper class for creation of reportlab story and container for Helper class for creation of reportlab story and container for
various data. various data.
""" """
def __init__(self, path, debug=0, capacity=-1): def __init__(self, path, debug=0, capacity=-1):
self.fontList = copy.copy(xhtml2pdf.default.DEFAULT_FONT) self.fontList = copy.copy(xhtml2pdf.default.DEFAULT_FONT)
self.asianFontList = copy.copy(xhtml2pdf.default.DEFAULT_ASIAN_FONT) self.asianFontList = copy.copy(xhtml2pdf.util.get_default_asian_font())
set_value(self, set_value(self,
('path', 'story', 'text', 'log', 'frameStaticList', ('path', 'story', 'text', 'log', 'frameStaticList',
'pisaBackgroundList', 'frameList', 'anchorFrag', 'pisaBackgroundList', 'frameList', 'anchorFrag',
'anchorName', 'fragList', 'fragAnchor', 'fragStack' 'anchorName', 'fragList', 'fragAnchor', 'fragStack'
), [], _copy=True) ), [], _copy=True)
set_value(self, ('node', 'indexing_story', set_value(self, ('node', 'indexing_story',
'template', 'keepInFrameIndex', 'template', 'keepInFrameIndex',
'tableData', 'image'), 'tableData', 'image'),
None) None)
 End of changes. 5 change blocks. 
2 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)