Quick Fixes are not quick Fixups
Opens in new tabUsing AI to create pdfToolbox imposition scripts: useful, but not magic
Large language models are now very good at writing JavaScript. That is useful, but in a production environment, it is only part of the story. During a recent callas webinar, we explored whether AI can help create imposition scripts for pdfToolbox using JavaScript.
The answer is yes — but only if the AI is handled correctly. LLMs are advanced technology, not magic.
When asking an AI tool to create imposition scripts for pdfToolbox, we are not asking it to write generic JavaScript. We are asking it to write JavaScript that works inside the pdfToolbox imposition environment.
That means the AI has to understand specific pdfToolbox concepts: the objects inserted into the JavaScript context, the convenience methods available on those objects, the constants that need to be used, the expected order of operations, and the production logic behind imposition itself.
This is where things become interesting.
Public AI models have seen huge amounts of general JavaScript. They have also seen general information about print production and imposition. But there is not much public training material on creating imposition scripts for pdfToolbox specifically. That means the model may be able to write JavaScript that looks plausible, while still getting important pdfToolbox-specific details wrong.
The trick is therefore not simply to ask better questions. The trick is to build a better working environment for the AI—one that gives it the documentation, examples, and context it needs to generate reliable imposition scripts.
For the webinar, we used a project-based setup in an AI tool. The exact tool is less important than the approach: the AI needs a place where it can keep relevant documentation, rules, examples, and instructions together across multiple conversations.
The project contained several types of material.
First, it included pdfToolbox documentation, especially the imposition documentation. This gives the AI a source of truth for the functionality it is expected to use.
Second, it included a small framework of guidance files. The
se described rules, coding style, preferred patterns, and how the AI should interact with the user. For example, the AI was instructed to prefer clarity over cleverness, to use readable code, and to avoid silently making assumptions when the user’s request is vague.
Third, it included carefully prepared example scripts. These examples were not simply copied from older real-world scripts. That would have introduced too much inconsistency. Real scripts often evolve over time and may reflect different habits, styles, or historical limitations. For an AI workbench, consistent examples are more useful than a large number of noisy examples.
The goal of these files was not to make the AI “creative”. The goal was to give it a narrow, reliable frame of reference.

One of the important lessons from this experiment is that more examples are not always better.
If you give an AI five different examples that solve similar problems in five slightly different ways, it may not know which pattern to follow. It may blend styles, copy outdated approaches, or make assumptions that are technically valid in one example but not in another.
For this reason, the example files used in the webinar were deliberately created to cover important pdfToolbox imposition concepts in a consistent style. They are artificial examples, but that is a strength in this context. They teach the model the patterns we want it to follow.
This is very similar to onboarding a junior developer. You do not simply hand over ten years of historical scripts and hope for the best. You provide documentation, explain conventions, give good examples, and define what “good” looks like.
A key part of the setup was instructing the AI to ask questions before writing code.
This matters because production workflows are full of hidden assumptions. Which page box should be used? Should bleed be included? What gaps and margins are required? Should pages be rotated if that improves sheet usage? Is the incoming file always one page, or can it be multi-page?
If those details are missing, the AI should not simply guess. It should ask.
During the webinar demo, this was visible in practice. When asked to create a simple step-and-repeat imposition, the AI asked for missing information before generating the script. Once the missing details were provided, it produced JavaScript that could be copied into pdfToolbox and tested.
That does not mean every generated script is automatically correct. It means the process becomes much safer than a single vague prompt followed by unverified code.
AI-generated code should always be tested.
In the webinar, the generated step-and-repeat configuration worked in pdfToolbox. But in earlier experiments, generated scripts did contain bugs. In one case, the algorithm for pattern repetition did not fully cover the expected page area. The useful part was that the AI could also help with the correction: by describing the visible problem, the model was able to adjust the script and improve the result.
This is one of the most promising parts of the workflow. You do not need to treat the AI response as a final answer. You can test the result, describe what went wrong, provide screenshots or output files, and ask the AI to revise the script.
The right mental model is not “AI replaces testing”. The right mental model is “AI helps accelerate the cycle of drafting, testing, correcting, and refining”.
One of the questions raised during the webinar was whether the same prompt would produce the same script next week.
The honest answer is: not necessarily.
AI systems are not fully deterministic in the way traditional software is. The model may phrase questions differently, generate slightly different code, or take a different route to the same result. In addition, the tools themselves change quickly. The model available today may not behave exactly like the model available next month.
However, the controlled workbench approach improves repeatability. By giving the AI documentation, style rules, canonical examples, and explicit interaction instructions, we reduce the amount of uncontrolled guessing. The output may not be identical every time, but it is more likely to be functionally similar, readable, and aligned with the expected pdfToolbox patterns.
For production use, that distinction matters. The goal is not blind trust. The goal is a better starting point and a more efficient development process.
Another interesting question from the webinar was whether this type of AI-assisted workflow should eventually be integrated directly into pdfToolbox.
That is an important question, but not a simple one.
Today, the strongest results often come from current online AI models, and these models change rapidly. Different users may also have different preferences for coding style, assumptions, and production behaviour. Some of the framework files used in the webinar reflect personal preferences, not universal rules.
That suggests that, for now, the most useful approach may be to provide AI-ready material around pdfToolbox: documentation extracts, curated examples, prompt templates, and guidance that users can adapt to their own needs.
In the future, deeper integration may become interesting. But any production-oriented AI feature would need to respect the same principles shown in this experiment: clear context, explicit assumptions, user control, and proper validation.
Watch the recording and try the materials
The project materials shown during the webinar are available here:
These materials are intended as a starting point. They should not be treated as the only correct way to work. Review them, adapt them, change the style rules if needed, add your own examples, and refine the prompts for your own production requirements.
And if you find useful improvements, please share them with us. The more real-world experience we gather, the better these AI-assisted workflows can become.
The same approach may also be useful in other areas of pdfToolbox.
For example, pdfToolbox also supports placing content using HTML templates, JavaScript, CSS, and pdfToolbox-specific behaviour. That has a similar structure: widely known base technologies combined with product-specific rules and production-specific expectations.
This makes it a good candidate for a future experiment.
AI can be genuinely useful for creating pdfToolbox imposition scripts. But the useful part is not magic, and it is not just prompt writing.
The useful part is building a controlled workbench: documentation, rules, examples, clarification, testing, and iteration.
Used that way, AI becomes less of a mysterious black box and more of a practical assistant: not a replacement for production knowledge, but a way to make that knowledge easier to apply.