Ejemplo n.º 1
0
 def __init__(self,
              key,
              psName,
              encoding=kDefaultEncoding,
              fontDescriptObjectNumber=None,
              type=kDefaultFontType,
              firstChar=None,
              lastChar=None,
              widths=None):
     self.fontname = psName
     self.keyname = key
     if encoding is None:
         encoding = '/MacRomanEncoding'
     textList = ['<<', '/Type /Font', '/Subtype %s' % type]
     if fontDescriptObjectNumber != None:
         textList.append("/FontDescriptor %s 0 R" %
                         fontDescriptObjectNumber)
         textList.append("/FirstChar %s" % firstChar)
         textList.append("/LastChar %s" % lastChar)
         textList.append("/Widths %s" % widths)
     textList += [
         '/Name /%s',  # filled in in 'save'
         '/BaseFont /%s',  # filled in in 'save'
         "/Encoding %s" % (encoding),
         '>>'
     ]
     self.template = LINEEND.join(textList)
Ejemplo n.º 2
0
 def save(self, file):
     file.write((LINEEND.join([
         "<</Title (%s)", "/Author (%s)", "/CreationDate (D:%s)",
         "/Producer (PDFgen)", "/Subject (%s)", ">>"
     ]) % (pdfutils._escape(self.title), pdfutils._escape(
         self.author), self.datestr, pdfutils._escape(self.subject)) +
                 LINEEND).encode('utf-8'))
Ejemplo n.º 3
0
 def save(self, file):
     lines = [
         '<<', '/Type /Pages',
         '/Count %d' % len(self.PageList), '/Kids ['
     ]
     for page in self.PageList:
         lines.append(str(page) + ' 0 R ')
     lines.append(']')
     lines.append('>>')
     text = LINEEND.join(lines)
     file.write((text + LINEEND).encode('utf-8'))
Ejemplo n.º 4
0
 def save(self, file):
     file.write(
         LINEEND.join([
             '<<', '/Type /XObject', '/Subtype /Image', '/Name /Im0',
             '/Width 24', '/Height 23', '/BitsPerComponent 1',
             '/ColorSpace /DeviceGray', '/Filter /ASCIIHexDecode',
             '/Length 174', '>>', 'stream',
             '003B00 002700 002480 0E4940 114920 14B220 3CB650',
             '75FE88 17FF8C 175F14 1C07E2 3803C4 703182 F8EDFC',
             'B2BBC2 BB6F84 31BFC2 18EA3C 0E3E00 07FC00 03F800',
             '1E1800 1FF800>', 'endstream', 'endobj'
         ]) + LINEEND)
Ejemplo n.º 5
0
 def __init__(self):
     self.drawables = []
     self.pagewidth = 595  #these are overridden by piddlePDF
     self.pageheight = 842
     self.stream = PDFStream()
     self.hasImages = 0
     self.pageTransitionString = ''  # presentation effects
     # editors on different systems may put different things in the line end
     # without me noticing.  No triple-quoted strings allowed!
     self.template = LINEEND.join([
         '<<',
         '/Type /Page',
         '/Parent %(parentpos)d 0 R',
         '/Resources',
         '   <<',
         '   /Font %(fontdict)s',
         '   /ProcSet %(procsettext)s',
         '   >>',
         '/MediaBox [0 0 %(pagewidth)d %(pageheight)d]',  #A4 by default
         '/Contents %(contentspos)d 0 R',
         '%(transitionString)s',
         '>>'
     ])
Ejemplo n.º 6
0
 def setStream(self, data):
     if isinstance(data, list):
         data = LINEEND.join(data)
     self.stream.setStream(data)
Ejemplo n.º 7
0
 def __init__(self):
     self.template = LINEEND.join(
         ['<<', '/Type /Outlines', '/Count 0', '>>'])
Ejemplo n.º 8
0
 def __init__(self):
     self.template = LINEEND.join([
         '<<', '/Type /Catalog', '/Pages %d 0 R', '/Outlines %d 0 R', '>>'
     ])