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