PrintBase
  • Product
  • Pricing
  • Docs
  • Resources
PrintBase/Guides/Printing troubleshooting

Print without a dialog in JavaScript

Browsers will not silently print from a public page. The workable pattern is your backend plus the print API, not a hidden window.print.

For Frontend developers hitting the print dialog

This page in another language: 中文

Overview

window.print() is defined to involve the user. A public page cannot open a USB device, and it cannot rely on calling http://127.0.0.1 to a printer helper. Chrome's private-network protections and certificate rules keep closing that door.

Call your backend with the order id. The backend holds the API key and POSTs /v1/print-jobs. The shop agent prints. The browser renders a job id. That is silent from the guest's point of view because no dialog appears on their laptop, and the paper is somewhere else.

The agent can listen on 127.0.0.1:17891, but the allow-list is localhost and printbase.cloud origins. Your production origin receives 403. Do not ship the API key to get around that.

Integration steps

  1. 01

    Stop calling window.print for this job

    Use it only when the user should pick a printer on their own computer.

  2. 02

    Post the order id to your server

    Not the API key, not the raw printer socket. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.

  3. 03

    Server submits the job

    Bearer token, printer_code, pdf or raw. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.

  4. 04

    Poll status for the operator

    The guest usually does not need the spooler detail. The kitchen display does.

Node.js

// Backend the browser is allowed to call
const res = await fetch('https://api.printbase.cloud/v1/print-jobs', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.PRINTBASE_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': idempotencyKey,
  },
  body: JSON.stringify({
    printer_code: Number(process.env.PRINTER_CODE),
    content_type: 'pdf',
    content: pdf.toString('base64'),
    copies: 1,
  }),
});
if (!res.ok) throw new Error(`PrintBase ${res.status}: ${await res.text()}`);
const job = await res.json();
// { id: "job_abc", status: "queued" }

Details for this setup

Local port

Empty Origin is allowed. localhost, 127.0.0.1, ::1, and printbase.cloud hosts are allowed. Anything else is forbidden.

Kiosk exception

A page served from localhost on the kiosk PC can use the local port. A public kiosk URL should still use the cloud API.

Questions

Can an iframe hide the dialog?

No. The dialog is not a DOM element you can restyle away. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.

What about QZ Tray?

It is a local bridge with its own signing. See the QZ pages. It is not window.print.

Will a Chrome flag fix this?

Do not depend on a user flipping a flag. The server path does not need one.

Is the PDF printed on the user's laptop?

Only if that laptop runs the agent and you targeted its printer. Usually you target the shop.

Related guides

  • Silent printing from browser JavaScript, via your backend

    Browsers will not silently print to a USB device from a public website. Call your backend, and let the backend call the print API.

  • Chrome private network access and localhost printing

    A public HTTPS page calling a localhost printer bridge is what private-network rules restrict. Printing from your server avoids that browser call.

  • QZ Tray alternative without a site certificate

    QZ Tray is free software. Silent printing without its warning dialog needs a certificate. PrintBase never asks the browser to sign a print request.

Free plan: 100 jobs a month on one computer, no card.

Create a free accountRead the API docs
PrintBase

PrintBase connects your applications to physical printers anywhere - securely, reliably, and in real time.

Product
Receipt PrintingLabel PrintingDashboardDevicesWebhooks
Resources
DocsBlogStatusAPI ReferenceDownloadPrintBase vs PrintNodePrintNode PricingFAQ
Guides
All guidesIntegrationsPrintersCode samplesComparisonsUse casesTroubleshooting
Company
ContactSecurityPrivacy

© 2026 Aveniq Technologies OÜ. All rights reserved. PrintBase is a service of Aveniq Technologies OÜ.

PrivacyTermsRefunds