AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { Property, createAction } from '@activepieces/pieces-framework';
import { iloveapiAuth } from '../common/auth';
import { iloveSchemas } from '../common/schemas';
import { fileToUploadInput, regionOf, sharedProps, webhookOf } from '../common/props';
import { runAndStoreResult } from '../common/runner';
export const pageNumbersPdfAction = createAction({
auth: iloveapiAuth,
name: 'page_numbers_pdf',
classification: 'READ',
displayName: 'Add Page Numbers to PDF',
description: 'Stamp page numbers onto a PDF, with control over position and styling.',
audience: 'both',
outputSchema: iloveSchemas.toolResult,
aiMetadata: {
description:
'Print page numbers onto a PDF, with control over which pages, the starting number, the {n}/{p} number format, facing-page (book) layout, cover-skip, and font styling. Each run produces a new numbered file, so re-running re-stamps rather than reusing an earlier output.',
idempotent: false,
},
props: {
file: Property.File({
displayName: 'PDF File',
required: true,
}),
pages: Property.ShortText({
displayName: 'Pages',
description:
'Pages to number. Use "all" or ranges like "2-5,7". Defaults to all.',
required: false,
defaultValue: 'all',
}),
starting_number: Property.Number({
displayName: 'Starting Number',
description: 'First page number to print. Defaults to 1.',
required: false,
defaultValue: 1,
}),
first_cover: Property.Checkbox({
displayName: 'Skip First Page (Cover)',
description: 'When enabled, skips numbering the first page.',
required: false,
defaultValue: false,
}),
facing_pages: Property.Checkbox({
displayName: 'Facing Pages (book mode)',
description:
'Alternate horizontal position for left/right pages, like a printed book.',
required: false,
defaultValue: false,
}),
vertical_position: Property.StaticDropdown({
displayName: 'Vertical Position',
required: false,
defaultValue: 'bottom',
options: {
disabled: false,
options: [
{ label: 'Top', value: 'top' },
{ label: 'Bottom', value: 'bottom' },
],
},
}),
horizontal_position: Property.StaticDropdown({
displayName: 'Horizontal Position',
required: false,
defaultValue: 'center',
options: {
disabled: false,
options: [
{ label: 'Left', value: 'left' },
{ label: 'Center', value: 'center' },
{ label: 'Right', value: 'right' },
],
},
}),
text: Property.ShortText({
displayName: 'Number Format',
description: 'Use {n} for current page and {p} for total pages. Example: "{n} of {p}".',
required: false,
defaultValue: '{n}',
}),
font_family: Property.StaticDropdown({
displayName: 'Font',
required: false,
defaultValue: 'Arial',
options: {
disabled: false,
options: [
{ label: 'Arial', value: 'Arial' },
{ label: 'Verdana', value: 'Verdana' },
{ label: 'Courier', value: 'Courier' },
{ label: 'Times New Roman', value: 'Times New Roman' },
{ label: 'Comic Sans MS', value: 'Comic Sans MS' },
],
},
}),
font_size: Property.Number({
displayName: 'Font Size',
required: false,
defaultValue: 14,
}),
font_color: Property.ShortText({
displayName: 'Font Color',
description: 'Hex color, e.g. #000000.',
required: false,
defaultValue: '#000000',
}),
...sharedProps,
},
async run(context) {
const {
file,
pages,
starting_number,
first_cover,
facing_pages,
vertical_position,
horizontal_position,
text,
font_family,
font_size,
font_color,
output_filename,
packaged_filename,
} = context.propsValue;
const options: Record<string, unknown> = {
pages: pages ?? 'all',
starting_number: starting_number ?? 1,
first_cover: first_cover ?? false,
facing_pages: facing_pages ?? false,
vertical_position: vertical_position ?? 'bottom',
horizontal_position: horizontal_position ?? 'center',
text: text ?? '{n}',
font_family: font_family ?? 'Arial',
font_size: font_size ?? 14,
font_color: font_color ?? '#000000',
};
return await runAndStoreResult({
auth: context.auth.secret_text,
region: regionOf(context.propsValue.region),
webhook: webhookOf(context.propsValue.webhook_url),
files: context.files,
tool: 'pagenumber',
uploads: [fileToUploadInput({ file: file })],
options,
output_filename,
packaged_filename,
});
},
});