mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-29 05:04:22 -05:00
Merge pull request #857 from hackmdio/fix/pdf-links
Fix broken images in PDF caused by misconfigred server URL
This commit is contained in:
commit
ec78c4f2fc
1 changed files with 4 additions and 1 deletions
|
@ -327,15 +327,18 @@ function actionInfo (req, res, note) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function actionPDF (req, res, note) {
|
function actionPDF (req, res, note) {
|
||||||
|
var url = config.serverURL || 'http://' + req.get('host')
|
||||||
var body = note.content
|
var body = note.content
|
||||||
var extracted = models.Note.extractMeta(body)
|
var extracted = models.Note.extractMeta(body)
|
||||||
|
var content = extracted.markdown
|
||||||
var title = models.Note.decodeTitle(note.title)
|
var title = models.Note.decodeTitle(note.title)
|
||||||
|
|
||||||
if (!fs.existsSync(config.tmpPath)) {
|
if (!fs.existsSync(config.tmpPath)) {
|
||||||
fs.mkdirSync(config.tmpPath)
|
fs.mkdirSync(config.tmpPath)
|
||||||
}
|
}
|
||||||
var path = config.tmpPath + '/' + Date.now() + '.pdf'
|
var path = config.tmpPath + '/' + Date.now() + '.pdf'
|
||||||
markdownpdf().from.string(extracted.markdown).to(path, function () {
|
content = content.replace(/\]\(\//g, '](' + url + '/')
|
||||||
|
markdownpdf().from.string(content).to(path, function () {
|
||||||
var stream = fs.createReadStream(path)
|
var stream = fs.createReadStream(path)
|
||||||
var filename = title
|
var filename = title
|
||||||
// Be careful of special characters
|
// Be careful of special characters
|
||||||
|
|
Loading…
Reference in a new issue