mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 05:32:41 +00:00
Merge branch 'pdf'
This commit is contained in:
@@ -1,393 +0,0 @@
|
|||||||
|
|
||||||
.pbhPages{
|
|
||||||
background-color: @steel;
|
|
||||||
padding : 30px 0px;
|
|
||||||
&>.phb{
|
|
||||||
box-shadow : 1px 4px 14px #000;
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family : BookInsanity;
|
|
||||||
src : url('/assets/homebrew/assets/Bookinsanity.otf');
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family : BookInsanityBold;
|
|
||||||
src : url('/assets/homebrew/assets/Bookinsanity Bold.otf');
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family : BookInsanityItalic;
|
|
||||||
src : url('/assets/homebrew/assets/Bookinsanity Italic.otf');
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family : BookInsanityBoldItalic;
|
|
||||||
src : url('/assets/homebrew/assets/Bookinsanity Bold Italic.otf');
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family : ScalaSans;
|
|
||||||
src : url('/assets/homebrew/assets/Scaly Sans.otf');
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
@font-face {
|
|
||||||
font-family : ScalaSansBold;
|
|
||||||
src : url('/assets/homebrew/assets/Scala Sans Bold.ttf');
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@font-face {
|
|
||||||
font-family : ScalaSansSmallCaps;
|
|
||||||
src : url('/assets/homebrew/assets/Scala Sans SmallCaps.ttf');
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family : Solbera;
|
|
||||||
src : url('/assets/homebrew/assets/Solbera Imitation.otf');
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family : MrEaves;
|
|
||||||
src : url('/assets/homebrew/assets/MrsEavesSmallCaps_Regular.ttf') format('truetype'),
|
|
||||||
url('/assets/homebrew/assets/Mr Eaves Small Caps.otf') format('otf');
|
|
||||||
}
|
|
||||||
.phb{
|
|
||||||
@background : #f2ece4;
|
|
||||||
@green : #e0e5c1;
|
|
||||||
@headerUnderline : #c9ad6a;
|
|
||||||
@horizontalRule : #9c2b1b;
|
|
||||||
@header : #58180D;
|
|
||||||
box-sizing : border-box;
|
|
||||||
height : 27.5cm;
|
|
||||||
width : 21cm;
|
|
||||||
padding : 1.0cm 1.7cm;
|
|
||||||
column-count : 2;
|
|
||||||
column-fill : auto;
|
|
||||||
column-gap : 1cm;
|
|
||||||
column-width : 8cm;
|
|
||||||
background-color: #EEE5CE;
|
|
||||||
background-image : url('/assets/homebrew/assets/PHB-background.png');
|
|
||||||
-webkit-column-count : 2;
|
|
||||||
-moz-column-count : 2;
|
|
||||||
-webkit-column-width : 8cm;
|
|
||||||
-moz-column-width : 8cm;
|
|
||||||
-webkit-column-gap : 1cm;
|
|
||||||
text-rendering : optimizeLegibility;
|
|
||||||
position : relative;
|
|
||||||
overflow: hidden;
|
|
||||||
z-index : 15;
|
|
||||||
|
|
||||||
|
|
||||||
img{
|
|
||||||
z-index : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Page Accents
|
|
||||||
&:after{
|
|
||||||
content : "";
|
|
||||||
position: absolute;
|
|
||||||
height: 50px;
|
|
||||||
width: 100%;
|
|
||||||
bottom : 0px;
|
|
||||||
left: 0px;
|
|
||||||
background-size: cover;
|
|
||||||
width : 100%;
|
|
||||||
background-image : url('/assets/homebrew/assets/accent.png');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Avoid breaking up
|
|
||||||
p,ul,blockquote,table{
|
|
||||||
-webkit-column-break-inside : avoid;
|
|
||||||
-moz-column-break-inside : avoid;
|
|
||||||
-o-column-break-inside : avoid;
|
|
||||||
-ms-column-break-inside : avoid;
|
|
||||||
column-break-inside : avoid;
|
|
||||||
z-index : 15;
|
|
||||||
}
|
|
||||||
|
|
||||||
p,ul{
|
|
||||||
strong{
|
|
||||||
font-family : BookInsanityBold;
|
|
||||||
em{
|
|
||||||
font-family : BookInsanityBoldItalic;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
em{
|
|
||||||
font-family : BookInsanityItalic;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
padding-bottom : 0.8em;
|
|
||||||
font-family : BookInsanity;
|
|
||||||
font-size : 9pt;
|
|
||||||
line-height : 1.3em;
|
|
||||||
&+p{
|
|
||||||
margin-top : -0.8em;
|
|
||||||
text-indent : 1em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ul{
|
|
||||||
margin-bottom : 0.8em;
|
|
||||||
font-family : BookInsanity;
|
|
||||||
font-size : 9pt;
|
|
||||||
line-height : 1.3em;
|
|
||||||
list-style-position : inside;
|
|
||||||
list-style-type : disc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Full Spell casting table
|
|
||||||
h5+hr+table{
|
|
||||||
-webkit-column-span : all;
|
|
||||||
column-span : all;
|
|
||||||
background-color: white;
|
|
||||||
border-image-source: url('/assets/homebrew/assets/frame_border.png');
|
|
||||||
border-image-slice: 150 200 150 200;
|
|
||||||
border-image-width: 47px;
|
|
||||||
border-image-outset: 37px 17px;
|
|
||||||
border-image-repeat: round;
|
|
||||||
margin-bottom: 50px;
|
|
||||||
border-collapse: separate;
|
|
||||||
border: initial;
|
|
||||||
padding-top: 10px;
|
|
||||||
margin-top: -5px;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
table{
|
|
||||||
width : 100%;
|
|
||||||
margin-bottom : 1em;
|
|
||||||
font-family : ScalaSans;
|
|
||||||
font-size : 10pt;
|
|
||||||
em{
|
|
||||||
font-family : ScalaSans;
|
|
||||||
font-style : italic;
|
|
||||||
}
|
|
||||||
strong{
|
|
||||||
font-weight : 800;
|
|
||||||
font-family : ScalaSans;
|
|
||||||
em{
|
|
||||||
font-style : italic;
|
|
||||||
font-weight : 800;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
thead{
|
|
||||||
font-weight : 800;
|
|
||||||
th{
|
|
||||||
padding-bottom : 0.3em;
|
|
||||||
padding-right: 0.1em;
|
|
||||||
padding-left: 0.1em;
|
|
||||||
vertical-align: bottom;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tbody{
|
|
||||||
tr{
|
|
||||||
td{
|
|
||||||
padding : 0.2em 0em;
|
|
||||||
}
|
|
||||||
&:nth-child(odd){
|
|
||||||
background-color : @green;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hr{
|
|
||||||
visibility: hidden;
|
|
||||||
//border : none;
|
|
||||||
margin: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Fancy List of things
|
|
||||||
hr+ul{
|
|
||||||
list-style-type: none;
|
|
||||||
text-indent: -1em;
|
|
||||||
padding-left: 1em;
|
|
||||||
|
|
||||||
//margin-top: -0.5em;
|
|
||||||
margin-bottom: 0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Column Break
|
|
||||||
pre{
|
|
||||||
visibility: hidden;
|
|
||||||
-webkit-column-break-after: always;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Monster Stat block
|
|
||||||
hr+blockquote{
|
|
||||||
position : relative;
|
|
||||||
background-color: #FDF1DC;
|
|
||||||
border : none;
|
|
||||||
|
|
||||||
h2{
|
|
||||||
margin-bottom: 0px;
|
|
||||||
&+p{
|
|
||||||
padding-bottom: 0px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
h3{
|
|
||||||
font-family: ScalaSans;
|
|
||||||
font-weight: 400;
|
|
||||||
border-bottom: 1px solid @header;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul{
|
|
||||||
list-style-type: none;
|
|
||||||
font-family: ScalaSans;
|
|
||||||
color : @header;
|
|
||||||
font-size: 10pt;
|
|
||||||
text-indent: -1em;
|
|
||||||
padding-left: 1em;
|
|
||||||
strong{
|
|
||||||
font-family: ScalaSans;
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Monster Ability table
|
|
||||||
hr+table{
|
|
||||||
-webkit-column-span : 1;
|
|
||||||
column-span : 1;
|
|
||||||
background-color: transparent;
|
|
||||||
border-image: none;
|
|
||||||
margin: 0;
|
|
||||||
thead{
|
|
||||||
tr{
|
|
||||||
//background-color: transparent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tbody{
|
|
||||||
tr:nth-child(odd), tr:nth-child(even){
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
table{
|
|
||||||
color : @header;
|
|
||||||
}
|
|
||||||
|
|
||||||
p+p{
|
|
||||||
margin-top : 0em;
|
|
||||||
text-indent : 0em;
|
|
||||||
padding-bottom: 0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Maybe move this to be built in
|
|
||||||
hr{
|
|
||||||
visibility: visible;
|
|
||||||
margin: 8px 0px;
|
|
||||||
|
|
||||||
border-color : transparent;
|
|
||||||
position: relative;
|
|
||||||
@height : 3px;
|
|
||||||
&:after, &:before{
|
|
||||||
content : "";
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: @height;
|
|
||||||
left: 0px;
|
|
||||||
}
|
|
||||||
&:before{
|
|
||||||
top : -@height;
|
|
||||||
background: linear-gradient(to right top, @horizontalRule 40%, transparent 50%)
|
|
||||||
}
|
|
||||||
&:after{
|
|
||||||
top: 0px;
|
|
||||||
background: linear-gradient(to right bottom, @horizontalRule 40%, transparent 50%)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Borders
|
|
||||||
&:after, &:before{
|
|
||||||
content : "";
|
|
||||||
position: absolute;
|
|
||||||
background-color : #E69A28;
|
|
||||||
border: 1px solid black;
|
|
||||||
height : 4px;
|
|
||||||
width : 100%;
|
|
||||||
padding : 0px 3px;
|
|
||||||
}
|
|
||||||
&:before{
|
|
||||||
top : 0px;
|
|
||||||
left : -3px;
|
|
||||||
}
|
|
||||||
&:after{
|
|
||||||
bottom : 0px;
|
|
||||||
left : -3px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Note
|
|
||||||
blockquote{
|
|
||||||
box-sizing : border-box;
|
|
||||||
margin-bottom : 1em;
|
|
||||||
padding : 5px 10px;
|
|
||||||
background-color : @green;
|
|
||||||
font-family : ScalaSans;
|
|
||||||
border-top : 2px black solid;
|
|
||||||
border-bottom : 2px black solid;
|
|
||||||
box-shadow : 1px 4px 14px #888;
|
|
||||||
|
|
||||||
p, ul{
|
|
||||||
font-family : ScalaSans;
|
|
||||||
font-size : 10pt;
|
|
||||||
line-height : 1.1em;
|
|
||||||
em{
|
|
||||||
font-family : ScalaSans;
|
|
||||||
font-style : italic;
|
|
||||||
}
|
|
||||||
strong{
|
|
||||||
font-weight : 800;
|
|
||||||
font-family : ScalaSans;
|
|
||||||
em{
|
|
||||||
font-style : italic;
|
|
||||||
font-weight : 800;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pre{
|
|
||||||
}
|
|
||||||
h1,h2,h3,h4{
|
|
||||||
margin-top : 0.2em;
|
|
||||||
margin-bottom : 0.2em;
|
|
||||||
font-family : MrEaves;
|
|
||||||
font-weight : 800;
|
|
||||||
color : @header;
|
|
||||||
}
|
|
||||||
h1{
|
|
||||||
column-span : all;
|
|
||||||
font-size : 28pt;
|
|
||||||
-webkit-column-span : all;
|
|
||||||
&+p{
|
|
||||||
&::first-letter{
|
|
||||||
float: left;
|
|
||||||
margin-top: 0.4em;
|
|
||||||
margin-bottom: 0.4em;
|
|
||||||
font-family: Solbera;
|
|
||||||
font-size: 10em;
|
|
||||||
color : #222;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
h2{
|
|
||||||
font-size : 20pt;
|
|
||||||
}
|
|
||||||
h3{
|
|
||||||
font-size : 15pt;
|
|
||||||
border-bottom : 2px solid @headerUnderline;
|
|
||||||
}
|
|
||||||
h4{
|
|
||||||
margin-bottom : 0.00em;
|
|
||||||
font-size : 12pt;
|
|
||||||
}
|
|
||||||
h5{
|
|
||||||
margin-bottom : 0.2em;
|
|
||||||
font-family : ScalaSansSmallCaps;
|
|
||||||
font-size : 13pt;
|
|
||||||
font-weight : 900;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
"classnames": "^2.2.0",
|
"classnames": "^2.2.0",
|
||||||
"express": "^4.13.3",
|
"express": "^4.13.3",
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.0",
|
||||||
|
"html-pdf": "^1.4.0",
|
||||||
"jsoneditor": "^4.2.1",
|
"jsoneditor": "^4.2.1",
|
||||||
"lodash": "^3.10.1",
|
"lodash": "^3.10.1",
|
||||||
"marked": "^0.3.5",
|
"marked": "^0.3.5",
|
||||||
|
|||||||
@@ -122,6 +122,45 @@ module.exports = function(app){
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//PDF download
|
||||||
|
/*
|
||||||
|
var pdf = require('html-pdf');
|
||||||
|
app.get('/homebrew/pdf/:id', function(req, res){
|
||||||
|
HomebrewModel.find({shareId : req.params.id}, function(err, objs){
|
||||||
|
if(err) return res.status(404).send();
|
||||||
|
|
||||||
|
var resObj = null;
|
||||||
|
var errObj = {text: "# oops\nCould not find the homebrew."}
|
||||||
|
if(objs.length){
|
||||||
|
resObj = objs[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
var content = _.map(resObj.text.split('\\page'), function(pageText){
|
||||||
|
return '<div class="phb">' + Markdown(pageText) + '</div>';
|
||||||
|
}).join('\n');
|
||||||
|
|
||||||
|
var title = '<title>' + resObj.text.split('\n')[0] + '</title>';
|
||||||
|
var page = '<html><head>' + title + PHBStyle + '</head><body>' + content +'</body></html>'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
"height": (279.4 - 56) + "mm",
|
||||||
|
"width": (215.9 - 43) + "mm",
|
||||||
|
"border": "0",
|
||||||
|
}
|
||||||
|
|
||||||
|
pdf.create(page, config).toStream(function(err, stream){
|
||||||
|
|
||||||
|
res.attachment('pdfname.pdf');
|
||||||
|
return stream.pipe(res);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
31
server/pdfConvert.js
Normal file
31
server/pdfConvert.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
var pdf = require('html-pdf');
|
||||||
|
var Markdown = require('marked');
|
||||||
|
|
||||||
|
var PHBStyle = '<style>' + require('fs').readFileSync('../phb.standalone.css', 'utf8') + '</style>'
|
||||||
|
|
||||||
|
|
||||||
|
var content = Markdown('# oh hey \n welcome! isnt this neat \n \\page ##### test');
|
||||||
|
|
||||||
|
|
||||||
|
var html = "<html><head>" + PHBStyle + "</head><body><div class='phb'>"+ content +"</div></body></html>"
|
||||||
|
|
||||||
|
//var h = 279.4 - 20*2.8;
|
||||||
|
var h = 279.4 - 56;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//var w = 215.9 - 56*1.7
|
||||||
|
|
||||||
|
var w = 215.9 - 43;
|
||||||
|
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
"height": (279.4 - 56) + "mm",
|
||||||
|
"width": (215.9 - 43) + "mm",
|
||||||
|
"border": "0",
|
||||||
|
}
|
||||||
|
|
||||||
|
pdf.create(html, config).toFile('./temp.pdf', function(err, res){
|
||||||
|
console.log(err);
|
||||||
|
console.log(res.filename);
|
||||||
|
});
|
||||||
BIN
server/pdfs/businesscard.pdf
Normal file
BIN
server/pdfs/businesscard.pdf
Normal file
Binary file not shown.
BIN
server/temp.pdf
Normal file
BIN
server/temp.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user