laurent22/joplin · error · Error
Only one note can be printed at a time.
Error message
Only one note can be printed at a time.
What it means
Thrown by the print command when noteIds.length is not exactly 1. The renderer's printTo accepts a single noteId; printing zero or multiple notes at once is unsupported.
Source
Thrown at packages/app-desktop/gui/WindowCommandsAndDialogs/commands/print.ts:18
import { CommandRuntime, CommandDeclaration, CommandContext } from '@joplin/lib/services/CommandService';
import { _ } from '@joplin/lib/locale';
import { WindowControl } from '../utils/useWindowControl';
import bridge from '../../../services/bridge';
export const declaration: CommandDeclaration = {
name: 'print',
label: () => _('Print'),
iconName: 'fa-file',
};
export const runtime = (comp: WindowControl): CommandRuntime => {
return {
execute: async (context: CommandContext, noteIds: string[] = null) => {
noteIds = noteIds || context.state.selectedNoteIds;
try {
if (noteIds.length !== 1) throw new Error(_('Only one note can be printed at a time.'));
await comp.printTo('printer', { noteId: noteIds[0] });
} catch (error) {
bridge().showErrorMessageBox(error.message);
}
},
enabledCondition: 'someNotesSelected && !noteLockContentUnavailable',
};
};
View on GitHub (pinned to 2654b33620)
Solutions
- Select exactly one note before printing.
- Gate the command behind an enabledCondition of `oneNoteSelected` (currently it uses someNotesSelected).
- If invoking programmatically, pass a single-element noteIds array.
- Loop and print one at a time if batch printing is genuinely needed.
Example fix
// before
if (noteIds.length !== 1) throw new Error(_('Only one note can be printed at a time.'));
// after — clear guidance in the message
if (noteIds.length !== 1) {
throw new Error(_('Only one note can be printed at a time. %d note(s) selected.', noteIds.length));
} Defensive patterns
Strategy: validation
Validate before calling
if (!noteIds || noteIds.length !== 1) {
// prompt user to select exactly one note
return;
}
await CommandService.instance().execute('print', noteIds); Type guard
function exactlyOneNote(ids: string[] | null | undefined): ids is [string] {
return Array.isArray(ids) && ids.length === 1;
} Try / catch
try {
await CommandService.instance().execute('print', noteIds);
} catch (e) {
if (e.message.includes('Only one note can be printed')) {
// tell the user to select a single note
} else throw e;
} Prevention
- Use an enabledCondition of 'oneNoteSelected' for the print command.
- Pass a single-element array when invoking programmatically.
- For batch needs, loop and print one note at a time.
When it happens
Trigger: Executing print with an empty selection (length 0) or a multi-selection (length > 1). The guard `if (noteIds.length !== 1)` fires before comp.printTo.
Common situations: User triggers Print with no note selected; user multi-selects notes and hits Print; a plugin calls execute() without filtering to a single note.
Related errors
- No notes selected for pdf export
- Locked notes cannot be opened in an external editor
- Format "${format}" can only be exported to a file
- Only one output directory can be selected
- Cannot move item with type ${itemType}
AI-assisted analysis of laurent22/joplin@2654b33620 (2026-08-12).
Data as JSON: /api/errors/60d4cfa3fe855cbd.
Report an issue: GitHub.