[reportlab-users] Can not print generated document on HP Laserjet 4100DTN

Andreas Martin reportlab-users@reportlab.com
Sat, 14 Jun 2003 00:25:07 +0200


Hello !

My Name is Andreas Martin and I just started to use the reportlab pdf
generation functionality. I have a problem with printing my document on
a HP Laserjet 4100DTN postscript printer. 

These are the first lines of my class I use to print my document:

import reportlab
from reportlab.lib.pagesizes import A4,landscape
from reportlab.lib.units import inch,cm
from reportlab.lib import colors, styles
from reportlab.pdfgen import canvas
from reportlab.platypus import *
from reportlab.platypus.paragraph import Paragraph
from reportlab.platypus.tables import Table, TableStyle
from reportlab.platypus.doctemplate import *


class TravelExpensesPrintout:
    "Class for printing a travel expense refund"

    def __init__(self, ter, filename):

        self.built = 0
        self.objects = []

        self.report = cStringIO.StringIO()

        ## Set up the document ----------------------------------

        # Get the DocTemplate and set its pagesize
        pagesize = A4
        self.document = BaseDocTemplate(self.report, pagesize=pagesize)

        # Define the content area
        content = Frame(2*cm, 2*cm, self.document.pagesize[0] - (4*cm),
\
                        self.document.pagesize[1] - (4*cm))
        pt = PageTemplate("general", [content], pagesize=pagesize)
        self.document.addPageTemplates(pt)

        # Styles:
        self.p = styles.ParagraphStyle(name='p', fontName='Helvetica', \
                                       fontSize=10, leading=12)
        self.td = styles.ParagraphStyle(name='p', fontName='Helvetica',
\
                                        fontSize=10, leading=12)
        self.t1c = styles.ParagraphStyle(name='p',
fontName='Helvetica-Bold', \
                                         fontSize=10, leading=12,
alignment=1)
        self.th = styles.ParagraphStyle(name='p',
fontName='Helvetica-Bold', \
                                        fontSize=10, leading=12,
alignment=1)
        self.h1 = styles.ParagraphStyle(name='h1',
fontName='Helvetica-Bold', \
                                        fontSize=16, leading=20)
        self.h2 = styles.ParagraphStyle(name='h1',
fontName='Helvetica-Bold', \
                                        fontSize=14, leading=20)
        self.h3 = styles.ParagraphStyle(name='h1',
fontName='Helvetica-Bold', \
                                        fontSize=12, leading=20)


        ## Generate the content --------------------------------

        # Header
        self.logo = flowables.Image(os.path.join(package_home(\
            globals()),"images/DFKI.jpg"),width=100,height=37)
        self.heading = Paragraph("Reisekostenabrechnung", self.h1)


Xxxxxxxxxxxxxxxxxxxxx prints only to this line
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


        table_data = [[self.heading, self.logo]]
        table_style = TableStyle([('ALIGN', (-1,0), (-1,0), 'RIGHT'),
                                 ('VALIGN', (0,0), (0,0), 'BOTTOM')])
        table = Table(table_data, colWidths=[13*cm,4*cm],
style=table_style)
        self._append(table)

        self._append(Spacer(0, 25))

        # Information on cost center, person, bank, travel purpose
        # and travel dates
        travel_nr = ter.getTravelNr()
        cost_center = Paragraph(ter.getCostCenterDescription()+' ('+\
                                ter.getCostCenterId()+')',self.td)
        emp_name = Paragraph(ter.getTraveller(),self.td)
        phone_nr = ter.getPhoneNumber()
        table_data =
[['Reisenummer:',travel_nr,'Kostenstelle:',cost_center],
                      ['Name:',emp_name, 'Tel.-Nr.:',phone_nr],
                      ]
        table_style =
TableStyle([('BOX',(0,0),(-1,-1),0.25,colors.black),
 
('LINEBELOW',(0,0),(-1,0),0.25,colors.black),
 
('FONTNAME',(0,0),(0,-1),'Helvetica-Bold'),
                                  ('FONTNAME',(1,0),(1,-1),'Helvetica'),
 
('FONTNAME',(2,0),(2,-1),'Helvetica-Bold'),
                                  ('FONTNAME',(3,0),(3,-1),'Helvetica'),
                                  ('FONTSIZE',(0,0),(-1,-1),10)])
        table = Table(table_data, colWidths=[3*cm,5.5*cm,2.5*cm,6*cm],
style=table_style)
        self._append(table)
	  
	  [.......]




When I print the document on a standard windows gdi laser printer I do
not have any problems. When using the HP postscript printer I only get
the heading printed (till the line self.heading =
Paragraph("Reisekostenabrechnung", self.h1)



Any suggestions ?

Thank you
Andreas Martin