cakebake / markdown-themeable-pdf

ARCHIVED. NOT MAINTAINED. Themeable Markdown Converter (Print to PDF, HTML, JPEG or PNG)
https://atom.io/packages/markdown-themeable-pdf
133 stars 37 forks source link

Question: Filename to header/footer? #28

Closed dynobo closed 8 years ago

dynobo commented 8 years ago

Is it possible, to automatically add the filename of the markdown-file to the pdf-header or pdf-footer? If so, what would the Javascript-Code for header.js would look like?

Thanks a lot for your extension! :-)

cakebake commented 8 years ago

Currently not. In general, however, I find it a good idea to make the most important data (input and output format, etc) available. Once I have the time, I'll implement it. In any case, before v1.0 ;)

cakebake commented 8 years ago

Now some useful informations are available like Object {fileInfo: Object, exportType: "pdf", destFileBase: "Demo.pdf", destFile: "......./markdown-themeable-pdf/tests/Demo.pdf"}. In obj.fileInfo.name for example the name of the markdown document.

cakebake commented 8 years ago

Example code

/**
 * Your markdown-themeable-pdf custom header.
 * After you have made any changes you need to reload or restart atom.
 *
 * The default file can be found in the folder ~/.atom/packages/markdown-themeable-pdf/templates
 *
 * @param Object For example: {fileInfo: base: "Demo.md", dir: ".../markdown-themeable-pdf/tests", ext: ".md", name: "Demo"}, root: "/", exportType: "pdf", destFileBase: "Demo.pdf", destFile: "......./markdown-themeable-pdf/tests/Demo.pdf"}
 * @returns Object {{height: string, contents: string}}
 */
module.exports = function (info) {
    return {
        height: '2cm',
        contents: '<div style="text-align: right;"><strong>' + info.fileInfo.base + '</strong> to <strong>' + info.destFileBase + '</strong> by <span style="color: #EC4634; font-size: 120%; text-transform: uppercase;">markdown-themeable-pdf</span></div>'
    };
};