Skip to content

Build your personal knowledge base with Trilium Notes

feat(print): add printer descriptions

Elian Doran6225f92a7d77
diff --git a/apps/client/src/widgets/dialogs/print_preview.tsx b/apps/client/src/widgets/dialogs/print_preview.tsx
index b0b3f4cca8..fedd2cd523 100644
--- a/apps/client/src/widgets/dialogs/print_preview.tsx
+++ b/apps/client/src/widgets/dialogs/print_preview.tsx
@@ -22,8 +22,19 @@ const DESTINATION_PDF = "__pdf__";
interface PrinterInfo {
name: string;
displayName: string;
+ description: string;
+ location: string;
isDefault: boolean;
}
+
+/** Builds the description line shown under a printer in the dropdown. */
+function buildPrinterDescription(printer: PrinterInfo): string | undefined {
+ const parts: string[] = [];
+ if (printer.isDefault) parts.push(t("print_preview.destination_default"));
+ if (printer.location) parts.push(printer.location);
+ else if (printer.description) parts.push(printer.description);
+ return parts.length ? parts.join(" · ") : undefined;
+}
const MARGIN_PRESETS = ["default", "none", "minimum"] as const;
type MarginPreset = typeof MARGIN_PRESETS[number];
@@ -313,7 +324,7 @@ export default function PrintPreviewDialog() {
icon="bx bx-printer"
selected={destination === printer.name}
onClick={() => setDestination(printer.name)}
- description={printer.isDefault ? t("print_preview.destination_default") : undefined}
+ description={buildPrinterDescription(printer)}
>
{printer.displayName || printer.name}
</FormListItem>
diff --git a/apps/server/src/services/window.ts b/apps/server/src/services/window.ts
index 93a5135751..e4c33f434a 100644
--- a/apps/server/src/services/window.ts
+++ b/apps/server/src/services/window.ts
@@ -277,7 +277,18 @@ interface PrintFromPreviewOpts extends ExportAsPdfOpts {
electron.ipcMain.handle("get-printers", async (e) => {
try {
- return await e.sender.getPrintersAsync();
+ const printers = await e.sender.getPrintersAsync();
+ return printers.map((p) => {
+ // Platform-specific: CUPS uses "printer-location", Windows/mac often expose "location".
+ const opts = (p.options ?? {}) as Record<string, string>;
+ return {
+ name: p.name,
+ displayName: p.displayName,
+ description: p.description,
+ location: opts["printer-location"] || opts.location || "",
+ isDefault: (p as unknown as { isDefault?: boolean }).isDefault ?? false
+ };
+ });
} catch {
return [];
}