For a page your application is authorized to render, use Playwright for Java with Chromium: navigate to an approved URL, wait for an application-specific ready condition, then call Page.pdf() and securely handle the returned bytes. A browser-generated PDF is a snapshot of rendered content—not an official bank statement or transaction record unless the bank explicitly treats it as one. For customer-specific pages, use the bank’s approved authentication and data-handling design; do not bypass login, MFA, access controls, or export restrictions.
Before you generate a banking-portal PDF
First establish what the PDF is for and whether the application is authorized to access and render the page. A public information page, an internal authorized view, and a customer’s account page have different security and privacy implications. If someone needs an authoritative statement, receipt, or transaction record, use the bank’s own export workflow.
For any customer-specific content, have the bank approve the authentication flow, deployment, storage destination, access controls, and retention period. Do not hard-code customer credentials, share browser sessions between customers, or log rendered account details. Keep navigation restricted to approved destinations and avoid sending sensitive page content to an unapproved third-party service.
The RBI’s Digital Payment Security Controls address secure-by-design practices, threat modelling, application lifecycle security objectives, and security testing for covered entities and applications. The RBI IT Services Outsourcing Direction, dated April 10, 2023, addresses matters including provider monitoring, confidentiality of customer information, need-to-know access, incident reporting, and data-storage terms where applicable. The bank’s compliance and security teams must determine which requirements apply to a particular portal and deployment, including whether a rendering or storage provider is an outsourcing arrangement.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsSet up Playwright Java and Chromium
Playwright Java is distributed as Maven modules. Its installation documentation lists Java 8 or higher as a system requirement; for production, use a Java and browser combination supported by your environment and install the matching Playwright browser runtime. PDF generation in this workflow is Chromium-specific, so use Chromium even though Playwright supports other browser engines. Follow the current Playwright Java installation guide for the dependency and browser installation steps.
The example below is a standalone Java entry point for an approved page. Configure APPROVED_PAGE_URL, APPROVED_HOST, and READY_SELECTOR in the application environment. The host check is a basic allowlist guard; adapt it to the bank’s routing, proxy, and network policy. This sample deliberately does not implement authentication: integrate only the institution-approved session and MFA flow rather than adding credentials to the code.
Rank #2
Generate the PDF
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserContext;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
public class PortalPdf {
public static void main(String[] args) throws Exception {
String url = requiredEnv("APPROVED_PAGE_URL");
String approvedHost = requiredEnv("APPROVED_HOST");
String readySelector = requiredEnv("READY_SELECTOR");
Path output = Path.of(args.length == 0 ? "page.pdf" : args[0]);
URI uri = URI.create(url);
if (!"https".equalsIgnoreCase(uri.getScheme())
|| uri.getHost() == null
|| !uri.getHost().equalsIgnoreCase(approvedHost)) {
throw new IllegalArgumentException("URL is not on the approved HTTPS host");
}
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch();
try {
BrowserContext context = browser.newContext();
try {
Page page = context.newPage();
page.navigate(url, new Page.NavigateOptions()
.setWaitUntil(com.microsoft.playwright.options.WaitUntilState.DOMCONTENTLOADED));
page.locator(readySelector).waitFor();
byte[] pdf = page.pdf(new Page.PdfOptions()
.setFormat("A4")
.setPrintBackground(true)
.setPreferCSSPageSize(true));
Files.write(output, pdf);
} finally {
context.close();
}
} finally {
browser.close();
}
}
}
private static String requiredEnv(String name) {
String value = System.getenv(name);
if (value == null || value.isBlank()) {
throw new IllegalStateException("Set the " + name + " environment variable");
}
return value;
}
}
Run it with the configured environment and an optional output path, for example java PortalPdf account-page.pdf. The Java class assumes Playwright is on the application’s classpath and Chromium has been installed for that Playwright version. Use a readiness selector that only appears when the intended content is ready; a generic fixed sleep can finish too early or waste time. Before writing the result to persistent storage, apply the bank’s approved permissions, encryption, retention, and temporary-file controls.
Choose print behavior deliberately
Playwright documents that page.pdf() generates a PDF using print CSS media and returns PDF bytes. Its defaults and options can affect the result, so check the API for the deployed library version at the Playwright Java Page API.
Free tools Windows power users keep installed
One-click scans. No signup required.
- Paper and margins: Set a paper format such as A4 and explicit margins when the output must follow a known document layout. The API also supports page ranges and scale.
- Backgrounds: Background graphics are off by default. Enable
setPrintBackground(true)only when the intended output needs them. - CSS page sizing: CSS page size does not take priority by default.
setPreferCSSPageSize(true)lets the page’s@pagerules govern sizing when that is the desired behavior. - Screen-styled pages: If the portal’s screen stylesheet is required instead of print styling, emulate screen media before calling
page.pdf(). Confirm the API method for the library version you deploy. - Tags and outlines: The API exposes tagged-output and document-outline options, but tagged output is off by default. Setting a flag alone does not demonstrate accessibility conformance.
Validate output and protect customer data
Test representative pages in a non-production or otherwise approved environment. Check page breaks, clipping, fonts and language glyphs, dynamic content, and whether the generated document includes the expected page—not a login redirect, error page, or partially loaded view. Validate accessibility against the requirements for the document’s intended audience and use. An Indian government document describes processes and observations for accessible PDFs on government websites; it is contextual guidance, not proof that a portal PDF meets a specific requirement: Accessible PDF process document.
Monitor failures using status and timing information rather than sensitive page text. Restrict access to generated files, control their retention, and ensure diagnostic output and temporary files do not expose account data. If the workflow uses outsourced rendering or storage, have the bank assess the arrangement against current RBI obligations and internal policy before deployment.
Rank #4
Troubleshoot common failures
- The browser does not start: Confirm the Playwright Java dependency and matching Chromium runtime are installed in the deployment environment. Verify that the runtime has the required operating-system dependencies and permitted execution resources.
- The PDF is blank or incomplete: Replace a fixed delay with a selector or other application-specific ready condition. Check that the selector belongs to the intended view and that navigation did not land on a login page, error, or redirect.
- Navigation fails or reaches the wrong page: Check the configured URL, DNS and network access, TLS trust, redirects, and host allowlist. Do not relax URL restrictions to make an unknown destination load.
- Colors, page size, or layout differ: Review print CSS, background settings, margins, and CSS page-size preference. If the portal is designed for screen media, emulate screen media before PDF generation and compare the result.
- Text is clipped or glyphs are missing: Check print styles, page breaks, scale, and whether required fonts are available in the browser environment. Validate the actual output for the languages used by the portal.
- Output is inaccessible or not an official record: A tagged-PDF setting is not a conformance test, and browser rendering does not confer official status. Use the bank’s export process when an authoritative record is required, and validate accessibility separately.
Or skip the browser setup
For an approved public or otherwise non-sensitive page, ScreenshotNeo offers a screenshot API and MCP server. Its cleanup options accept cookie and consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. AI agents can use its MCP server tools, including take_screenshot, get_page_info, and capture_pdf. Do not send customer-specific banking content unless the bank has approved that service and its data handling for the use case.
The one-call example below saves a WebP screenshot image, not a PDF; see the ScreenshotNeo documentation for the PDF request options before using it for a PDF workflow.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo’s free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up free for 1,000 screenshots a month with no card.
Quick Recap
Best Value
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.

