Properties are a great addition to Obsidian! Nevertheless, it would be great to have the option to export them to PDF, too, as some stuff we used to keep on the note body we can put on metadata (e.g., tags, related notes, etc.), potentially losing track of them on exported PDFs.
Proposed solution
Implementing the “Include file properties” option in the PDF modal would be great!
First one using DQL listing all fields as a table:
TABLE WITHOUT ID file.frontmatter AS Properties
WHERE file.name = this.file.name
Second one using JavaScript (more versatile as you can exclude certain fields that you do not want to export, but also much more involved):
// Retrieve the current file's frontmatter
let frontmatter = dv.current().file.frontmatter;
// Define fields to exclude (adapt as necessary)
let excludeFields = ['tags', 'created']
// Extract and filter the keys and values based on the exclusion list
let filtered_keys = Object.keys(frontmatter).filter(key => ! excludeFields.includes(key));
let filtered_values = filtered_keys.map(key => frontmatter[key]);
// Define an array to hold each row of the table
let rows = [];
// Populate the rows array with key-value pairs
for (let i = 0; i < filtered_keys.length; i++) {
// Convert array values (e.g. tags) to a single string separated by commas
let value = Array.isArray(filtered_values[i]) ? filtered_values[i].join(', ') : filtered_values [i];
rows.push([filtered_keys[i], value])
}
// Generate a table with two columns and populate with rows
dv.table(['Properties', 'Values'], rows)
Reviving this post to ask if there is a way to add that dataview table only when exporting to PDF, but otherwise not have it in the file always?
I have the dataviewjs script on a template to save it because it kept bothering me to have it in the files as I already have the native properties shown, so it’s just taking up space. I also do export multiple files to PDF at once and I’d rather not have to enter each of them to add the table before exporting and then going back to remove them.
I propose a short term alternative : Right clic / Open in default app (choose your favorite txt viewer app - i use notepad) / Then, in that app, Print using the native PDF printer. Not user friendly but it helps me waiting. It’s not a multiple files solution
absolutely INSANE that this doesn’t already exist. Shocked you guys are acting like this is a novel idea. Appalled that we haven’t already found a solution as one would think this is basic 101 level feature for what is supposed to be an “extensible” platform.
It is really hard to believe that there is no print option in Obsidian. I think Windows Notepad had this functionality back in the 1980’s. When I started searching for how to print, I thought people were joking when they said that that function didn’t exist. Just cut and past everything in another program … Really?
Hi - Is there any news on the likelihood of this feature being implemented and if so when? The requirement has been identified for some time now. Is there some reason why it is difficult to implement?
Marijn Bent has developed a community Print plug-in that works really well. GitHub - marijnbent/obsidian-print: Print your notes directly from Obsidian Perhaps this could be extended to include the feature for printing Note properties. It may be worthwhile Obsidian coordintating with Marijn to adopt the Print plug-in as one of Obsidian’s core plug-ins.
Hi. Looking for a bit of help on this topic please. Is there any way of using Dataview or css code snippet to allow for the Note properties to be included when printing or exporting to pdf? Thanks.
You mean something along the lines that the snippet from @Lu_do gets included automatically when exporting as pdf? That would be a very nice feature!
Currently I have a template based on this answer above and insert it manually at the end of a file whenever I want to export something to PDF. It’s not that elegant, but I rarely do exports, so this workaround is ok. And I absolutely want the relevant properties to show up.
Yes. It would be ideal if Note Property fields could be automatically included in printouts or PDF exports. @Lu_do solution above works well. Like you, I’ve found a workround using a Template but it would be nice to have a more elegant standard feature for this important feature.