Silent Ant Design tables?
Yes—extract HTML and call printHtml via the local client.
In React + Ant Design or Ant Design Pro admin apps, extract Table / ProTable HTML and call printHtml. See the React guide for basics.
npm install web-print-pdfWrap the table with a ref or build a print-only HTML string; call printHtml from toolbar actions. See print options.
Same Hook pattern as the React guide:
import { useCallback, useState } from 'react';
import webPrintPdf from 'web-print-pdf';
export function useSilentPrint() {
const [loading, setLoading] = useState(false);
const printHtml = useCallback(async (html) => {
setLoading(true);
try {
return await webPrintPdf.printHtml(
html,
{ paperFormat: 'A4', printBackground: true },
{ paperFormat: 'A4', printerName: '默认打印机' }
);
} finally {
setLoading(false);
}
}, []);
return { loading, printHtml };
}
import { useSilentPrint } from './useSilentPrint';
export function OrderPrintButton({ html }) {
const { loading, printHtml } = useSilentPrint();
return (
<button disabled={loading} onClick={() => printHtml(html)}>
{loading ? '打印中…' : '静默打印'}
</button>
);
}
.ant-table-content or use a print template—avoid printing ProLayout chrome.getConnectStatus(); see error handling.ProLayout chrome, ProTable filters, fixed columns, and horizontal scroll are common extra content on paper.
.ant-table-content or a template—not the full layoutYes—extract HTML and call printHtml via the local client.
By default yes—select table DOM or a dedicated template.
react-to-print often uses the browser dialog; web-print-pdf adds silent named-printer output.
By default yes—select table DOM or a dedicated HTML template.
Build-tool agnostic: npm install web-print-pdf and import—TypeScript types built in.
The same web-print-pdf front-end runs on Windows, macOS, and Linux/domestic OS—install the matching client on each desktop.