Skip to content

Commit

Permalink
Page Size and Height Width Option Added.
Browse files Browse the repository at this point in the history
Page size (letter, legal, A4) and width, height option added
var converted = htmlDocx.asBlob(content, {orientation: orientation, size:'legal'});
or
var converted = htmlDocx.asBlob(content, {orientation: orientation, width:12240, height:15840});
  • Loading branch information
thatal authored Jul 26, 2018
1 parent d785735 commit aef35e0
Showing 1 changed file with 45 additions and 7 deletions.
52 changes: 45 additions & 7 deletions dist/html-docx.js
Original file line number Diff line number Diff line change
Expand Up @@ -13057,6 +13057,41 @@ module.exports = {
if (documentOptions == null) {
documentOptions = {};
}
var pageSizes = ['legal','letter','A4'];
var pageWidth = 12240;
var pageHeight = 15840;
if(documentOptions.height){
pageHeight = documentOptions.height;
}
if(documentOptions.width){
pageWidth = documentOptions.width;
}
if(!documentOptions.height && !documentOptions.height){
if(documentOptions.size){
var a = pageSizes.indexOf(documentOptions.size);
console.log(a);
if(a === -1){
throw new Error("Size should be "+pageSizes.toString());
}
}else{
documentOptions.size = 'letter';
}

switch(documentOptions.size){
case 'legal':
pageHeight = 20160;
pageWidth = 12240;
break;
case 'A4':
pageHeight = 16837.795;
pageWidth = 11905.511;
break;
default:
pageHeight = 15840;
pageWidth = 12240;
}
}

templateData = _.merge({
margins: {
top: 1440,
Expand All @@ -13068,18 +13103,21 @@ module.exports = {
gutter: 0
}
}, (function() {

switch (documentOptions.orientation) {
case 'landscape':
return {
height: 12240,
width: 15840,
orient: 'landscape'
// height: 12240,
// width: 15840,
width : pageHeight,
height : pageWidth,
orient : 'landscape'
};
default:
return {
width: 12240,
height: 15840,
orient: 'portrait'
width : pageWidth,
height : pageHeight,
orient : 'portrait'
};
}
})(), {
Expand Down Expand Up @@ -13213,4 +13251,4 @@ module.exports = {

},{"./templates/mht_document":67,"./templates/mht_part":68}]},{},[64])
(64)
});
});

0 comments on commit aef35e0

Please sign in to comment.