You can print a Perspective screen from a button. The requestPrint component method and the Request Print component action were added in 8.1.28. Put self.requestPrint(target='page', documentTitle='MyPDF') in the button's onActionPerformed event, and the browser print dialog opens.
What it will not do is print content scrolled off screen. It prints exactly what is visible in the browser viewport, whether the target is page or view. To get scrolled content onto paper, change what is visible before printing. Changing the target will not help.
Read the Symptoms Before Touching the Script
Start here. Most failed print buttons are not script bugs. They come from version, platform, or viewport limits. Match what you see to the cause before editing anything.
| What you see | Cause | First check |
|---|---|---|
Button does nothing; script error says requestPrint is not an attribute of the component |
Gateway is older than 8.1.28 | Gateway version on the status page |
| Button works in a desktop browser, does nothing in the mobile app | Feature works in web browsers only, not mobile | Test the same view in a desktop browser session |
| Print dialog opens and the operator has to pick a printer or PDF destination | Normal browser behavior. Silent printing is blocked. | Nothing to fix |
| Printout cuts off at the bottom of the screen; scrolled rows or containers are missing | requestPrint captures only the visible viewport | Zoom out and print again to confirm |
target='page' and target='view' give identical, clipped output |
Both targets are bounded by what is on screen | Stop swapping targets. Change the layout or zoom. |
| Printout shows only the button |
target='component' called on self from the button |
Which component the method is called on |
| Cannot print another browser tab or the desktop | Browser sandbox. Printing is limited to the current page. | Nothing to fix |
Understand Why the Printout Stops at the Viewport
A Perspective session is a web page rendered in the browser. requestPrint hands that rendered page to the browser's print pipeline and asks the browser to print it. It does not build a separate document.
- The print scope you choose (page, view, or component) decides which element gets printed. It does not decide how much of that element gets rendered.
- Scroll containers in Perspective clip their overflow. Content below the fold exists in the session, but it is not painted on screen. The print captures the painted screen.
- That is why
viewandpagegive the same result on a scrolling screen. Both scopes stop at the edge of the viewport. - Zooming the browser out shrinks everything so more of the view fits inside the viewport. That is the only in-place way to pull more content into the print.
The browser also controls the last step. The operator must confirm the print and choose a destination. Browsers treat any page that prints without confirmation, or reaches into other tabs, as malicious. No Perspective setting overrides that.
Confirm the Gateway Supports requestPrint
Check this first. It takes ten seconds and rules out the most common reason a button does nothing.
- Open the Gateway web page and read the version on the status/overview page.
- If the version is 8.1.28 or later, the method exists. An 8.1.35 gateway, for example, has it.
- If the version is older than 8.1.28, upgrade the gateway. Script workarounds will not add a component method.
- The feature first appeared in an 8.1.28 nightly build. Run a release build at or above 8.1.28 on production gateways, not a snapshot.
No other gateway module, license, or configuration is needed for the call itself. Once the version is right, the rest is button configuration.
Wire the Print Button
There are two ways to do it. Use the built-in action if you need no logic. Use the script if you want to set the title dynamically or print a component other than the button.
Option A: Request Print action (no script)
- In the Designer, right-click the button and open Configure Events.
- Select the
onActionPerformedevent. - Add the Request Print action.
- Choose the scope: page, view, or component.
- Save the project and test in a browser session.
Option B: Script action
- In Configure Events, select
onActionPerformedand add a Script action. - Enter the call:
self.requestPrint(target='page', documentTitle='MyPDF') - Set
targetto the scope you need. The changelog summary lists page, view, and component. Read the full argument list in the Perspective component scripting functions section of the Ignition user manual, not the changelog. - Set
documentTitle. The browser uses it as the default file name when the operator saves to PDF. - Save and test in a desktop browser session.
Print a specific container instead of the whole page
requestPrint is a component method, so the component you call it on is the one that gets printed with target='component'. Called on self from a button, it prints the button.
To print a neighboring container, get a reference to that container first:
# onActionPerformed on the button
target_container = self.getSibling('ReportContainer')
target_container.requestPrint(target='component', documentTitle='Line3_Summary')
ReportContainer is a placeholder. Use your container's actual name, and adjust the path if it is not a direct sibling.
Get Scrolled Content onto Paper
Changing target is the fix that wastes the most time. It does not change the viewport. Use one of these approaches instead, listed from least effort to most.
| Approach | How | Use when | Limit |
|---|---|---|---|
| Browser zoom-out | Operator zooms the browser out until the whole view is on screen, then presses Print | One-off prints; content is only slightly taller than the screen | Text shrinks. Depends on the operator doing it every time. |
| Print-specific view | Build a second view laid out to fit one screen, with no scroll container. Navigate to it, then print. | Recurring shift or batch summaries with a fixed layout | Must be maintained next to the live view |
| Paged sections | Split content into sections that each fit the viewport. Print each section with the component target, one at a time. | Long forms or multi-panel screens | One print dialog per section |
| Component-level print | Print only the container that matters with target='component'
|
The operator needs one panel, not the whole screen | That container still clips if it scrolls internally |
| Reporting module output | Generate a paginated document server-side instead of printing the screen | Tables or logs longer than any screen, audit records | Separate design effort. Not a screen capture. |
Tables with internal scrolling behave the same way. Rows below the table's visible area do not print. If the operator needs every row, a screen print is the wrong tool. Use a report.
Verify the Print Path
- Open the view in a desktop browser session, not in the Designer and not in the mobile app.
- Press the button. The browser print dialog should open with the preview already populated.
- Select the browser's save-to-PDF destination. Check that the default file name matches
documentTitle. - Open the PDF. Compare it against the screen, and confirm the scope matches the target you set.
- Scroll the view and print again. The output should change to match the new visible region. If it does, the clipping is the viewport limit, not a script fault.
- Repeat at the screen resolution and browser zoom level the operators actually use. A layout that fits on an engineering monitor can clip on a smaller panel PC.
- If the button does nothing, open the browser developer console and the gateway logs. Look for a script error from the
onActionPerformedhandler before assuming a version problem.
Avoid the Recurring Traps
-
Swapping targets to fix clipping.
page,view, andcomponentchoose the element. None of them extends past the visible area. - Expecting unattended printing. The operator will always see a dialog. Scheduled or event-triggered prints with no user present need a server-side approach, not requestPrint.
- Testing only in the Designer. The feature depends on the browser's print pipeline. Validate in a real browser session.
- Deploying to mobile users. requestPrint works in web browsers only, not mobile. Give mobile users a report or PDF link instead.
-
Calling the method on the wrong object.
selfin a button event is the button. Get a reference to the container you mean to print. - Reading the changelog for arguments. Changelogs summarize changes. The argument list and allowed values are in the user manual's component scripting reference.
- Printing from another tab. The call cannot reach other tabs or anything outside the browser page. Each print runs from the session that owns the content.
Frequently Asked Questions
Why does Perspective requestPrint only print what is visible on the screen?
requestPrint sends the rendered browser viewport to the print dialog. Content below a scroll boundary is not rendered on screen, so it does not print, whether target is page or view. Zoom the browser out, build a print-specific view that fits one screen, or use a report for content longer than a screen.
Why does requestPrint do nothing on my Ignition gateway or in the mobile app?
The method was added in 8.1.28, so older gateways do not have it and need an upgrade. On 8.1.28 or later, it works in web browsers only, not in mobile sessions. Test the same view in a desktop browser to tell the two causes apart.
Why does the browser still ask the user to confirm and pick a printer?
Browsers require the user to confirm any print request and choose the destination. Browsers treat automated printing as malicious. documentTitle sets the default file name, but no Perspective argument skips the dialog.
When should I escalate a requestPrint problem to Inductive Automation support?
Escalate if you are on 8.1.28 or later, testing in a supported desktop browser, and the button still throws a script error or the print dialog never opens. Include the gateway version, browser version, the exact onActionPerformed script, and the matching gateway log entries when you open the case with Inductive Automation support. Viewport clipping of scrolled content is not a support case. It is how the feature works.