"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xhtml2pdf/tags.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.

tags.py  (xhtml2pdf-0.2.6):tags.py  (xhtml2pdf-0.2.7)
skipping to change at line 20 skipping to change at line 20
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import print_function, unicode_literals from __future__ import print_function, unicode_literals
import copy import copy
import json
import logging import logging
import re import re
import string import string
import warnings import warnings
from reportlab.graphics.barcode import createBarcodeDrawing from reportlab.graphics.barcode import createBarcodeDrawing
from reportlab.graphics.charts.legends import Legend
from reportlab.graphics.charts.textlabels import Label
from reportlab.graphics.shapes import Drawing, Rect
from reportlab.lib.pagesizes import A4 from reportlab.lib.pagesizes import A4
from reportlab.lib.units import inch, mm from reportlab.lib.units import inch, mm
from reportlab.platypus.doctemplate import FrameBreak, NextPageTemplate from reportlab.platypus.doctemplate import FrameBreak, NextPageTemplate
from reportlab.platypus.flowables import Flowable, HRFlowable, PageBreak, Spacer from reportlab.platypus.flowables import Flowable, HRFlowable, PageBreak, Spacer
from reportlab.platypus.frames import Frame from reportlab.platypus.frames import Frame
from reportlab.platypus.paraparser import ABag, tt2ps from reportlab.platypus.paraparser import ABag, tt2ps
from .charts import DoughnutChart, PieChart, HorizontalLine, VerticalBar, Horizo ntalBar, LegendedPieChart
from xhtml2pdf import xhtml2pdf_reportlab from xhtml2pdf import xhtml2pdf_reportlab
from xhtml2pdf.util import dpi96, getAlign, getColor, getSize from xhtml2pdf.util import dpi96, getAlign, getColor, getSize
from xhtml2pdf.xhtml2pdf_reportlab import PmlImage, PmlPageTemplate from xhtml2pdf.xhtml2pdf_reportlab import PmlImage, PmlPageTemplate
log = logging.getLogger("xhtml2pdf") log = logging.getLogger("xhtml2pdf")
def deprecation(message): def deprecation(message):
warnings.warn("<" + message + "> is deprecated!", DeprecationWarning, stackl evel=2) warnings.warn("<" + message + "> is deprecated!", DeprecationWarning, stackl evel=2)
class pisaTag: class pisaTag:
skipping to change at line 719 skipping to change at line 725
afrag.text = "" afrag.text = ""
afrag.fontName = fontName afrag.fontName = fontName
afrag.cbDefn = ABag( afrag.cbDefn = ABag(
kind="barcode", kind="barcode",
barcode=barcode, barcode=barcode,
width=width, width=width,
height=height, height=height,
valign=valign, valign=valign,
) )
c.fragList.append(afrag) c.fragList.append(afrag)
class pisaTagCANVAS(pisaTag):
def __init__(self, node, attr):
super().__init__(node, attr)
self.chart = None
self.shapes = {
'horizontalbar': HorizontalBar,
'verticalbar': VerticalBar,
'horizontalline': HorizontalLine,
'pie': PieChart,
'doughnut': DoughnutChart,
'legendedPie': LegendedPieChart
}
def start(self, c):
pass
def end(self, c):
data = None
width = 350
height = 150
try:
data = json.loads(c.text)
except json.JSONDecodeError:
print("JSON Decode Error")
if data:
nodetype = dict(c.node.attributes).get('type')
nodewidth = dict(c.node.attributes).get('width')
nodeheight = dict(c.node.attributes).get('height')
canvastype = None
if nodetype is not None:
canvastype = nodetype.nodeValue
if canvastype:
c.clearFrag()
if nodewidth:
width = int(nodewidth.nodeValue)
if nodeheight:
height = int(nodeheight.nodeValue)
self.chart = self.shapes[data['type']]()
draw = Drawing(width, height) # CONTAINER
draw.background = Rect(115, 25, width, height, strokeWidth=1, stroke
Color="#868686", fillColor="#f8fce8")
# REQUIRED DATA
self.chart.set_properties(data)
#OPTIONAL DATA
if "title" in data:
title = Label()
self.chart.set_title_properties(data['title'], title)
draw.add(title)
if "legend" in data:
if data["legend"]:
legend = Legend()
self.chart.set_legend(data['legend'], legend)
self.chart.load_data_legend(data, legend)
draw.add(legend)
# ADD CHART TO DRAW OBJECT
draw.add(self.chart)
c.addStory(draw)
 End of changes. 5 change blocks. 
0 lines changed or deleted 6 lines changed or added

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