eric6/QScintilla/Exporters/ExporterPDF.py

changeset 7267
aedc309827c7
parent 7249
0bf517e60f54
child 7360
9190402e4505
--- a/eric6/QScintilla/Exporters/ExporterPDF.py	Wed Sep 25 18:25:43 2019 +0200
+++ b/eric6/QScintilla/Exporters/ExporterPDF.py	Wed Sep 25 18:37:35 2019 +0200
@@ -177,12 +177,18 @@
         
         buf = ""
         if styleNext != self.styleCurrent or style_ == -1:
-            if self.style[self.styleCurrent].font != \
-                    self.style[styleNext].font or style_ == -1:
+            if (
+                (self.style[self.styleCurrent].font !=
+                 self.style[styleNext].font) or
+                style_ == -1
+            ):
                 buf += "/F{0:d} {1:d} Tf ".format(
                     self.style[styleNext].font + 1, self.fontSize)
-            if self.style[self.styleCurrent].fore != \
-                    self.style[styleNext].fore or style_ == -1:
+            if (
+                (self.style[self.styleCurrent].fore !=
+                 self.style[styleNext].fore) or
+                style_ == -1
+            ):
                 buf += "{0}rg ".format(self.style[styleNext].fore)
         return buf
         
@@ -197,12 +203,18 @@
         self.leading = self.fontSize * PDF_SPACING_DEFAULT
         
         # sanity check for page size and margins
-        pageWidthMin = int(self.leading) + \
-            self.pageMargins["left"] + self.pageMargins["right"]
+        pageWidthMin = (
+            int(self.leading) +
+            self.pageMargins["left"] +
+            self.pageMargins["right"]
+        )
         if self.pageWidth < pageWidthMin:
             self.pageWidth = pageWidthMin
-        pageHeightMin = int(self.leading) + \
-            self.pageMargins["top"] + self.pageMargins["bottom"]
+        pageHeightMin = (
+            int(self.leading) +
+            self.pageMargins["top"] +
+            self.pageMargins["bottom"]
+        )
         if self.pageHeight < pageHeightMin:
             self.pageHeight = pageHeightMin
         
@@ -215,10 +227,12 @@
         # *expected* to start from index 1 since they are the first objects
         # to be inserted (PDF1.4Ref(p317))
         for i in range(4):
-            buffer = \
-                "<</Type/Font/Subtype/Type1/Name/F{0:d}/BaseFont/{1}/" \
-                "Encoding/{2}>>\n".format(
-                    i + 1, PDFfontNames[self.fontSet * 4 + i], PDF_ENCODING)
+            buffer = (
+                "<</Type/Font/Subtype/Type1/Name/F{0:d}/BaseFont/{1}/"
+                "Encoding/{2}>>\n"
+            ).format(
+                i + 1, PDFfontNames[self.fontSet * 4 + i], PDF_ENCODING
+            )
             self.oT.add(buffer)
         
         self.pageContentStart = self.oT.index
@@ -241,12 +255,15 @@
         pageObjectStart = self.oT.index
         pagesRef = pageObjectStart + self.pageCount
         for i in range(self.pageCount):
-            buffer = "<</Type/Page/Parent {0:d} 0 R\n" \
-                     "/MediaBox[ 0 0 {1:d} {2:d}]\n" \
-                     "/Contents {3:d} 0 R\n" \
-                     "/Resources {4:d} 0 R\n>>\n".format(
-                         pagesRef, self.pageWidth, self.pageHeight,
-                         self.pageContentStart + i, resourceRef)
+            buffer = (
+                "<</Type/Page/Parent {0:d} 0 R\n"
+                "/MediaBox[ 0 0 {1:d} {2:d}]\n"
+                "/Contents {3:d} 0 R\n"
+                "/Resources {4:d} 0 R\n>>\n"
+            ).format(
+                pagesRef, self.pageWidth, self.pageHeight,
+                self.pageContentStart + i, resourceRef
+            )
             self.oT.add(buffer)
         
         # create page tree object (PDF1.4Ref(p86))
@@ -264,9 +281,10 @@
         xref = self.oT.xref()
         
         # end the file with the trailer (PDF1.4Ref(p67))
-        buffer = \
-            "trailer\n<< /Size {0:d} /Root {1:d} 0 R\n>>\nstartxref\n{2:d}\n" \
-            "%%EOF\n".format(self.oT.index, catalogRef, xref)
+        buffer = (
+            "trailer\n<< /Size {0:d} /Root {1:d} 0 R\n>>\nstartxref\n{2:d}\n"
+            "%%EOF\n"
+        ).format(self.oT.index, catalogRef, xref)
         self.oT.write(buffer)
         
     def add(self, ch, style_):
@@ -483,8 +501,10 @@
                 while istyle <= QsciScintilla.STYLE_MAX:
                     if (istyle <= QsciScintilla.STYLE_DEFAULT or
                             istyle > QsciScintilla.STYLE_LASTPREDEFINED):
-                        if lex.description(istyle) or \
-                           istyle == QsciScintilla.STYLE_DEFAULT:
+                        if (
+                            lex.description(istyle) or
+                            istyle == QsciScintilla.STYLE_DEFAULT
+                        ):
                             style = PDFStyle()
                             
                             font = lex.font(istyle)
@@ -558,8 +578,10 @@
                             column += ts
                             self.pr.add(' ' * ts, style)
                         elif ch == b'\r' or ch == b'\n':
-                            if ch == b'\r' and \
-                                    self.editor.byteAt(pos + 1) == b'\n':
+                            if (
+                                ch == b'\r' and
+                                self.editor.byteAt(pos + 1) == b'\n'
+                            ):
                                 pos += 1
                             # close and begin a newline...
                             self.pr.nextLine()

eric ide

mercurial