home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / hplip / fax / coverpages.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-08-31  |  4.1 KB  |  104 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. from reportlab.platypus.paragraph import Paragraph
  5. from reportlab.platypus.doctemplate import *
  6. from reportlab.platypus import SimpleDocTemplate, Spacer
  7. from reportlab.platypus.tables import Table, TableStyle
  8. from reportlab.lib.pagesizes import letter, legal, A4
  9. from reportlab.lib.units import inch
  10. from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
  11. from reportlab.lib import colors
  12. from time import localtime, strftime
  13. from base import utils
  14. PAGE_SIZE_LETTER = 'letter'
  15. PAGE_SIZE_LEGAL = 'legal'
  16. PAGE_SIZE_A4 = 'a4'
  17.  
  18. def createStandardCoverPage(page_size = PAGE_SIZE_LETTER, total_pages = 1, recipient_name = '', recipient_phone = '', recipient_fax = '', sender_name = '', sender_phone = '', sender_fax = '', sender_email = '', regarding = '', message = ''):
  19.     s = getSampleStyleSheet()
  20.     story = []
  21.     ps = ParagraphStyle(name = 'title', parent = None, fontName = 'helvetica-bold', fontSize = 36)
  22.     story.append(Paragraph('Fax', ps))
  23.     story.append(Spacer(1, inch))
  24.     ps = ParagraphStyle(name = 'normal', fontName = 'Times-Roman', fontSize = 12)
  25.     recipient_name_label = Paragraph('To:', ps)
  26.     recipient_name_text = Paragraph(recipient_name[:64], ps)
  27.     recipient_fax_label = Paragraph('Fax:', ps)
  28.     recipient_fax_text = Paragraph(recipient_fax[:64], ps)
  29.     recipient_phone_label = Paragraph('Phone:', ps)
  30.     recipient_phone_text = Paragraph(recipient_phone[:64], ps)
  31.     sender_name_label = Paragraph('From:', ps)
  32.     sender_name_text = Paragraph(sender_name[:64], ps)
  33.     sender_phone_label = Paragraph('Phone:', ps)
  34.     sender_phone_text = Paragraph(sender_phone[:64], ps)
  35.     sender_email_label = Paragraph('Email:', ps)
  36.     sender_email_text = Paragraph(sender_email[:64], ps)
  37.     regarding_label = Paragraph('Regarding:', ps)
  38.     regarding_text = Paragraph(regarding[:128], ps)
  39.     date_time_label = Paragraph('Date:', ps)
  40.     date_time_text = Paragraph(strftime('%a, %d %b %Y %H:%M:%S (%Z)', localtime()), ps)
  41.     total_pages_label = Paragraph('Total Pages:', ps)
  42.     total_pages_text = Paragraph('%d' % total_pages, ps)
  43.     data = [
  44.         [
  45.             recipient_name_label,
  46.             recipient_name_text,
  47.             sender_name_label,
  48.             sender_name_text],
  49.         [
  50.             recipient_fax_label,
  51.             recipient_fax_text,
  52.             sender_phone_label,
  53.             sender_phone_text],
  54.         [
  55.             date_time_label,
  56.             date_time_text,
  57.             sender_email_label,
  58.             sender_email_text],
  59.         [
  60.             regarding_label,
  61.             regarding_text,
  62.             total_pages_label,
  63.             total_pages_text]]
  64.     LIST_STYLE = TableStyle([
  65.         ('LINEABOVE', (0, 0), (-1, 0), 2, colors.black),
  66.         ('LINEABOVE', (0, 1), (-1, -1), 0.25, colors.black),
  67.         ('LINEBELOW', (0, -1), (-1, -1), 2, colors.black),
  68.         ('ALIGN', (1, 1), (-1, -1), 'RIGHT'),
  69.         ('VALIGN', (0, 0), (-1, -1), 'TOP')])
  70.     t = Table(data, style = LIST_STYLE)
  71.     story.append(t)
  72.     if message:
  73.         MSG_STYLE = TableStyle([
  74.             ('LINEABOVE', (0, 0), (-1, 0), 2, colors.black),
  75.             ('LINEABOVE', (0, 1), (-1, -1), 0.25, colors.black),
  76.             ('LINEBELOW', (0, -1), (-1, -1), 2, colors.black),
  77.             ('ALIGN', (1, 1), (-1, -1), 'RIGHT'),
  78.             ('VALIGN', (0, 0), (-1, -1), 'TOP'),
  79.             ('SPAN', (-2, 1), (-1, -1))])
  80.         story.append(Spacer(1, 0.5 * inch))
  81.         data = [
  82.             [
  83.                 Paragraph('Comments/Notes:', ps),
  84.                 ''],
  85.             [
  86.                 Paragraph(message[:2048], ps),
  87.                 '']]
  88.         t = Table(data, style = MSG_STYLE)
  89.         story.append(t)
  90.     
  91.     if page_size == PAGE_SIZE_LETTER:
  92.         pgsz = letter
  93.     elif page_size == PAGE_SIZE_LEGAL:
  94.         pgsz = legal
  95.     else:
  96.         pgsz = A4
  97.     (f_fd, f) = utils.make_temp_file()
  98.     doc = SimpleDocTemplate(f, pagesize = pgsz)
  99.     doc.build(story)
  100.     return f
  101.  
  102. COVERPAGES = {
  103.     'basic': (createStandardCoverPage, 'standard_coverpage.png') }
  104.