Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use Pega’s built-in HTMLToPDF capability to turn controlled HTML or a Pega HTML stream into PDF bytes. You can then display those bytes to a user, offer a download, or attach the PDF to a case or work object. Pega documentation also describes pyViewAsPDF for creating or viewing a PDF from an HTML rule or stream. Because activity names, parameters, CSS handling, and output properties vary by Pega Platform release, verify the exact configuration in the activity and documentation installed with your target system.
What the Pega HTML-to-PDF flow does
The conversion is a server-side print-rendering operation, not a screenshot of the browser window. Your application resolves HTML, applies the supported styles, and invokes the PDF activity. The result is binary PDF data that another step must deliver.
- Choose the source: purpose-built printable HTML, a Pega HTML rule/stream, or selected section content.
- Resolve application data: populate values, repeaters, tables, and conditional sections in the request context.
- Convert: pass the HTML source and the release-appropriate options to
HTMLToPDF(or thepyViewAsPDFflow). - Deliver: stream the bytes for viewing or download, or persist them as an attachment.
- Validate: test pagination, fonts, images, tables, and long real-world records in the exact environment where the feature will run.
Plan the PDF as a print document. Interactive browser behavior, dynamic layout groups, and every screen-only style should not be assumed to survive conversion.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesChoose the right source HTML
Purpose-built printable HTML
Create a document-oriented template with explicit headings, tables, page-break rules, and a footer. This is usually the most predictable option for invoices, reports, correspondence, and case summaries because you control the markup independently of the interactive view.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
A Pega HTML rule or stream
A rule or stream can centralize the template and allow Pega expressions and application data to be resolved before conversion. Treat community examples that include sections inside an HTML rule as techniques to validate, not universal recipes. Confirm the syntax, rule availability, and processing context in your release.
Selected section content
Reusing a section avoids duplicating markup, but screen-oriented sections often contain responsive grids, controls, dynamic layout groups, or JavaScript that have no useful print representation. Create a print variant when the screen section is not already document-friendly.
Prepare a printable template
Keep the HTML self-contained where possible. Use absolute or application-resolvable URLs for images, provide text alternatives, and avoid relying on client-side JavaScript to insert essential content after the conversion starts.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →<html>
<head>
<meta charset="utf-8">
<style>
@page { size: A4; margin: 18mm 15mm 20mm; }
body { font-family: Arial, sans-serif; font-size: 10pt; color: #222; }
h1 { font-size: 18pt; margin: 0 0 8mm; }
h2 { font-size: 12pt; margin: 7mm 0 3mm; }
table { width: 100%; border-collapse: collapse; page-break-inside: auto; }
thead { display: table-header-group; }
tr { page-break-inside: avoid; }
th, td { border: 0.2mm solid #888; padding: 2mm; vertical-align: top; }
.page-break { page-break-before: always; }
</style>
</head>
<body>
<h1>Case summary</h1>
<p>Case: <span>{case id}</span></p>
<h2>Details</h2>
<table>
<thead><tr><th>Field</th><th>Value</th></tr></thead>
<tbody><tr><td>Status</td><td>{status}</td></tr></tbody>
</table>
</body>
</html>
Replace the brace-delimited values with the expressions or resolved properties used by your application. Escape untrusted text before inserting it into HTML, and do not allow user-supplied markup to become executable template code.
Rank #2
Configure HTMLToPDF in Pega
The exact parameter names and storage properties are release-sensitive. Open the built-in activity in your deployed Pega version and map its documented inputs rather than copying a parameter list from an older example.
- Resolve the source stream. Build the final HTML rule or stream after all case data, localization, and conditional content are available.
- Invoke
HTMLToPDF. Supply the HTML source/stream and enable the documented CSS option when your version requires it. If your release exposes a stylesheet or skin input, provide the print stylesheet there. - Capture the output bytes. Store the returned PDF in the activity’s documented output property or binary page. Do not treat a temporary page as durable storage until you have copied it to the appropriate attachment or content object.
- Handle errors explicitly. Check the activity status and logs before sending a response. A successful activity invocation does not prove that every image, font, or page rendered correctly.
- Deliver the result. Use the release-appropriate view/download action, or pass the bytes to the attachment mechanism used by your case type.
Pega’s documentation describes pyViewAsPDF as a workflow for generating or viewing a PDF from an HTML rule or stream. Use it when your application needs the built-in view behavior; use the lower-level conversion activity when you need to control storage and delivery yourself.
View, download, or attach the PDF
| Outcome | When to use it | Implementation check |
|---|---|---|
| View in the application | A user needs a quick preview or print action. | Use the view action or pyViewAsPDF flow supported by your release and confirm browser download behavior. |
| Download | The caller needs a local copy or an API response. | Return the binary PDF with the correct content type and a safe filename; verify that large files are streamed rather than held in multiple memory copies. |
| Attach to a case | The document must follow the work object’s audit and retention lifecycle. | Use the attachment activity or service supported by your case type, then verify permissions, versioning, and cleanup of temporary files. |
Creating the PDF and delivering it are separate concerns. A conversion that succeeds can still produce no user-visible document if the output page is not passed to a view, download, or attachment step.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCSS, layouts, and pagination
Use print-oriented layouts
Pega Platform 8.5 documentation states that dynamic layout groups are unsupported for HTMLToPDF and recommends free-form or smart layouts for printable forms. A responsive screen can therefore need a dedicated print layout. Keep related labels and values together, repeat table headers, and add explicit page breaks before major sections.
Rank #3
Know how styles are supplied
The 8.5 guide says the application skin CSS is applied by default and describes enabling CSS use and supplying a stylesheet for customization. The controls and property names differ by release, so inspect the activity and current help for your system. Do not assume a screen theme, generated class, or client-side stylesheet is available to the server renderer.
Design for imperfect page breaks
- Use conservative margins and font sizes; a small width change can push a column onto another page.
- Set table widths deliberately and avoid very long unbroken strings.
- Use
thead { display: table-header-group; }where supported so headings repeat. - Keep rows together with
page-break-inside: avoid, but test because complex nested tables may override it. - Provide a fallback for missing images and fonts so the document remains understandable.
The output is a print layout, not a pixel-faithful copy of the interactive UI. Validate the visual result at the page size and orientation your users will actually print.
Section-inclusion and HTML-rule techniques
Some Pega community examples build an HTML rule that includes selected sections, then send that stream to PDF conversion. This can be useful for a report assembled from reusable fragments, but verify each include in your target release. Check that:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
- the section is available in the server execution context;
- all referenced properties are present and authorized;
- the generated markup is valid and does not depend on browser JavaScript;
- the resulting CSS is included in the conversion request; and
- repeated sections do not create invalid nested tables or duplicate IDs.
HTML rules have had changing guidance across Pega 8.x releases. Treat forum statements about deprecation or “compact” PDF styles as release-specific advice, not as a substitute for current product documentation.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Troubleshoot common failures
Missing line breaks or collapsed rich text
Support guidance identifies defective custom CSS as one possible cause. Inspect the generated HTML first, then remove conflicting rules and test with the application’s documented compact or preprocessing options if your release exposes them. Confirm that those options are supported in your version; an older parameter table applies to Pega Platform 8.2 and earlier.
Table borders or cells disappear
Check that borders are defined on the table, header, and cell elements rather than only on a screen wrapper. Simplify nested tables, set explicit widths, and test the compact-styling or HTML-preprocessing settings documented for your release. Do not copy 8.2-and-earlier defaults into an 8.3-or-later system without confirmation.
Blank PDF
Log the final HTML stream before conversion (without exposing sensitive data), verify that the stream is non-empty, and ensure the activity is running with the expected user and rule context. A section that renders in a browser may still be empty when server-side conditions or permissions differ.
Free tools Windows power users keep installed
One-click scans. No signup required.
Images or fonts are missing
Use resolvable URLs or embedded resources available to the server renderer. Check authentication, relative paths, content types, and network access from the Pega node. Supply fallback fonts and alt text so the document remains usable when an asset cannot load.
Best Value
Pages are cut off or columns overflow
Reduce fixed widths, switch to landscape where appropriate, simplify nested layout structures, and test with the longest realistic values. A layout that works with sample data can fail when translations, long names, or rich text are introduced.
Parameters from an old example do not work
Pega Support’s troubleshooting material explicitly labels its parameter list as for Platform 8.2 and earlier and directs users to newer help for 8.3 and later. Treat historical support threads and community answers as diagnostic leads only, and check the activity definition shipped with your release.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Performance, reliability, and security
- Control input size: large case histories, high-resolution images, and deeply nested tables increase rendering time and memory use. Generate only the sections the document needs.
- Queue long jobs: for large reports, use the asynchronous processing pattern already supported by your application rather than blocking an interactive request.
- Make output deterministic: freeze locale, timezone, number/date formats, and data snapshots before conversion so a retry does not produce a different document.
- Protect sensitive content: authorize the generation and attachment actions, avoid logging full HTML or PDF bytes, and remove temporary files according to your retention policy.
- Test failure paths: exercise missing images, denied resources, empty data sets, oversized fields, concurrent requests, and node restarts.
- Verify after upgrades: rendering engines, CSS support, and activity parameters can change with a Pega release. Keep representative PDF fixtures for visual regression checks.
Which approach should you choose?
| Approach | Best fit | Main trade-off |
|---|---|---|
Built-in HTMLToPDF or pyViewAsPDF |
Controlled HTML or a Pega stream that must become a case document. | Exact parameters, CSS behavior, and output handling must be checked in the deployed release. |
| Generate from selected sections | Reports that reuse application content. | Screen styling may not carry over; community techniques require validation. |
| View or download | Short-lived user access. | You must implement response headers, permissions, and lifecycle behavior. |
| Attach to a work object | Audited, durable case records. | Storage, retention, access control, and duplicate-generation rules become part of the design. |
Or skip the browser setup
If the input is a public or externally reachable webpage rather than a Pega server-side HTML stream, ScreenshotNeo provides a one-call capture API and an MCP server for AI agents. It can return a screenshot or PDF without you maintaining a headless-browser service. Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status.
For a direct request, see the ScreenshotNeo API documentation:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo also exposes tools named take_screenshot, get_page_info, and capture_pdf through MCP clients such as Claude and Cursor. Its options include full-page capture with lazy-image loading, CSS-selector element capture, dark mode, device and viewport presets, retina scale, PDF paper settings and page ranges, custom CSS and JavaScript, click and wait conditions, request blocking, headers, cookies, user agent, authorization, timezone, geolocation, transparent backgrounds, resizing, configurable caching, signed links, asynchronous webhooks, bulk capture, usage reporting, and an OpenAPI specification. Every plan includes every feature. The Free plan provides 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
Validate before production
- Record the target Pega Platform release and the exact activity/rule configuration.
- Generate PDFs from short, long, multilingual, and rich-text records.
- Inspect page breaks, repeated headers, images, fonts, links, and file metadata.
- Test view, download, and attachment paths under real permissions.
- Repeat the suite after Pega upgrades or stylesheet changes.
Frequently Asked Questions
Does HTMLToPDF reproduce the Pega browser screen exactly?
No. It creates a print layout from the resolved HTML and supported CSS. Interactive behavior and unsupported layout constructs can differ from the browser UI.
Should I use a community parameter list for my current Pega version?
Use it only as a troubleshooting lead. Support material labels some parameter tables as applying to Pega Platform 8.2 and earlier, so verify every option in the activity and documentation for your deployed release.
Can the generated PDF be attached automatically?
Yes, after conversion you can pass the PDF bytes to the attachment mechanism used by your case type. Configure permissions, retention, and duplicate-generation handling separately from the conversion step.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

