Scenario: i'm iterating through several .md
files, converting them first in HTML
and then PDF
.
I need the file path on one of my pipe (the pdf
one) but i don't know how to do it.
EDIT:
- I do not need to rename the files as they are piped through.
- I want to get the file path of the processed file on the
pdf
pipe, since i want to use it in that pipe (as shown in the code).
var pdf= require('gulp-html-pdf');
return gulp.src(path.join(config.ROOT, '**/docs/**/*.md'))
// doing stuff...
.pipe(gulp.dest(function(file) {
return file.base;
}))
// Converting it to PDF
.pipe(
// i need the file path here, in order to use it for the PDF options
pdf({
"format": "A4",
"border": {
"top": "0cm", // default is 0, units: mm, cm, in, px
"right": "2.5cm",
"bottom": "0cm",
"left": "2.5cm"
},
"header": {
"height": "3cm",
"contents": '<header style="text-align: center;">' + FILE PATH + '</header>'
},
"footer": {
"height": "3cm",
"contents": '<footer style="height:3cm; text-align:right; padding-top:1cm">Page: {{page}}</span>/<span>{{pages}}</footer>'
},
"phantomArgs": []
}))
// Saving PDF
.pipe(gulp.dest(function(file) {
var fileName = file.path.substr(file.path.lastIndexOf('docs\\') + 5);
console.log("...creating ", fileName);
return file.base;
}));