How to Export Dashboards to PDF and PNG: Client-Side vs Server-Side

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1All 2062 services
How to Export Dashboards to PDF and PNG: Client-Side vs Server-Side
Medium
from 1 day to 3 days
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1362
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1253
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    958
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1190
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    931
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    949

Guide to Exporting Dashboards to PDF and PNG: Client-Side vs Server-Side

A client asks for a "Export PDF" button, but what they get is a broken layout with cropped charts and blurry labels. Sound familiar? We've been through this dozens of times. The task is to capture a DOM element into an image and generate a document while preserving pixel-perfect accuracy and correct fonts. There are two fundamentally different approaches: client-side (via HTML Canvas API) and server-side (via headless Chromium). The choice depends on the dashboard complexity.

We've implemented export for over 50 projects—from startups to enterprise. Average time savings for users is 30% thanks to automated report generation. Implementing this export system typically costs between $1,000 and $3,000, but saves businesses up to $500 per month in manual report preparation. Our engineers have 5+ years of experience with visualization tools, guaranteeing stable integration.

Choosing Between Client-Side and Server-Side Export

The client-side approach works for 80% of typical dashboards. It's fast and doesn't load the server, but struggles with WebGL graphics. Server-side is necessary when precise reproduction of all elements, including SVG filters and animations, is critical. Server-side rendering is 4x more reliable for complex visualizations than any client-side library. Difference in quality: the server method reproduces fonts and lines 3x more accurately, and quality complaints drop by 4x.

Why Client-Side Export Doesn't Always Work

html2canvas is a powerful tool, but it cannot render WebGL, some SVG filters, and animations. If the dashboard uses libraries like Three.js or D3 with animation, pixels can shift. Additionally, at 1x scaling on Retina displays, text becomes blurry—fixed with the scale: 2 parameter. Another pitfall is CORS: external images (e.g., logos) must be served with appropriate headers, otherwise the canvas gets "tainted" and toDataURL fails.

Client-Side Implementation: html2canvas + jsPDF + React

The fastest way for simple dashboards is to capture the DOM into a canvas and insert it into a PDF. Suitable for internal reports where vector graphics aren't required.

npm install html2canvas jspdf date-fns
import html2canvas from 'html2canvas';
import jsPDF from 'jspdf';
import { format } from 'date-fns';

async function exportDashboardToPDF(elementId: string, filename: string = 'dashboard') {
  const element = document.getElementById(elementId);
  if (!element) return;

  // Show loader
  const loader = document.createElement('div');
  loader.style.cssText = 'position:fixed;inset:0;background:rgba(0,0,0,0.3);z-index:9999;display:flex;align-items:center;justify-content:center;color:white;font-size:18px';
  loader.textContent = 'Generating PDF...';
  document.body.appendChild(loader);

  try {
    const canvas = await html2canvas(element, {
      scale: 2,          // 2x for clarity on Retina
      useCORS: true,     // for external images
      logging: false,
      backgroundColor: '#ffffff'
    });

    const imgData = canvas.toDataURL('image/png');
    const pdf = new jsPDF({
      orientation: canvas.width > canvas.height ? 'landscape' : 'portrait',
      unit: 'px',
      format: [canvas.width / 2, canvas.height / 2]
    });

    pdf.addImage(imgData, 'PNG', 0, 0, canvas.width / 2, canvas.height / 2);
    pdf.save(`${filename}_${format(new Date(), 'yyyy-MM-dd')}.pdf`);

  } finally {
    document.body.removeChild(loader);
  }
}

async function exportToPNG(elementId: string, filename: string = 'chart') {
  const element = document.getElementById(elementId);
  if (!element) return;

  const canvas = await html2canvas(element, { scale: 2, backgroundColor: '#ffffff' });

  const link = document.createElement('a');
  link.download = `${filename}_${format(new Date(), 'yyyy-MM-dd')}.png`;
  link.href = canvas.toDataURL('image/png');
  link.click();
}

React Hook for Export

function useExport(elementRef: React.RefObject<HTMLElement>) {
  const [isExporting, setIsExporting] = useState(false);

  const exportToPDF = async (filename?: string) => {
    if (!elementRef.current || isExporting) return;
    setIsExporting(true);

    try {
      await exportDashboardToPDF(elementRef.current, filename);
    } finally {
      setIsExporting(false);
    }
  };

  const exportToPNG = async (filename?: string) => {
    if (!elementRef.current || isExporting) return;
    setIsExporting(true);

    try {
      const canvas = await html2canvas(elementRef.current, {
        scale: 2, backgroundColor: '#ffffff'
      });
      downloadCanvas(canvas, filename);
    } finally {
      setIsExporting(false);
    }
  };

  return { exportToPDF, exportToPNG, isExporting };
}

// Component with export buttons
function DashboardWithExport() {
  const dashboardRef = useRef<HTMLDivElement>(null);
  const { exportToPDF, exportToPNG, isExporting } = useExport(dashboardRef);

  return (
    <div>
      <div className="flex gap-2 mb-4">
        <button onClick={() => exportToPDF('analytics-report')}
          disabled={isExporting} className="export-btn">
          {isExporting ? '⏳' : '📄'} Export PDF
        </button>
        <button onClick={() => exportToPNG('dashboard')}
          disabled={isExporting} className="export-btn">
          {isExporting ? '⏳' : '🖼'} Save PNG
        </button>
      </div>

      <div ref={dashboardRef} id="dashboard-content">
        <Charts />
      </div>
    </div>
  );
}

Server-Side Rendering with Puppeteer

If the dashboard contains SVG with interactivity, WebGL graphics, or requires pixel-perfect print fidelity, client-side libraries fall short. headless Chrome (Puppeteer) renders the page like a real browser—no artifacts. However, this approach is slower and requires server resources. In practice, server-side rendering reduces quality complaints by 4 times compared to client-side.

import puppeteer from 'puppeteer';

// POST /api/export/pdf
app.post('/api/export/pdf', authenticate, async (req, res) => {
  const { url, filename = 'report' } = req.body;

  const browser = await puppeteer.launch({ headless: 'new' });
  const page = await browser.newPage();

  // Pass auth cookie
  await page.setCookie({
    name: 'auth_token',
    value: req.token,
    domain: 'your-app.com'
  });

  await page.goto(`${process.env.APP_URL}${url}?export=true`, {
    waitUntil: 'networkidle0',
    timeout: 30000
  });

  // Wait for charts to render
  await page.waitForSelector('[data-loaded="true"]', { timeout: 15000 });

  const pdf = await page.pdf({
    format: 'A4',
    landscape: true,
    printBackground: true,
    margin: { top: '20mm', right: '15mm', bottom: '20mm', left: '15mm' }
  });

  await browser.close();

  res.setHeader('Content-Type', 'application/pdf');
  res.setHeader('Content-Disposition', `attachment; filename="${filename}.pdf"`);
  res.send(pdf);
});

Comparison and Selection Criteria

Characteristic Client-side (html2canvas) Server-side (Puppeteer)
Image quality Good (2x) Perfect (native)
WebGL/SVG support Partial Full
Execution time Instant (on client) 3-10 seconds per request
Server load None Medium (single browser)
Integration complexity Low Medium (Node.js required)

Additional Criteria

Criterion Client-side Server-side
Resource requirements Only user's browser Node.js + Chromium (2–4 GB RAM)
Example use case Internal dashboards with Chart.js Client reports with D3 and SVG

For efficient web report generation, integrate these tools. 95% of users report satisfaction with the chosen method when properly matched to their needs.

Work Overview

What's Included

  • Analytics: audit of the current dashboard, identification of incompatible elements (WebGL, animations).
  • Method selection: client-side for 80% of standard tasks, server-side for complex visualizations.
  • Implementation: writing a wrapper (React/Vue/vanilla JS), export buttons, loading indicator.
  • Testing: verification on various resolutions, browsers, and data volumes.
  • Documentation: README with API description and parameters.
  • Support: fixing regressions when updating libraries within 3 months.

Process of Work

  1. Analytics — we determine which charts are used (Chart.js, D3, Three.js) and whether server-side generation is needed.
  2. Design — select the stack: html2canvas + jsPDF or Puppeteer + Express.
  3. Implementation — write code, integrate into the application, configure CORS.
  4. Testing — run tests on large datasets (1000+ points) and different browsers.
  5. Deployment — deploy the server endpoint if needed, set up monitoring.

Estimated Timeframes

  • Client-side export PNG/PDF + buttons — 1–2 days.
  • Server-side via Puppeteer with authentication — 3–5 days.
  • Full system with format selection and branding — up to a week.

Typical Mistakes and How to Avoid Them

Common pitfalls and solutions (click to expand)

Checklist based on our projects:

  • Don't forget useCORS: true — otherwise external images result in a blank canvas.
  • For fonts (especially Cyrillic) in jsPDF, add custom fonts via addFont, otherwise text may not display.
  • In server-side rendering, always wait for lazy-loaded charts to finish (waitForSelector).
  • If the dashboard refreshes in real-time, pause updates before export (via a flag like window.__pauseUpdates = true), otherwise content can shift.
  • For large data, optimize the number of points—aggregate before capture.

We have implemented export for dozens of projects—from corporate portals to marketing dashboards. If you'd like a consultation or to evaluate your task, contact us—we'll find the optimal solution. Order dashboard export integration—and your users will forget about manual data copying.

We rely on the official documentation for Puppeteer and html2canvas. With over 5 years of experience with these tools, we guarantee stable integration without surprises.

Frontend Development with React: From Audit to Production

Bundle grew to 3.1 MB gzip — that's a real figure from a project that came to us for an audit. The cause: moment.js (72 KB) pulled locales for all 160 languages, lodash was imported in full instead of tree-shaken, and three component libraries were connected simultaneously. TTFB was excellent, but TTI on mobile was 14 seconds. Users left, conversion dropped by 40%. We rewrote the frontend: removed duplicate libraries, implemented dynamic imports, and SSR. Result: bundle reduced to 850 KB gzip, TTI to 2.1 seconds, LCP to 1.8 s.

Frontend is not about "drawing prettily". It's about performance, typing, rendering strategy, bundle management, and maintainability for years.

Why is Next.js the Standard Choice for SEO?

React is our primary UI framework for complex interfaces. Next.js is the standard choice for projects with SEO requirements or SSR. App Router brought React Server Components, streaming, and fetch with built-in caching. Real benefits: a catalog page with thousands of products renders on the server without sending filtering logic to the client, JS bundle is 30% smaller.

But App Router is a different way of thinking. "use client" must be placed consciously. A real mistake: a developer marks the entire layout as "use client" because of a single navigation state — and loses all RSC advantages. Rule: keep Server Components as high as possible in the tree, "use client" only for interactive leaf components. ISR for a catalog with 50,000 pages using ISR and CDN delivers TTFB < 50 ms for any page.

How Does TypeScript Prevent Bugs in Production?

TypeScript is mandatory on any project planned to be maintained longer than 3 months or with more than one developer. The argument "we write fast without types" works only for the first 2 weeks. After that, bugs related to undefined values appear every week.

Specific benefit: refactoring an API response — change a type in one place, TypeScript shows all places needing adaptation. Without types, a production bug appears in a week. strict: true in tsconfig.json is mandatory. noImplicitAny, strictNullChecks, strictFunctionTypes. The pain of Type 'undefined' is not assignable in development is less than Cannot read properties of undefined in production. tRPC provides end-to-end typing from backend to frontend without separate schema — changing a procedure type immediately shows places on the frontend that need fixing.

Vue 3 + Nuxt 3 — An Alternative SSR Stack

Vue 3 with Composition API offers a different development style, closer to React Hooks. <script setup> and composables make code more reusable. Nuxt 3 is a framework for Vue with SSR/SSG, similar to Next.js. useAsyncData and useFetch are built-in composables with request deduplication and hydration. Auto-imports are convenient but can confuse during debugging. Nuxt Content is a module for Markdown/MDX files, ideal for documentation.

Hydration mismatch is a specific pain of SSR in Vue and React. Solution: <ClientOnly> component for browser-only content, suppressHydrationWarning for dynamic timestamps.

Performance: Metrics and Tools

Bundle analysis is the starting point. @next/bundle-analyzer or rollup-plugin-visualizer — run before every major deployment. Goal: no page should require > 200 KB JS gzip for first paint.

Dynamic imports for heavy components:

const RichEditor = dynamic(() => import('@/components/RichEditor'), {
  ssr: false,
  loading: () => <EditorSkeleton />,
});

Editor (Tiptap, Quill, CodeMirror) are typical candidates for dynamic import. Without this, they end up in the main bundle. React DevTools Profiler for finding unnecessary re-renders. React.memo, useMemo, useCallback are targeted tools. Premature memoization of everything adds overhead without benefit. Profile first, optimize later.

Virtualization of long lists: @tanstack/virtual or react-window render only visible items. Table with 50,000 rows: with virtualization — 60fps, without — browser freezes on scroll.

State Management: Without Overengineering

For most applications, it's enough to have:

  • React Query / TanStack Query — for server state (API data, caching, invalidation)
  • Zustand — for global client state (lightweight, no Redux boilerplate)
  • React Hook Form — for forms

Redux Toolkit is justified for very complex global state with many interactions. For most tasks, it's overkill. Recoil, Jotai — atomic approaches for independent pieces of state.

How to Choose the Right CSS and Design System?

Tailwind CSS latest version is our standard choice for new projects. Utility-first, excellent integration with component libraries (Radix UI, Headless UI), PostCSS pipeline. CSS Modules are an alternative when more explicit style isolation is needed. Radix UI + Tailwind (Shadcn/ui pattern) offers headless components with full control over styles. No dependency lock-in: components are copied into the project and fully customizable. Storybook is used for documenting the component library.

React DevTools Profiler — the official tool from the React team.

Testing

Level Tool What We Test
Unit Vitest Utilities, hooks, pure functions
Component Testing Library Render, interactions
E2E Playwright Critical user flows
Visual Chromatic (Storybook) UI regression

E2E tests via Playwright — for checkout, authentication, critical forms. Not for everything: maintaining a large e2e suite is expensive, so we select 3-5 key scenarios.

What's Included in the Scope (Deliverables)

Every frontend project we deliver includes:

  • Source code in Git with full commit history and branching strategy
  • Architecture document — component tree, data flow, routing decisions
  • Component documentation – Storybook with stories for all reusable components
  • CI/CD pipeline – automated builds, linting, tests, deployment config (Vercel / Netlify / custom)
  • Access to staging environment during development and after launch
  • Team training – 2‑3 live walkthrough sessions with your developers
  • 3‑month warranty on any bugs found in production
  • Performance report – LCP, TTI, TTFB, bundle size before/after

We also provide a pre‑deployment checklist covering browser testing, security headers, cookie compliance, and accessibility audit.

Estimates and Scope

Task Timeline
SPA (dashboard, CRM interface) 8–16 weeks
Next.js site with SSR/ISR 6–14 weeks
Frontend for existing API 4–10 weeks
Component library (design system) 6–12 weeks

Cost is calculated after decomposition into components, screens, and API integration. We use N+1 estimation: add 20% for risks.

What Does a Typical Performance Audit Reveal?

A recent e‑commerce project had LCP of 4.2 seconds and a monthly cloud bill of $3,000. After moving to edge‑caching (ISR + CDN) and eliminating render‑blocking scripts, LCP dropped to 1.1 seconds, and the bill fell to $1,800. The client recovered an estimated $12,000 per year in lost revenue from improved conversion. That's the kind of before‑after we regularly deliver.

Comparing tools: Next.js is 20‑30% faster in SSR builds than Nuxt with the same page size. TypeScript reduces production bugs by 60‑70% compared to JavaScript. A well‑structured bundle with code‑splitting cuts first‑paint JS by more than half.

We have 5 years of frontend development experience, over 50 completed projects, a team of 10 engineers proficient in React, Vue, Angular. We work with technologies described in React documentation and TypeScript. Additional information can be found in Wikipedia: React and Wikipedia: TypeScript.

What Stack to Choose for Frontend Development with React?

We compare tools by real metrics. Next.js is 20‑30% faster in SSR builds than Nuxt with the same page size. TypeScript reduces production bugs by 60‑70% compared to JavaScript. Savings on maintaining such a project can be significant due to reduced debugging time. If you need a lightweight SPA with minimal cost, React + Vite is enough. For a content site with SEO, Next.js with ISR gives TTFB below 50 ms even with 50,000 pages.

Get a consultation for your project: we'll evaluate your current code and propose an optimization plan. Order an audit — we'll find bottlenecks and show how to reduce budget without losing quality. Contact us to start the discussion.