Using Skill Creator to Generate a Skill for Splitting PDF Documents by Chapter
In daily office work, large PDF documents such as manuals, reports, theses, and bidding documents are commonly processed. Manually splitting chapters and renaming the resulting files one by one is time-consuming and affects document processing efficiency. To address this pain point, you can use Skill Creator provided in Marketplace of CodeArts Agent to quickly generate a dedicated PDF-splitting skill.
You can find Skill Creator in Marketplace and use it after installation. When you need a skill, simply say, "Help me create a skill", and specify its desired functions. CodeArts Agent will then produce the necessary skill package.
- Large document splitting: A manual or report with hundreds of pages can be split into single-chapter files for easy distribution and viewing.
- Standard archiving: After splitting, the files are automatically named based on the chapter names and can be directly imported into the database with just one click.
- Targeted distribution: Only a specific chapter is distributed, eliminating the need to send the entire large document, which is more secure and saves bandwidth.
Figure 1 shows the entire process.
Preparations
Before using CodeArts Agent, create a project to store various files in the project. After the project is created, enable the auto approval function. In this way, AI will automatically perform related operations without manual intervention.
- Log in to CodeArts Agent by referring to Quick Start.
- Create a project for storing files.
- On the top menu bar of the IDE, choose File > New > Create Project to go to the page for creating a project.
- Select a path for storing the project, enter the project name (for example, pdf-skill-demo), and click OK.
The project name must start with a letter, and can contain a maximum of 64 characters. Letters, digits, hyphens (-), and underscores (_) are allowed.
After the project is created, you can view the created PDF-SKILL-DEMO project under EXPLORER.
- (Optional) Select the agent running mode and authorize automatic operations.
- Click
in the upper right corner of CodeArts Agent IDE to go to the Settings page. - Choose Chats > Agents > Terminal Command Running Mode, select the running policy for the agent to execute terminal commands. This section uses the default running policy (Running in Sandbox).
- Choose Chats > Auto-approve, and click
to enable the required items. After authorization, tasks for generating complex project-level code are executed automatically. Without authorization, some operations will need your manual confirmation when you code with CodeArts Agent.
Enabling auto approval can lead to operational risks. Assess these risks carefully first and only enable this feature in a secure and trustworthy environment.
Table 1 Parameters for auto approval Parameter
Description
Example
Edit
Allows the agent to call tools like edit, write, and deleteFile to edit files on your computer.
Enabled
Browser Access
Allows the agent to access websites in the browser.
Enabled
Web Crawler
Allows the agent to access and capture specified web page content.
Enabled
- Exit the current page to complete the authorization.
- Click
Installing Skill Creator in the Marketplace
- Click
in the upper right corner of CodeArts Agent IDE to go to the Settings page. - In the navigation pane on the left, choose Skills and Rules.
- Click Marketplace. On the displayed page, locate Skill Creator.
- After specifying the skill, click
, set the installation location to Project, and click OK. After the installation is successful,
next to the skill changes to Installed.
Generating a PDF-Splitting Skill
- In the input box on the CodeArts Agent chat panel, enter the following prompts and click
: Invoke Skill Creator to generate a professional PDF-splitting skill by chapter based on the following rules: [Triggering rules] - Enable the skill as long as a user says "Split the PDF by chapter", "Split and name the PDF by chapter title", or "Split the PDF chapters." [Execution rules] - Automatically identifies chapter titles and boundaries in PDF files. - Splits the original PDF into multiple independent PDFs by chapter. - Names each split file with the corresponding chapter name. [Delivery requirements] No page loss or incorrect splitting. Return all split files after the operation is complete.
- Confirm the creation information, select "Proceed with creation" – Create the skill with the above name and path, click Submit, and wait until the skill is successfully created.
After the skill is created, the pdf-split-by-chapters skill package is generated in the PDF-SKILL-DEMO directory under EXPLORER.
Figure 2 Viewing the generated skill package
- Place the PDF to be split in the current project directory and enter the following prompt in the text box on the chat panel:
Invoke pdf-chapter-splitter to split the PDF of the CodeArts Agent user guide by chapter.
Click
. CodeArts Agent will help you split the PDF.Figure 3 Splitting completed
Figure 4 Viewing the splitting result in the corresponding directory
The graph shown here is for reference only. The actual output may vary.
Prompt Optimization
In the previous section, the prompts for generating skills provide basic core functions, which can only be used to perform simple splitting. There are no unified standards for chapter identification, naming, or exception handling. When the content of a PDF document is complex or batch processing is required, issues such as decreased recognition accuracy, prolonged processing time, and naming exceptions often occur.
You can optimize the prompts, for example, specifying the chapter identification style and adding prerequisite file validation rules, splitting requirements, naming rules, and exception messages. This ensures that skills can be executed in a way that better meets your business needs and can run stably and reliably over the long term.
Prompt After Optimization
Invoke Skill Creator to generate a professional PDF-splitting skill by chapter based on the following rules: [Triggering rules] - Positive triggering: The skill is enabled when a user requests to split a PDF by chapter or title and automatically name the resulting files. - Exclusive constraint: This skill does not perform other operations such as PDF merging, encryption/decryption, text extraction, or format conversion to avoid function conflicts. [Standard handling process] 1. PDF file preprocessing: Check the PDF file status, identify encrypted files, and provide clear prompts and pop-up notifications to users in case of exceptions. 2. Chapter identification and parsing: Identify hierarchical headings, support common formats such as "Chapter X", "1.1", "Chapter 1", and "1", and automatically remove the cover and table of contents pages. 3. Precise document splitting: Split pages based on chapter boundaries to ensure that chapter content is complete and coherent, without missing pages, missing content, content truncation, or page disorder. 4. File naming after splitting: Use the corresponding chapter name as the name of the split file, automatically remove system-prohibited special characters such as / \ : * ? " < > | from the file name, and ensure compatibility with Windows and macOS. 5. Result receipt: After the splitting is complete, output the splitting details list, clearly mark the chapter name and start and end page numbers of each file, and return all split files in an orderly manner. [Quality requirements] Ensure that the splitting result is accurate, the file names do not contain garbled characters, and the files are fully compatible with mainstream PDF formats, meeting the requirements of daily office work and batch production.
Summary of Prompt Optimization Tips
Issues such as skill execution deviation and file naming exceptions are often caused by vague prompt semantics and lack of rules. When writing prompts, follow the practical tips described in the table below to ensure standardization. This can comprehensively optimize the skill execution effect, reduce running deviations, and significantly improve the practicality and stability of the PDF chapter splitting function.
| Tip | Good Example | Bad Example |
|---|---|---|
| Specify chapter identification rules. | Identify hierarchical headings, support common formats such as "Chapter X", "1.1", "Chapter 1", and "1", and automatically remove the cover and table of contents pages. | Automatically identifies chapters in PDF files. |
| Specify exclusive rules to prevent foundation models from triggering other operations by mistake. | Do not perform other PDF operations such as merging, encryption, and text extraction to avoid conflicts. | No content is provided. |
| Consider exception scenarios. |
| No content is provided. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
