QScintilla/Exporters/ExporterPDF.py

changeset 3039
8dd0165d805d
parent 3034
7ce719013078
child 3060
5883ce99ee12
child 3160
209a07d7e401
equal deleted inserted replaced
3038:7fe9a53280bd 3039:8dd0165d805d
194 # leading is the term for distance between lines 194 # leading is the term for distance between lines
195 self.leading = self.fontSize * PDF_SPACING_DEFAULT 195 self.leading = self.fontSize * PDF_SPACING_DEFAULT
196 196
197 # sanity check for page size and margins 197 # sanity check for page size and margins
198 pageWidthMin = int(self.leading) + \ 198 pageWidthMin = int(self.leading) + \
199 self.pageMargins["left"] + self.pageMargins["right"] 199 self.pageMargins["left"] + self.pageMargins["right"]
200 if self.pageWidth < pageWidthMin: 200 if self.pageWidth < pageWidthMin:
201 self.pageWidth = pageWidthMin 201 self.pageWidth = pageWidthMin
202 pageHeightMin = int(self.leading) + \ 202 pageHeightMin = int(self.leading) + \
203 self.pageMargins["top"] + self.pageMargins["bottom"] 203 self.pageMargins["top"] + self.pageMargins["bottom"]
204 if self.pageHeight < pageHeightMin: 204 if self.pageHeight < pageHeightMin:
205 self.pageHeight = pageHeightMin 205 self.pageHeight = pageHeightMin
206 206
207 # start to write PDF file here (PDF1.4Ref(p63)) 207 # start to write PDF file here (PDF1.4Ref(p63))
208 # ASCII>127 characters to indicate binary-possible stream 208 # ASCII>127 characters to indicate binary-possible stream
241 for i in range(self.pageCount): 241 for i in range(self.pageCount):
242 buffer = "<</Type/Page/Parent {0:d} 0 R\n" \ 242 buffer = "<</Type/Page/Parent {0:d} 0 R\n" \
243 "/MediaBox[ 0 0 {1:d} {2:d}]\n" \ 243 "/MediaBox[ 0 0 {1:d} {2:d}]\n" \
244 "/Contents {3:d} 0 R\n" \ 244 "/Contents {3:d} 0 R\n" \
245 "/Resources {4:d} 0 R\n>>\n".format( 245 "/Resources {4:d} 0 R\n>>\n".format(
246 pagesRef, self.pageWidth, self.pageHeight, 246 pagesRef, self.pageWidth, self.pageHeight,
247 self.pageContentStart + i, resourceRef) 247 self.pageContentStart + i, resourceRef)
248 self.oT.add(buffer) 248 self.oT.add(buffer)
249 249
250 # create page tree object (PDF1.4Ref(p86)) 250 # create page tree object (PDF1.4Ref(p86))
251 self.pageData = "<</Type/Pages/Kids[\n" 251 self.pageData = "<</Type/Pages/Kids[\n"
252 for i in range(self.pageCount): 252 for i in range(self.pageCount):
478 # or the default style if no language is available... 478 # or the default style if no language is available...
479 if lex: 479 if lex:
480 istyle = 0 480 istyle = 0
481 while istyle <= QsciScintilla.STYLE_MAX: 481 while istyle <= QsciScintilla.STYLE_MAX:
482 if (istyle <= QsciScintilla.STYLE_DEFAULT or 482 if (istyle <= QsciScintilla.STYLE_DEFAULT or
483 istyle > QsciScintilla.STYLE_LASTPREDEFINED): 483 istyle > QsciScintilla.STYLE_LASTPREDEFINED):
484 if lex.description(istyle) or \ 484 if lex.description(istyle) or \
485 istyle == QsciScintilla.STYLE_DEFAULT: 485 istyle == QsciScintilla.STYLE_DEFAULT:
486 style = PDFStyle() 486 style = PDFStyle()
487 487
488 font = lex.font(istyle) 488 font = lex.font(istyle)
598 self.editor, 598 self.editor,
599 self.trUtf8("Export source"), 599 self.trUtf8("Export source"),
600 self.trUtf8( 600 self.trUtf8(
601 """<p>The source could not be exported to""" 601 """<p>The source could not be exported to"""
602 """ <b>{0}</b>.</p><p>Reason: {1}</p>""") 602 """ <b>{0}</b>.</p><p>Reason: {1}</p>""")
603 .format(filename, str(err))) 603 .format(filename, str(err)))
604 finally: 604 finally:
605 QApplication.restoreOverrideCursor() 605 QApplication.restoreOverrideCursor()

eric ide

mercurial