changes in pdf: footer on first page, logo next to title, no duplicate title
authorJan Szejko <janek37@gmail.com>
Fri, 23 Mar 2018 15:36:49 +0000 (16:36 +0100)
committerJan Szejko <janek37@gmail.com>
Fri, 23 Mar 2018 15:36:49 +0000 (16:36 +0100)
librarian/formats/pdf/__init__.py
librarian/formats/pdf/res/wl.cls

index bc3d2f5..10313c8 100644 (file)
@@ -116,10 +116,11 @@ class PdfFormat(Format):
         t.append(texml_cmd("title", title))
 
         doc = etree.SubElement(t, TexmlNS('env'), name="document")
         t.append(texml_cmd("title", title))
 
         doc = etree.SubElement(t, TexmlNS('env'), name="document")
-        doc.append(texml_cmd("thispagestyle", "empty"))
 
         # Wielkości!
 
         # Wielkości!
-        grp = etree.SubElement(doc, 'group')
+        title_field = texml_cmd("titlefield", "")
+        doc.append(title_field)
+        grp = title_field[0]
         grp.append(texml_cmd("raggedright"))
         grp.append(texml_cmd("vfill"))
         if author:
         grp.append(texml_cmd("raggedright"))
         grp.append(texml_cmd("vfill"))
         if author:
@@ -146,14 +147,14 @@ class PdfFormat(Format):
         if cover_logo_url:
             self.add_file(build_ctx, 'coverlogo.png', cover_logo_url, image=True)
             size = Image.open(self.get_file(build_ctx, 'coverlogo.png')).size
         if cover_logo_url:
             self.add_file(build_ctx, 'coverlogo.png', cover_logo_url, image=True)
             size = Image.open(self.get_file(build_ctx, 'coverlogo.png')).size
-            p = texml_cmd("par", "")
-            doc.append(p)
-            p[0].append(texml_cmd("noindent"))
-            p[0].append(texml_cmd("insertimage", 'coverlogo.png', "%fcm" % (2.0 * size[0] / size[1]), "2cm"))
+            doc.append(texml_cmd("toplogo", 'coverlogo.png', "%fcm" % (2.0 * size[0] / size[1]), "2cm"))
+
         doc.append(texml_cmd("vspace", "2em"))
 
         ctx = Context(build_ctx, format=self, img=1)
         doc.append(texml_cmd("vspace", "2em"))
 
         ctx = Context(build_ctx, format=self, img=1)
-        doc.extend(self.render(self.doc.edoc.getroot(), ctx))
+        root = self.doc.edoc.getroot()
+        root.remove(root[1])
+        doc.extend(self.render(root, ctx))
 
         # Redakcyjna na końcu.
         doc.append(texml_cmd("section*", "Information about the resource"))
 
         # Redakcyjna na końcu.
         doc.append(texml_cmd("section*", "Information about the resource"))
index fb2796a..d871e51 100755 (executable)
@@ -429,3 +429,18 @@ Letters={Uppercase}
 #1%
 \pagebreak%
 }
 #1%
 \pagebreak%
 }
+
+\newcommand{\titlefield}[1]{%
+\noindent%
+\begin{minipage}[t]{.7\textwidth}%
+\vspace{0pt}%
+#1%
+\end{minipage}%
+}
+
+\newcommand{\toplogo}[3]{%
+\begin{minipage}[t]{.3\textwidth}%
+\raggedleft%
+\vspace{0pt}{\includegraphics[height=#2,width=#3]{#1}}%
+\end{minipage}%
+}
\ No newline at end of file