-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate PDFs with chromium, remove wicked_pdf #453
Changes from all commits
bd78d3c
679b39f
7303419
8b38e6e
1fea085
c386850
e052f74
b36db00
1421c58
40e1602
97d671e
52717c8
c1f07e1
6dd2119
37c184a
5100f32
9172fc6
78a15cd
b1bb4d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,7 +183,6 @@ table { | |
width: 100%; | ||
} | ||
|
||
|
||
ul, ol { | ||
margin-left: 1.6rem; | ||
} | ||
|
@@ -196,6 +195,25 @@ h1 { | |
page-break-before: always; | ||
} | ||
|
||
@page { | ||
size: auto; | ||
margin: 0.6in 1in 1.5in 1in; | ||
} | ||
|
||
#header { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
} | ||
|
||
#header img { | ||
width: 100%; | ||
} | ||
|
||
#main-content { | ||
margin-top: 65px; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pushed a change to inline the stylesheet and use a data URI for the header image, which should be more reliable. |
||
|
||
.toc ol { | ||
margin-left: 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env node | ||
|
||
var process = require('process'); | ||
var fs = require('fs'); | ||
|
||
var argv = require('minimist')(process.argv.slice(2), { | ||
string: ['html', 'pdf'] | ||
}); | ||
|
||
var htmlPdf = require('../node_modules/html-pdf-chrome'); | ||
|
||
if (!argv['html'] || !argv['pdf']) { | ||
console.log('Usage: html-pdf-chrome --html input.html --pdf output.pdf'); | ||
process.exit(1); | ||
} | ||
|
||
var html = fs.readFileSync(argv['html']).toString(); | ||
|
||
var options = { | ||
chromePath: 'chromium-browser', | ||
chromeFlags: [ | ||
'--disable-gpu', | ||
'--no-sandbox', | ||
'--headless', | ||
'--hide-scrollbars', | ||
] | ||
}; | ||
|
||
htmlPdf.create(html, options).then(function(pdf) { | ||
pdf.toFile(argv['pdf']); | ||
}); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ namespace :pdfs do | |
task recreate: :environment do | ||
Lesson.published.find_each do |lesson| | ||
UpdateLessonPdf.perform_now(lesson.id) | ||
sleep 0.5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove xvfb and wkhtmltopdf@edgetesting from the Dockerfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! Good idea.