MCPcopy Index your code
hub / github.com/clips/pattern / PDFResourceManager

Class PDFResourceManager

pattern/web/pdf/pdfinterp.py:124–200  ·  view source on GitHub ↗

Repository of shared resources. ResourceManager facilitates reuse of shared resources such as fonts and images so that large objects are not allocated multiple times.

Source from the content-addressed store, hash-verified

122## Resource Manager
123##
124class PDFResourceManager(object):
125
126 """Repository of shared resources.
127
128 ResourceManager facilitates reuse of shared resources
129 such as fonts and images so that large objects are not
130 allocated multiple times.
131 """
132 debug = 0
133
134 def __init__(self, caching=True):
135 self.caching = caching
136 self._cached_fonts = {}
137 return
138
139 def get_procset(self, procs):
140 for proc in procs:
141 if proc is LITERAL_PDF:
142 pass
143 elif proc is LITERAL_TEXT:
144 pass
145 else:
146 #raise PDFResourceError('ProcSet %r is not supported.' % proc)
147 pass
148 return
149
150 def get_cmap(self, cmapname, strict=False):
151 try:
152 return CMapDB.get_cmap(cmapname)
153 except CMapDB.CMapNotFound:
154 if strict: raise
155 return CMap()
156
157 def get_font(self, objid, spec):
158 if objid and objid in self._cached_fonts:
159 font = self._cached_fonts[objid]
160 else:
161 if 2 <= self.debug:
162 print >>sys.stderr, 'get_font: create: objid=%r, spec=%r' % (objid, spec)
163 if STRICT:
164 if spec['Type'] is not LITERAL_FONT:
165 raise PDFFontError('Type is not /Font')
166 # Create a Font object.
167 if 'Subtype' in spec:
168 subtype = literal_name(spec['Subtype'])
169 else:
170 if STRICT:
171 raise PDFFontError('Font Subtype is not specified.')
172 subtype = 'Type1'
173 if subtype in ('Type1', 'MMType1'):
174 # Type1 Font
175 font = PDFType1Font(self, spec)
176 elif subtype == 'TrueType':
177 # TrueType Font
178 font = PDFTrueTypeFont(self, spec)
179 elif subtype == 'Type3':
180 # Type3 Font
181 font = PDFType3Font(self, spec)

Callers 1

_parseMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…