get_hwp_page_def
Retrieve page definitions including paper size, margins, and columns for each section in a Hangul Word Processor file. Understand document layout properties.
Instructions
Get per-section page definition (paper size, margins, columns) and section properties. Useful for understanding document layout. Args: file_path.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes |
Implementation Reference
- src/tools/info.ts:92-118 (handler)The handler function for the 'get_hwp_page_def' tool. Opens a document, iterates over each section, retrieves page definition and section definition via doc.getPageDef(s) and doc.getSectionDef(s), and returns a formatted string.
export async function getHwpPageDef(args: FilePathArgs): Promise<string> { let doc; try { doc = await openDocument(args.file_path); } catch (e) { return (e as Error).message; } try { const sectionCount = doc.getSectionCount(); const out: string[] = []; for (let s = 0; s < sectionCount; s++) { try { const pageRaw = doc.getPageDef(s); const sectionRaw = doc.getSectionDef(s); out.push(`# section ${s}`); out.push(`pageDef: ${pageRaw}`); out.push(`sectionDef: ${sectionRaw}`); out.push(""); } catch (e) { out.push(`section ${s}: ${(e as Error).message}`); } } return out.join("\n"); } finally { closeDocument(doc); } } - src/tools/info.ts:12-14 (schema)The FilePathArgs interface defining the input schema fields: file_path (string).
export interface FilePathArgs { file_path: string; } - src/server.ts:131-140 (registration)Tool registration metadata: name 'get_hwp_page_def', description, and inputSchema (type object with required file_path).
{ name: "get_hwp_page_def", description: "Get per-section page definition (paper size, margins, columns) and section properties. Useful for understanding document layout. Args: file_path.", inputSchema: { type: "object", properties: { file_path: { type: "string" } }, required: ["file_path"], }, }, - src/server.ts:521-521 (registration)Handler mapping in the HANDLERS record: maps 'get_hwp_page_def' to the getHwpPageDef function.
get_hwp_page_def: getHwpPageDef, - src/server.ts:17-17 (registration)Import of getHwpPageDef from the info.ts module.
import { getHwpInfo, listHwpFields, getHwpFieldValue, getHwpPageDef } from "./tools/info.js";