I have been struggling in an attempt to change the paragraph style in report lab. I think the issue is probably a lack of understanding what classes are. If anyone could give me some pointers that would be awesome. Bellow is my code. When I run it I get the error 'Error when calling the metaclass bases init() takes at most 3 arguments (4 given)'.
Cheers,
Robin
from reportlab.lib.styles import ParagraphStyle
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.units import mm
from reportlab.platypus import Paragraph, Frame
Title = 'Test'
c = Canvas(str(Title)+'.pdf')
story = []
file = open('Acknowledgements.txt','r')
lis = []
for line in file:
lis.append(line)
styles = getSampleStyleSheet()
styleN = styles['Normal']
styleH = styles['Heading1']
class ParagraphStyle(styleN):
defaults = {
'fontName':'Helvetica',
'fontSize':14,
'leading':12,
'leftIndent':0,
'rightIndent':0,
'firstLineIndent':0,
'alignment':0,
'spaceBefore':0,
'spaceAfter':0,
'bulletFontName':'Helvetica',
'bulletFontSize':10,
'bulletIndent':0,
'textColor': 'k',
'backColor':None,
'wordWrap':None,
'borderWidth': 0,
'borderPadding': 0,
'borderColor': None,
'borderRadius': None,
'allowWidows': 1,
'allowOrphans': 0,
'textTransform':None,
'endDots':None,
'splitLongWords':1,
'underlineProportion': 0,
'bulletAnchor': 'start',
'justifyLastLine': 0,
'justifyBreaks': 0,
'spaceShrinkage': 0,
}
story.append(Paragraph('Acknowledgements', styleH))
for l in lis:
story.append(Paragraph(l, styleN))
f = Frame(110*mm, 0*mm, 90*mm, 280*mm, showBoundary=0)
f.addFromList(story,c)
c.save()