X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/b6ec0976a383cc1823f4a199bc3e6dc40880b049..941b8e6effd4c0ffff52fa7e548d866f8454dddb:/librarian/pdf.py diff --git a/librarian/pdf.py b/librarian/pdf.py index 02438a6..ace83af 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() @@ -179,18 +180,26 @@ 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 - flags: less-advertising, + cover: a cover.Cover object or True for default + flags: less-advertising, not-wl, images customizations: user requested customizations regarding various formatting parameters (passed to wl LaTeX class) """ + # TODO: images # Parse XSLT try: - document = load_including_children(wldoc) + document = load_including_children(wldoc) if cover: + if cover is True: + cover = WLCover document.edoc.getroot().set('data-cover-width', str(cover.width)) document.edoc.getroot().set('data-cover-height', str(cover.height)) + if 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,10 +231,13 @@ 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) + c = cover(document.book_info) with open(os.path.join(temp, 'cover.png'), 'w') as f: c.save(f) + for img in document.edoc.findall('//ilustr'): + shutil.copy(img.get('src'), temp) + del document # no longer needed large object :) tex_path = os.path.join(temp, 'doc.tex') @@ -241,6 +253,10 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None, shutil.copy(get_resource('pdf/wl.cls'), temp) shutil.copy(get_resource('res/wl-logo.png'), temp) + # FIXME: temporary + shutil.copy(get_resource('res/ofop-logo.png'), temp) + shutil.copy(get_resource('res/logo-fio.jpg'), temp) + cwd = os.getcwd() os.chdir(temp)