# Fumadocs (Framework Mode, Next.js): Export PDF
URL: /docs/next/guides/export-pdf
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/[framework]/guides/export-pdf.mdx

Export docs pages as PDF documents

## Overview [#overview]

In general, we strongly recommend you to download the entire website (HTML files, etc) for offline browsing.

In case if you want to export the page as a PDF, you can follow this guide.

## Setup [#setup]

Use Puppeteer to export PDF files.

```ts title="scripts/export-pdf.ts"
import puppeteer from 'puppeteer';
import fs from 'node:fs/promises';
import path from 'node:path';

const browser = await puppeteer.launch();
const outDir = 'pdfs';
// update this [!code highlight:2]
const urls = ['/docs/ui', '/docs/ui/customizations'];

async function exportPdf(pathname: string) {
  const page = await browser.newPage();
  await page.goto('http://localhost:3000' + pathname, {
    waitUntil: 'networkidle2',
  });

  await page.pdf({
    path: path.join(outDir, pathname.slice(1).replaceAll('/', '-') + '.pdf'),
    width: 950,
    printBackground: true,
  });

  console.log(`PDF generated successfully for ${pathname}`);
  await page.close();
}

await fs.mkdir(outDir, { recursive: true });
await Promise.all(urls.map(exportPdf));
await browser.close();
```

Add the following to your Tailwind CSS file to disable navigation elements when printing:

```css
@media print {
  #nd-docs-layout {
    --fd-sidebar-width: 0px !important;
  }

  #nd-sidebar {
    display: none;
  }
}
```

You can now run the script:

```bash
bun ./scripts/export-pdf.ts
```

### Invisible Contents [#invisible-contents]

For invisible contents in accordions/tabs, you may need to temporarily override the MDX components. For example:

```tsx title="components/mdx.tsx"
import defaultMdxComponents from 'fumadocs-ui/mdx';
import type { MDXComponents } from 'mdx/types';
import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';

// you may use environment variable here [!code highlight:2]
const isPrinting = true;

function PrintingAccordion(props: React.ComponentProps<typeof Accordion>) {
  return (
    <div>
      <h3>{props.title}</h3>
      {props.children}
    </div>
  );
}

function PrintingAccordions(props: React.ComponentProps<typeof Accordions>) {
  return <div>{props.children}</div>;
}

export function getMDXComponents(components?: MDXComponents) {
  return {
    ...defaultMdxComponents,
    // updated accordions:
    Accordion: isPrinting ? PrintingAccordion : Accordion,
    Accordions: isPrinting ? PrintingAccordions : Accordions,
    ...components,
  } satisfies MDXComponents;
}
```