Skip to content

Commit

Permalink
Merge pull request #182 from phairow/master
Browse files Browse the repository at this point in the history
Update phantomscript.js
  • Loading branch information
knsv committed Jul 3, 2015
2 parents 6f96b5d + 590fa08 commit a85a694
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/phantomscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ function executeInPage(data) {
, elContent
, svg
, svgValue
, boundingBox
, width
, height

toRemove = document.getElementsByClassName('mermaid')
if (toRemove && toRemove.length) {
Expand Down Expand Up @@ -254,6 +257,32 @@ function executeInPage(data) {
mermaid.init();

svg = document.querySelector('svg')

boundingBox = svg.getBoundingClientRect(); // the initial bonding box of the svg
width = boundingBox.width * 1.5; // adding the scale factor for consistency with output in chrome browser
height = boundingBox.height * 1.5; // adding the scale factor for consistency with output in chrome browser

// resizing the body to fit the svg
document.body.setAttribute(
'style'
, 'width: ' + width + '; height: ' + height + ';'
)
// resizing the svg via css for consistent display
svg.setAttribute(
'style'
, 'width: ' + width + '; height: ' + height + ';'
)

// set witdth and height attributes used to set the viewport when rending png image
svg.setAttribute(
'width'
, width
)
svg.setAttribute(
'height'
, height
)

svgValue = xmlSerializer.serializeToString(svg)

//console.log(document.body.outerHTML);
Expand Down

0 comments on commit a85a694

Please sign in to comment.