images in PDF
authorJan Szejko <j-sz@o2.pl>
Mon, 14 Mar 2016 16:51:28 +0000 (17:51 +0100)
committerJan Szejko <j-sz@o2.pl>
Mon, 14 Mar 2016 16:51:28 +0000 (17:51 +0100)
librarian/pdf.py
librarian/pdf/wl.cls
librarian/pdf/wl2tex.xslt
librarian/xslt/book2html.xslt

index c899afa..246fd0c 100644 (file)
@@ -199,7 +199,7 @@ def package_available(package, args='', verbose=False):
 
 
 def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
 
 
 def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
-              cover=None, flags=None, customizations=None):
+              cover=None, flags=None, customizations=None, ilustr_path=''):
     """ produces a PDF file with XeLaTeX
 
     wldoc: a WLDocument
     """ produces a PDF file with XeLaTeX
 
     wldoc: a WLDocument
@@ -268,6 +268,9 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
         # TeXML -> LaTeX
         temp = mkdtemp('-wl2pdf')
 
         # TeXML -> LaTeX
         temp = mkdtemp('-wl2pdf')
 
+        for ilustr in document.edoc.findall("//ilustr"):
+            shutil.copy(os.path.join(ilustr_path, ilustr.get("src")), temp)
+
         for sponsor in book_info.sponsors:
             ins = etree.Element("data-sponsor", name=sponsor)
             logo = sponsor_logo(sponsor)
         for sponsor in book_info.sponsors:
             ins = etree.Element("data-sponsor", name=sponsor)
             logo = sponsor_logo(sponsor)
index a802e20..29683ea 100644 (file)
@@ -538,3 +538,8 @@ Letters={Uppercase}
 \fi
 }
 
 \fi
 }
 
+\newcommand{\ilustr}[2]{%
+\vspace{1em}%
+\par{\noindent\includegraphics[width=\linewidth]{#1}}%
+\vspace{1em}
+}
index c278981..652a081 100644 (file)
     </cmd>
 </xsl:template>
 
     </cmd>
 </xsl:template>
 
+<xsl:template match="ilustr">
+    <cmd name="ilustr">
+        <parm><xsl:value-of select="@src" /></parm>
+        <parm><xsl:value-of select="@alt" /></parm>
+    </cmd>
+</xsl:template>
 
 <!-- ========================================== -->
 <!-- = PARAGRAPH TAGS                         = -->
 
 <!-- ========================================== -->
 <!-- = PARAGRAPH TAGS                         = -->
index ca7cdbd..c8aa52b 100644 (file)
     <div class="motto"><xsl:apply-templates /></div>
 </xsl:template>
 
     <div class="motto"><xsl:apply-templates /></div>
 </xsl:template>
 
+<xsl:template match="ilustr" mode="inline">
+    <xsl:apply-templates select="."/>
+</xsl:template>
+
+<xsl:template match="ilustr">
+    <img>
+        <xsl:attribute name="src">
+            <xsl:value-of select="@src" />
+        </xsl:attribute>
+        <xsl:attribute name="alt">
+            <xsl:value-of select="@alt" />
+        </xsl:attribute>
+        <xsl:attribute name="title">
+            <xsl:value-of select="@alt" />
+        </xsl:attribute>
+    </img>
+</xsl:template>
+
 
 <!-- ========================================== -->
 <!-- = PARAGRAPH TAGS                         = -->
 
 <!-- ========================================== -->
 <!-- = PARAGRAPH TAGS                         = -->