Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.2.0
=====
- Support remote images in html template


0.1.3
=====
- Update phantomjs node module dependency, some cdn changed
Expand Down
31 changes: 15 additions & 16 deletions lib/scripts/pdf_a4_portrait.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,23 @@ else

page.paperSize = paperSize

page.onLoadFinished = (status) ->
# Output to parent process
fileOptions =
type: options.type || 'pdf'
quality: options.quality || 75

# Option 1: Output file to stdout
# Not working in Ubuntu 12.04 (at least not in my environment)
if options.buffer
page.render('/dev/stdout', fileOptions)

# Output to parent process
fileOptions =
type: options.type || 'pdf'
quality: options.quality || 75

# Option 1: Output file to stdout
# Not working in Ubuntu 12.04 (at least not in my environment)
if options.buffer
page.render('/dev/stdout', fileOptions)


# Option 2: Output filename to stdout
else
filename = options.filename || ("#{options.directory || '/tmp'}/html-pdf-#{sys.pid}-#{size}.#{fileOptions.type}")
page.render(filename, fileOptions)
sys.stdout.write(filename)
# Option 2: Output filename to stdout
else
filename = options.filename || ("#{options.directory || '/tmp'}/html-pdf-#{sys.pid}-#{size}.#{fileOptions.type}")
page.render(filename, fileOptions)
sys.stdout.write(filename)


phantom.exit(0)
phantom.exit(0)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html-pdf",
"version": "0.1.3",
"version": "0.2.0",
"description": "HTML to PDF converter that uses phantomjs",
"main": "index.js",
"directories": {
Expand Down
31 changes: 30 additions & 1 deletion test/businesscard.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,46 @@
}

.group {
margin-top: 6mm;
margin-top: 3mm;
}

.line {
color: white;
position: relative;
}

.ghost {
position: relative;
text-align: center;
-webkit-transform: scale(0.6);
}

.ghost .body {
z-index: 1;
position: relative;
height: 176px;
width: 125px;
}

.ghost .eyes {
z-index: 10;
position: absolute;
left: 50%;
margin-left: -22px;
top: 25%;
width: 44px;
height: 25px;
background: url('http://static.suitart.com/templates/eyes.gif');
}

</style>
</head>
<body>
<div class="bottom">
<div class="ghost">
<div class="eyes"></div>
<img class="body" src="http://static.suitart.com/templates/ghost.png">
</div>
<div class="line">Marc Bachmann</div>
<div class="line">cto</div>

Expand Down