X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/12b5230d8fdb3ad995e867fb5d58a69e8a627e68..0fd34bb9e21323f850cbf8dd2f82ce100ba595d2:/librarian/pdf.py?ds=sidebyside diff --git a/librarian/pdf.py b/librarian/pdf.py index c899afa..c8af03b 100644 --- a/librarian/pdf.py +++ b/librarian/pdf.py @@ -199,7 +199,7 @@ def package_available(package, args='', verbose=False): 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 @@ -268,6 +268,9 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None, # 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) @@ -307,12 +310,14 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None, cwd = None os.chdir(temp) - if verbose: - p = call(['xelatex', tex_path]) - else: - p = call(['xelatex', '-interaction=batchmode', tex_path], stdout=PIPE, stderr=PIPE) - if p: - raise ParseError("Error parsing .tex file") + # some things work better when compiled twice + for run in xrange(2): + if verbose: + p = call(['xelatex', tex_path]) + else: + p = call(['xelatex', '-interaction=batchmode', tex_path], stdout=PIPE, stderr=PIPE) + if p: + raise ParseError("Error parsing .tex file") if cwd is not None: os.chdir(cwd)