Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.supernote.com/llms.txt

Use this file to discover all available pages before exploring further.

This API belongs to PluginNoteAPI and can only be called in NOTE.
static generateLayerPreviewImage(
  notePath: string,
  page: number,
  layer: number,
  imagePath: string
): Promise<APIResponse<boolean>>;
Parameters
ParameterTypeDescription
notePathstringNOTE file path
pagenumberPage index (starts from 0)
layernumberLayer index. -1 indicates the background layer, 0 indicates the main layer, and 1~3 indicate custom layers
imagePathstringOutput path for the thumbnail image
Returns
  • APIResponse<boolean>: result === true indicates the layer thumbnail image was generated successfully

Example

import { PluginNoteAPI } from 'sn-plugin-lib';

/**
 * Example: generate a thumbnail image for a layer.
 */
export async function exampleGenerateLayerPreviewImage() {
  const res = await PluginNoteAPI.generateLayerPreviewImage(
    '/storage/emulated/0/Note/demo.note',
    0,
    0,
    '/storage/emulated/0/Note/out/layer-preview.png'
  );
  if (!res.success) {
    throw new Error(res.error?.message ?? 'generateLayerPreviewImage call failed');
  }
  return res.result;
}