@ind-rcg/plugins-printengine 250.1002.0 → 250.1004.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -167,7 +167,7 @@ class ContractToIntermediateJSON {
|
|
|
167
167
|
let documentPropertiesRaw = _.find(printLayoutNode.elements, {name:DOCUMENT_PROPERTIES_NODE});
|
|
168
168
|
let documentProperties = this.__reformatDocumentProperties(documentPropertiesRaw);
|
|
169
169
|
|
|
170
|
-
return {"reportLayout": reportLayout, "documentProperties": documentProperties};
|
|
170
|
+
return {"reportLayout": reportLayout, "documentProperties": documentProperties, "printFont": params.getPrintFont() };
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
__processDivs(params) {
|
|
@@ -28,6 +28,12 @@ const BrowserFonts = {
|
|
|
28
28
|
bold: 'Roboto-Medium.ttf',
|
|
29
29
|
italics: 'Roboto-Italic.ttf',
|
|
30
30
|
bolditalics: 'Roboto-MediumItalic.ttf'
|
|
31
|
+
},
|
|
32
|
+
PrintFont: {
|
|
33
|
+
normal: 'Regular',
|
|
34
|
+
bold: 'Bold',
|
|
35
|
+
italics: 'Italic',
|
|
36
|
+
bolditalics: 'BoldItalic'
|
|
31
37
|
}
|
|
32
38
|
};
|
|
33
39
|
|
|
@@ -705,6 +711,17 @@ class PdfConverter {
|
|
|
705
711
|
}
|
|
706
712
|
}
|
|
707
713
|
|
|
714
|
+
__addPrintFont(definition, printFont) {
|
|
715
|
+
if (_.isObject(printFont)
|
|
716
|
+
&& ("Regular" in printFont)
|
|
717
|
+
&& ("Bold" in printFont)
|
|
718
|
+
&& ("Italic" in printFont)
|
|
719
|
+
&& ("BoldItalic" in printFont)) {
|
|
720
|
+
definition.defaultStyle.font = "PrintFont";
|
|
721
|
+
definition.printFont = printFont;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
708
725
|
__addDocumentMetadata(definition, documentProperties){
|
|
709
726
|
definition.info = {};
|
|
710
727
|
definition.info.creator = "Consumer Goods Cloud";
|
|
@@ -926,6 +943,7 @@ class PdfConverter {
|
|
|
926
943
|
|
|
927
944
|
toPdfDefinition(json/*, format*/) {
|
|
928
945
|
this.__initializePdfDefinition();
|
|
946
|
+
this.__addPrintFont(this.__definition, json.printFont);
|
|
929
947
|
this.__addDocumentMetadata(this.__definition, json.documentProperties);
|
|
930
948
|
let reportLayout = json.reportLayout;
|
|
931
949
|
this.__configureAutomaticPageBreak(reportLayout);
|
|
@@ -1030,8 +1048,14 @@ class PdfConverter {
|
|
|
1030
1048
|
if (_.isNil(pdfDefinition) && !_.isNil(previousResult)) {
|
|
1031
1049
|
resolve(previousResult);
|
|
1032
1050
|
} else {
|
|
1033
|
-
let pdfDocGenerator =
|
|
1034
|
-
|
|
1051
|
+
let pdfDocGenerator = null;
|
|
1052
|
+
if (pdfDefinition.defaultStyle.font !== "PrintFont") {
|
|
1053
|
+
pdfDocGenerator = this.__pdfMake.createPdf(pdfDefinition, TableLayouts, BrowserFonts, BrowserFontsVfs.pdfMake.vfs);
|
|
1054
|
+
}
|
|
1055
|
+
else {
|
|
1056
|
+
pdfDocGenerator = this.__pdfMake.createPdf(pdfDefinition, TableLayouts, BrowserFonts, pdfDefinition.printFont);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1035
1059
|
switch (type) {
|
|
1036
1060
|
case EXPORT_TYPE.BASE_64:
|
|
1037
1061
|
pdfDocGenerator.getBase64((data) => {
|
|
@@ -10,7 +10,8 @@ const STORAGE_KEYS = {
|
|
|
10
10
|
"LOCALIZATION": "LOCALIZATION",
|
|
11
11
|
"IMAGES": "IMAGES",
|
|
12
12
|
"TOGGLES":"TOGGLES",
|
|
13
|
-
"METADATA": "METADATA"
|
|
13
|
+
"METADATA": "METADATA",
|
|
14
|
+
"PRINTFONT": "PRINTFONT"
|
|
14
15
|
};
|
|
15
16
|
Object.freeze(STORAGE_KEYS);
|
|
16
17
|
|
|
@@ -24,19 +25,21 @@ const DATATYPE_ERROR_MSG = "Wrong datatype.";
|
|
|
24
25
|
|
|
25
26
|
class PrintEngineParams {
|
|
26
27
|
|
|
27
|
-
constructor(bos = {}, images = {}, localization = {}, toggles = new ClassToggles({}), metadata = {}) {
|
|
28
|
+
constructor(bos = {}, images = {}, localization = {}, toggles = new ClassToggles({}), metadata = {}, printfont = {}) {
|
|
28
29
|
//Optional parameters for constructor via destructuring assignments including call without parameters.
|
|
29
30
|
this.__checkInputSetBOs(bos);
|
|
30
31
|
this.__checkInputSetImages(images);
|
|
31
32
|
this.__checkInputSetLocalization(localization);
|
|
32
33
|
this.__checkInputSetToggles(toggles);
|
|
33
34
|
this.__checkInputSetMetadata(metadata);
|
|
35
|
+
this.__checkInputSetPrintFont(printfont);
|
|
34
36
|
this.__internalStorage = {};
|
|
35
37
|
this.__internalStorage[STORAGE_KEYS.BOS] = bos;
|
|
36
38
|
this.__internalStorage[STORAGE_KEYS.IMAGES] = images;
|
|
37
39
|
this.__internalStorage[STORAGE_KEYS.LOCALIZATION] = localization;
|
|
38
40
|
this.__internalStorage[STORAGE_KEYS.TOGGLES] = toggles;
|
|
39
41
|
this.__internalStorage[STORAGE_KEYS.METADATA] = metadata;
|
|
42
|
+
this.__internalStorage[STORAGE_KEYS.PRINTFONT] = printfont;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
__checkInputSetBOs(boDictionary){
|
|
@@ -69,6 +72,19 @@ class PrintEngineParams {
|
|
|
69
72
|
this.__checkInputSetMetadata(metadataDictionary);
|
|
70
73
|
this.__internalStorage[STORAGE_KEYS.METADATA] = metadataDictionary;
|
|
71
74
|
}
|
|
75
|
+
|
|
76
|
+
getPrintFont(){
|
|
77
|
+
return this.__internalStorage[STORAGE_KEYS.PRINTFONT];
|
|
78
|
+
}
|
|
79
|
+
__checkInputSetPrintFont(printFont){
|
|
80
|
+
if(!_.isObject(printFont)) {
|
|
81
|
+
throw new Error(DATATYPE_ERROR_MSG);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
setPrintFont(printFont) {
|
|
85
|
+
this.__checkInputSetPrintFont(printFont);
|
|
86
|
+
this.__internalStorage[STORAGE_KEYS.PRINTFONT] = printFont;
|
|
87
|
+
}
|
|
72
88
|
|
|
73
89
|
__checkInputSetImages(imageDictionary){
|
|
74
90
|
if(!_.isObject(imageDictionary) || _.isArray(imageDictionary)) {
|