Added new config options to show logos on the right side in motion PDF.

This commit is contained in:
Sean Engelhardt 2018-06-22 14:51:28 +02:00 committed by Emanuel Schütze
parent d9d0c84a1a
commit a6ed54eb92
4 changed files with 100 additions and 24 deletions

View File

@ -13,6 +13,7 @@ Motions:
- New representation of amendments (paragraph based creation, new diff - New representation of amendments (paragraph based creation, new diff
and list views for amendments) [#3637]. and list views for amendments) [#3637].
- New feature to customize workflows and states [#3772]. - New feature to customize workflows and states [#3772].
- New config options to show logos on the right side in PDF [#3768].
Version 2.2 (2018-06-06) Version 2.2 (2018-06-06)

View File

@ -256,8 +256,10 @@ def get_config_variables():
'logo_projector_main', 'logo_projector_main',
'logo_projector_header', 'logo_projector_header',
'logo_web_header', 'logo_web_header',
'logo_pdf_header', 'logo_pdf_header_L',
'logo_pdf_footer', 'logo_pdf_header_R',
'logo_pdf_footer_L',
'logo_pdf_footer_R',
'logo_pdf_ballot_paper'], 'logo_pdf_ballot_paper'],
weight=300, weight=300,
group='Logo', group='Logo',
@ -295,9 +297,9 @@ def get_config_variables():
# PDF logos # PDF logos
yield ConfigVariable( yield ConfigVariable(
name='logo_pdf_header', name='logo_pdf_header_L',
default_value={ default_value={
'display_name': 'PDF header logo', 'display_name': 'PDF header logo (Left)',
'path': ''}, 'path': ''},
input_type='static', input_type='static',
weight=310, weight=310,
@ -305,22 +307,42 @@ def get_config_variables():
hidden=True) hidden=True)
yield ConfigVariable( yield ConfigVariable(
name='logo_pdf_footer', name='logo_pdf_header_R',
default_value={ default_value={
'display_name': 'PDF footer logo', 'display_name': 'PDF header logo (Right)',
'path': ''}, 'path': ''},
input_type='static', input_type='static',
weight=311, weight=311,
group='Logo', group='Logo',
hidden=True) hidden=True)
yield ConfigVariable(
name='logo_pdf_footer_L',
default_value={
'display_name': 'PDF footer logo (Left)',
'path': ''},
input_type='static',
weight=312,
group='Logo',
hidden=True)
yield ConfigVariable(
name='logo_pdf_footer_R',
default_value={
'display_name': 'PDF footer logo (Right)',
'path': ''},
input_type='static',
weight=313,
group='Logo',
hidden=True)
yield ConfigVariable( yield ConfigVariable(
name='logo_pdf_ballot_paper', name='logo_pdf_ballot_paper',
default_value={ default_value={
'display_name': 'PDF ballot paper logo', 'display_name': 'PDF ballot paper logo',
'path': ''}, 'path': ''},
input_type='static', input_type='static',
weight=312, weight=314,
group='Logo', group='Logo',
hidden=True) hidden=True)

View File

@ -176,20 +176,22 @@ angular.module('OpenSlidesApp.core.pdf', [])
//images shall contain the the logos as URL: base64Str, just like the converter //images shall contain the the logos as URL: base64Str, just like the converter
var createInstance = function(contentProvider, noFooter) { var createInstance = function(contentProvider, noFooter) {
// Logo urls // Logo urls
var logoHeaderUrl = Config.get('logo_pdf_header').value.path, var logoHeaderLeftUrl = Config.get('logo_pdf_header_L').value.path,
logoFooterUrl = Config.get('logo_pdf_footer').value.path; logoHeaderRightUrl = Config.get('logo_pdf_header_R').value.path,
logoFooterLeftUrl = Config.get('logo_pdf_footer_L').value.path,
logoFooterRightUrl = Config.get('logo_pdf_footer_R').value.path;
var imageMap = contentProvider.getImageMap ? contentProvider.getImageMap() : {}; var imageMap = contentProvider.getImageMap ? contentProvider.getImageMap() : {};
// PDF header // PDF header
var getHeader = function() { var getHeader = function() {
var columns = []; var columns = [];
if (logoHeaderUrl) { if (logoHeaderLeftUrl) {
if (logoHeaderUrl.indexOf('/') === 0) { if (logoHeaderLeftUrl.indexOf('/') === 0) {
logoHeaderUrl = logoHeaderUrl.substr(1); // remove trailing / logoHeaderLeftUrl = logoHeaderLeftUrl.substr(1); // remove trailing /
} }
columns.push({ columns.push({
image: logoHeaderUrl, image: logoHeaderLeftUrl,
fit: [180, 40], fit: [180, 40],
width: '20%' width: '20%'
}); });
@ -207,9 +209,21 @@ angular.module('OpenSlidesApp.core.pdf', [])
columns.push({ columns.push({
text: text, text: text,
fontSize: 10, fontSize: 10,
alignment: 'right', alignment: logoHeaderRightUrl ? 'left' : 'right',
margin: [0, 10, 0, 0], margin: [0, 10, 0, 0],
}); });
if (logoHeaderRightUrl) {
if (logoHeaderRightUrl.indexOf('/') === 0) {
logoHeaderRightUrl = logoHeaderRightUrl.substr(1); // remove trailing /
}
columns.push({
image: logoHeaderRightUrl,
fit: [180, 40],
width: '20%'
});
}
return { return {
color: '#555', color: '#555',
fontSize: 9, fontSize: 9,
@ -226,23 +240,59 @@ angular.module('OpenSlidesApp.core.pdf', [])
var getFooter = function() { var getFooter = function() {
var columns = []; var columns = [];
if (logoFooterUrl) { // if there is a single logo, give it a lot of space
if (logoFooterUrl.indexOf('/') === 0) { var logoContainerWidth;
logoFooterUrl = logoFooterUrl.substr(1); // remove trailing / var logoConteinerSize;
if (logoFooterLeftUrl && logoFooterRightUrl) {
logoContainerWidth = '20%';
logoConteinerSize = [180, 40];
} else {
logoContainerWidth = '80%';
logoConteinerSize = [400, 50];
}
// the position of the page number depends on the logos
var pageNumberPosition;
if (logoFooterLeftUrl && logoFooterRightUrl) {
pageNumberPosition = 'center';
} else if (logoFooterLeftUrl && (!logoFooterRightUrl)) {
pageNumberPosition = 'right';
} else if (logoFooterRightUrl && (!logoFooterLeftUrl)) {
pageNumberPosition = 'left';
} else {
pageNumberPosition = Config.get('general_export_pdf_pagenumber_alignment').value;
}
if (logoFooterLeftUrl) {
if (logoFooterLeftUrl.indexOf('/') === 0) {
logoFooterLeftUrl = logoFooterLeftUrl.substr(1); // remove trailing /
} }
columns.push({ columns.push({
image: logoFooterUrl, image: logoFooterLeftUrl,
fit: [400,50], fit: logoConteinerSize,
width: '80%' width: logoContainerWidth,
alignment: 'left',
}); });
} }
columns.push({ columns.push({
text: '{{currentPage}} / {{pageCount}}', text: '{{currentPage}} / {{pageCount}}',
color: '#555', color: '#555',
fontSize: 9, fontSize: 9,
alignment: Config.get('general_export_pdf_pagenumber_alignment').value, alignment: pageNumberPosition,
margin: [0, 15, 0, 0], margin: [0, 15, 0, 0],
}); });
if (logoFooterRightUrl) {
if (logoFooterRightUrl.indexOf('/') === 0) {
logoFooterRightUrl = logoFooterRightUrl.substr(1); // remove trailing /
}
columns.push({
image: logoFooterRightUrl,
fit: logoConteinerSize,
width: logoContainerWidth,
alignment: 'right',
});
}
return { return {
margin: [75, 0, 75, 10], margin: [75, 0, 75, 10],
columns: columns, columns: columns,
@ -358,8 +408,10 @@ angular.module('OpenSlidesApp.core.pdf', [])
return $q(function (resolve, reject) { return $q(function (resolve, reject) {
var imageSources = [ var imageSources = [
logoHeaderUrl, logoHeaderLeftUrl,
logoFooterUrl logoHeaderRightUrl,
logoFooterLeftUrl,
logoFooterRightUrl,
]; ];
ImageConverter.toBase64(imageSources).then(function (_imageMap) { ImageConverter.toBase64(imageSources).then(function (_imageMap) {
_.forEach(_imageMap, function (data, path) { _.forEach(_imageMap, function (data, path) {

View File

@ -2119,7 +2119,8 @@ angular.module('OpenSlidesApp.core.site', [
gettext('List of speakers overlay'); gettext('List of speakers overlay');
gettext('Projector logo'); gettext('Projector logo');
gettext('Projector header image'); gettext('Projector header image');
gettext('PDF header logo'); gettext('PDF header logo (Left)');
gettext('PDF header logo (Right)');
gettext('PDF footer logo'); gettext('PDF footer logo');
gettext('Web interface header logo'); gettext('Web interface header logo');
gettext('PDF ballot paper logo'); gettext('PDF ballot paper logo');