X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/b6ec0976a383cc1823f4a199bc3e6dc40880b049..5c55be51e46b296d368b86375f2f4b90ea46c00b:/librarian/pdf.py diff --git a/librarian/pdf.py b/librarian/pdf.py index 02438a6..7bba9d2 100644 --- a/librarian/pdf.py +++ b/librarian/pdf.py @@ -21,6 +21,7 @@ from librarian.dcparser import Person from librarian.parser import WLDocument from librarian import ParseError, DCNS, get_resource, OutputFile from librarian import functions +from librarian.cover import WLCover functions.reg_substitute_entities() @@ -33,13 +34,14 @@ STYLESHEETS = { 'wl2tex': 'pdf/wl2tex.xslt', } -CUSTOMIZATIONS = [ - 'nofootnotes', - 'nothemes', - 'onehalfleading', - 'doubleleading', - 'nowlfont', - ] +#CUSTOMIZATIONS = [ +# 'nofootnotes', +# 'nothemes', +# 'defaultleading', +# 'onehalfleading', +# 'doubleleading', +# 'nowlfont', +# ] def insert_tags(doc, split_re, tagname, exclude=None): """ inserts for every occurence of `split_re' in text nodes in the `doc' tree @@ -179,7 +181,7 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None, verbose: prints all output from LaTeX save_tex: path to save the intermediary LaTeX file to morefloats (old/new/none): force specific morefloats - cover: a cover.Cover object + cover: a cover.Cover factory or True for default flags: less-advertising, customizations: user requested customizations regarding various formatting parameters (passed to wl LaTeX class) """ @@ -189,8 +191,16 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None, document = load_including_children(wldoc) if cover: - document.edoc.getroot().set('data-cover-width', str(cover.width)) - document.edoc.getroot().set('data-cover-height', str(cover.height)) + if cover is True: + cover = WLCover + bound_cover = cover(document.book_info) + document.edoc.getroot().set('data-cover-width', str(bound_cover.width)) + document.edoc.getroot().set('data-cover-height', str(bound_cover.height)) + if bound_cover.uses_dc_cover: + if document.book_info.cover_by: + document.edoc.getroot().set('data-cover-by', document.book_info.cover_by) + if document.book_info.cover_source: + document.edoc.getroot().set('data-cover-source', document.book_info.cover_source) if flags: for flag in flags: document.edoc.getroot().set('flag-' + flag, 'yes') @@ -222,9 +232,8 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None, temp = mkdtemp('-wl2pdf') if cover: - c = cover(document.book_info.author.readable(), document.book_info.title) with open(os.path.join(temp, 'cover.png'), 'w') as f: - c.save(f) + bound_cover.save(f) del document # no longer needed large object :)