From 9639d9233fc489f288d677fbec074e1d24d41795 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Mon, 12 Mar 2018 14:00:23 +0100 Subject: [PATCH] Pdf fixes --- openslides/agenda/static/js/agenda/pdf.js | 2 +- .../assignments/static/js/assignments/pdf.js | 17 +++++++++++------ openslides/core/static/js/core/pdf.js | 6 +++--- openslides/users/static/js/users/pdf.js | 8 ++++---- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/openslides/agenda/static/js/agenda/pdf.js b/openslides/agenda/static/js/agenda/pdf.js index 28e957cef..4233c3e80 100644 --- a/openslides/agenda/static/js/agenda/pdf.js +++ b/openslides/agenda/static/js/agenda/pdf.js @@ -88,7 +88,7 @@ angular.module('OpenSlidesApp.agenda.pdf', ['OpenSlidesApp.core.pdf']) var filename = gettextCatalog.getString('Agenda') + '.pdf'; var agendaContentProvider = AgendaContentProvider.createInstance(items); PdfMakeDocumentProvider.createInstance(agendaContentProvider).then(function (documentProvider) { - PdfCreate.download(documentProvider.getDocument(), filename); + PdfCreate.download(documentProvider, filename); }); }, }; diff --git a/openslides/assignments/static/js/assignments/pdf.js b/openslides/assignments/static/js/assignments/pdf.js index 5a9845769..234e13174 100644 --- a/openslides/assignments/static/js/assignments/pdf.js +++ b/openslides/assignments/static/js/assignments/pdf.js @@ -286,7 +286,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) // logo if (logoBallotPaperUrl) { columns.push({ - image: imageMap[logoBallotPaperUrl].data, + image: logoBallotPaperUrl, fit: [90,20], width: '20%' }); @@ -506,6 +506,10 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) return createContentTable(); }; + var getImageMap = function () { + return imageMap; + }; + return $q(function (resolve) { var imageSources = [ logoBallotPaperUrl, @@ -513,7 +517,8 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) ImageConverter.toBase64(imageSources).then(function (_imageMap) { imageMap = _imageMap; resolve({ - getContent: getContent + getContent: getContent, + getImageMap: getImageMap, }); }); }); @@ -531,7 +536,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) 'Config', function(gettextCatalog, PDFLayout, Config) { - var createInstance = function(allAssignmnets) { + var createInstance = function(allAssignments) { var title = PDFLayout.createTitle( Config.translate(Config.get('assignments_pdf_title').value) @@ -575,10 +580,10 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) var assignmentContent = []; var assignmentTitles = []; - angular.forEach(allAssignmnets, function(assignment, key) { + _.forEach(allAssignments, function(assignment, key) { assignmentTitles.push(assignment.title); assignmentContent.push(assignment.getContent()); - if (key < allAssignmnets.length - 1) { + if (key < allAssignments.length - 1) { assignmentContent.push(PDFLayout.addPageBreak()); } }); @@ -638,7 +643,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) PdfMakeDocumentProvider.createInstance(assignmentCatalogContentProvider); } documentProviderPromise.then(function (documentProvider) { - PdfCreate.download(documentProvider.getDocument(), filename); + PdfCreate.download(documentProvider, filename); }); }, createBallotPdf: function (assignment, pollId) { diff --git a/openslides/core/static/js/core/pdf.js b/openslides/core/static/js/core/pdf.js index 40492045b..149b3a94a 100644 --- a/openslides/core/static/js/core/pdf.js +++ b/openslides/core/static/js/core/pdf.js @@ -166,11 +166,11 @@ angular.module('OpenSlidesApp.core.pdf', []) * returns an array for content */ //images shall contain the the logos as URL: base64Str, just like the converter - var createInstance = function(contentProvider) { + var createInstance = function(contentProvider, noFooter) { // Logo urls var logoHeaderUrl = Config.get('logo_pdf_header').value.path, logoFooterUrl = Config.get('logo_pdf_footer').value.path; - var imageMap = contentProvider.getImageMap(); + var imageMap = contentProvider.getImageMap ? contentProvider.getImageMap() : {}; // PDF header var getHeader = function() { @@ -242,7 +242,7 @@ angular.module('OpenSlidesApp.core.pdf', []) }; }; // Generates the document(definition) for pdfMake - var getDocument = function(noFooter) { + var getDocument = function() { var content = contentProvider.getContent(); var standardFontsize = Config.get('general_export_pdf_fontsize').value; return { diff --git a/openslides/users/static/js/users/pdf.js b/openslides/users/static/js/users/pdf.js index dc607d2f7..d1c77f618 100644 --- a/openslides/users/static/js/users/pdf.js +++ b/openslides/users/static/js/users/pdf.js @@ -301,7 +301,7 @@ angular.module('OpenSlidesApp.users.pdf', ['OpenSlidesApp.core.pdf']) var userListContentProvider = UserListContentProvider.createInstance(users); PdfMakeDocumentProvider.createInstance(userListContentProvider).then( function (documentProvider) { - PdfCreate.download(documentProvider.getDocument(), filename); + PdfCreate.download(documentProvider, filename); } ); }, @@ -309,10 +309,10 @@ angular.module('OpenSlidesApp.users.pdf', ['OpenSlidesApp.core.pdf']) var filename = gettextCatalog.getString('List of access data') + '.pdf'; var userAccessDataListContentProvider = UserAccessDataListContentProvider.createInstance( users); - PdfMakeDocumentProvider.createInstance(userAccessDataListContentProvider).then( + // no footer here + PdfMakeDocumentProvider.createInstance(userAccessDataListContentProvider, true).then( function (documentProvider) { - var noFooter = true; - PdfCreate.download(documentProvider.getDocument(noFooter), filename); + PdfCreate.download(documentProvider, filename, true); } ); }