Flayms / Markdown2Pdf

.NET library for converting markdown to PDF.
https://www.nuget.org/packages/Markdown2Pdf/
MIT License
5 stars 1 forks source link

Set title in file properties of PDF file #71

Closed INOPIAE closed 4 months ago

INOPIAE commented 4 months ago

Is there a way to set the title property in the file properties in the generated PDF file. As far as I can see the filename of the html file is taken as title property. image

Flayms commented 4 months ago

It uses the html title-element which is currently unset so it defaults to the filename. I think the best way to resolve this is to insert a title-element with Markdown2PdfOptions.Title into the html (same property that also gets inserted into header / footer) if set. What do you think about this?

INOPIAE commented 4 months ago

Sounds good. Once working on the file properties may be it is worth to add other file properties as well. e.g. Author, Subject and Keywords Here an idea https://stackoverflow.com/questions/51153026/puppeteer-pdf-title-and-author-metadata

Default settings could be: Title: filename Author: empty Subject: empty Keywords: empty

Flayms commented 4 months ago

Alright, gonna set the title over the HTML. For the other metadata there's no puppeteer support but might be adjustable with https://github.com/UglyToad/PdfPig which I am already using for generating the TOC page numbers.

Flayms commented 4 months ago

With PdfPig it's easy to read the Metadata, however It seems like It can't be used it for editing it. Currently still looking for an easy way to edit XMP metadata in C#. Exiftool is nice but would need to create a wrapper for it that also works cross-platform. This sounds quite painful.