Esempio n. 1
0
 def do_Do(self, xobjid):
     xobjid = literal_name(xobjid)
     try:
         xobj = stream_value(self.xobjmap[xobjid])
     except KeyError:
         if STRICT:
             raise PDFInterpreterError('Undefined xobject id: %r' % xobjid)
         return
     if 1 <= self.debug:
         print(('Processing xobj: %r' % xobj))
     subtype = xobj.get('Subtype')
     if subtype is LITERAL_FORM and 'BBox' in xobj:
         interpreter = self.dup()
         bbox = list_value(xobj['BBox'])
         matrix = list_value(xobj.get('Matrix', MATRIX_IDENTITY))
         # According to PDF reference 1.7 section 4.9.1, XObjects in 
         # earlier PDFs (prior to v1.2) use the page's Resources entry
         # instead of having their own Resources entry.
         resources = dict_value(xobj.get('Resources')) or self.resources.copy()
         self.device.begin_figure(xobjid, bbox, matrix)
         interpreter.render_contents(resources, [xobj], ctm=mult_matrix(matrix, self.ctm))
         self.device.end_figure(xobjid)
     elif subtype is LITERAL_IMAGE and 'Width' in xobj and 'Height' in xobj:
         self.device.begin_figure(xobjid, (0,0,1,1), MATRIX_IDENTITY)
         self.device.render_image(xobjid, xobj)
         self.device.end_figure(xobjid)
     else:
         # unsupported xobject type.
         pass
     return
Esempio n. 2
0
 def render_string(self, textstate, seq):
     matrix = mult_matrix(textstate.matrix, self.ctm)
     font = textstate.font
     fontsize = textstate.fontsize
     scaling = textstate.scaling * .01
     charspace = textstate.charspace * scaling
     wordspace = textstate.wordspace * scaling
     rise = textstate.rise
     if font.is_multibyte():
         wordspace = 0
     dxscale = .001 * fontsize * scaling
     if font.is_vertical():
         textstate.linematrix = self.render_string_vertical(
             seq, matrix, textstate.linematrix, font, fontsize,
             scaling, charspace, wordspace, rise, dxscale)
     else:
         textstate.linematrix = self.render_string_horizontal(
             seq, matrix, textstate.linematrix, font, fontsize,
             scaling, charspace, wordspace, rise, dxscale)
     return
Esempio n. 3
0
 def do_cm(self, a1, b1, c1, d1, e1, f1):
     self.ctm = mult_matrix((a1,b1,c1,d1,e1,f1), self.ctm)
     self.device.set_ctm(self.ctm)
     return
Esempio n. 4
0
 def begin_figure(self, name, bbox, matrix):
     self._stack.append(self.cur_item)
     self.cur_item = LTFigure(name, bbox, mult_matrix(matrix, self.ctm))
     return