Properties: option to export to PDF

Use case or problem

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!

Current workaround (optional)

There’s no workaround currently.

Related feature requests (optional)

None that I know of.

44 Likes

Upvote!!!

2 Likes

This would be a great feature.

It would also be good if the functionality could be to select the properties you want to include/exclude.

1 Like

I would love this! If all properties were included, that would be fine with me.

1 Like

I found two workaround options using Dataview.

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)
1 Like

Brilliant solution, @Lu_do!! Thanks!