October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Convert a React Page to PDF with DocRaptor

DocRaptor converts HTML or a reachable page URL—not React component objects—to PDF. Enable JavaScript for React, wait for async work, and check assets and print styles.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To convert a React page with DocRaptor, send HTML or a reachable page URL to the DocRaptor API and enable its JavaScript rendering option so React can run. React components themselves are not API input. Make sure rendering and asynchronous data work have finished, the page’s assets can be reached, and its print styles produce the layout you want.

What DocRaptor needs from a React page

DocRaptor accepts either HTML/XML in document_content or a page address in document_url. Your application must make the finished document available in one of those forms; you cannot send a React component object and expect DocRaptor to render it. DocRaptor’s standard JavaScript engine supports React, but JavaScript is disabled by default. See DocRaptor’s JavaScript documentation and API reference.

As an Amazon Associate I earn from qualifying purchases.

For a public application, the usual flow is to generate the PDF on your server. The server authenticates with DocRaptor, submits the document, and returns the PDF bytes to the browser. This keeps the account API key out of publicly served React code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose HTML content or a document URL

Input Use it when Check before converting
document_content Your server has assembled the HTML for the report or page. Make sure linked stylesheets, images, fonts, and scripts have resolvable URLs. Set a base URL when relative paths need one.
document_url DocRaptor can retrieve the document from an address accessible to it. The page must be reachable to DocRaptor, and any access or authentication requirements must be accounted for.

When supplying content directly, relative references may need absolute URLs, a <base> element, or prince_options.baseurl. A leading slash resolves from the domain root, which may not be the directory you intended. The API reference describes the input and base URL options.

#1 Best Overall
PDF Converter Ultimate - Convert PDF files into Word, Excel, PowerPoint and others - PDF converter software with OCR recognition compatible with Windows 11 / 10 / 8.1 / 8 / 7
  • Convert your PDF files into Word, Excel & Co. the easy way
  • Convert scanned documents thanks to our new 2022 OCR technology
  • Adjustable conversion settings
  • No subscription! Lifetime license!
  • Compatible with Windows 11, 10, 8.1, 7 - Internet connection required

Generate the PDF from a server-side route

The request below shows the essential request shape in Node.js. It is an implementation sketch, not a complete authentication sample: configure the authentication method for your server-side DocRaptor request as described in the API reference. The html value must contain the complete document content and styles needed for conversion.

const response = await fetch("https://api.docraptor.com/docs", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    // Add DocRaptor authentication for this server-side request.
  },
  body: JSON.stringify({
    type: "pdf",
    document_content: html,
    javascript: true,
    test: true
  })
});

if (!response.ok) {
  throw new Error(`PDF generation failed: ${response.status}`);
}

const pdfBytes = await response.arrayBuffer();

In a real route, send pdfBytes to the browser with a PDF content type and handle the response as binary data. Generation errors may return XML rather than PDF bytes, so do not treat every response body as a valid PDF. The official API overview describes the response modes: synchronous generation returns PDF bytes, hosted document mode returns a public URL, and asynchronous generation returns a status_id for later retrieval.

Rank #2
Doxillion Free Document Converter – Converts DOCX, DOC, PDF, WPS and Many More Files Quickly [Download]
  • Convert over 50 document file formats.
  • Preview your files from Doxillion before converting them.
  • Use batch conversion to convert thousands of files at once.
  • Enjoy an easy-to-use, intuitive interface with a Drag and Drop file option.
  • Burn your converted or original files directly to disc.

The example sets test: true for development. Test-mode PDFs are watermarked. Check the current API reference for test-mode and account terms before relying on them in production.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enable JavaScript and wait for React to finish

Set the standard API option javascript to true when the page needs React execution. Without it, content created only after JavaScript runs may be absent. DocRaptor’s JavaScript Execution documentation says JavaScript is disabled by default.

Rank #3
PDF Extra Ultimate | Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Yearly License | 1 Windows PC & 2 Mobile Devices | 1 User
  • EDIT text, images & designs in PDF documents. ORGANIZE PDFs. Convert PDFs to Word, Excel & ePub.
  • READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.
  • CREATE, COMBINE, SCAN and COMPRESS PDFs
  • FILL forms & Digitally Sign PDFs. PROTECT and Encrypt PDFs
  • 1 Year License for 1 Windows & 2 Mobile (Android and/or iOS) devices.

Account for data loaded after the initial page

If React fetches report data or performs other delayed work, the renderer may decide the page is ready before that work completes. Use the documented rendering delay or completion controls for your case, then verify the PDF with realistic data. For the standard engine, DocRaptor documents docraptorJavaScriptFinished() as a function that should report whether JavaScript work has finished. Consult the JavaScript documentation and API reference for the relevant settings.

Choose one JavaScript engine deliberately

DocRaptor generally recommends its standard JavaScript engine for typical React rendering. Its separate Prince JavaScript engine is intended for needs such as Prince-specific PDF scripting or canvas support. Prince is not a modern web browser, and its JavaScript behavior can differ from browser behavior. Avoid enabling both engines casually: the API reference warns that both can execute all JavaScript twice. See JavaScript Execution and the API reference.

Rank #4
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
  • Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.
  • EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
  • READ and Comment on PDFs – Intuitive reading modes & document commenting and mark up tools!
  • CREATE, COMBINE, SCAN and COMPRESS PDFs.
  • FILL forms & Digitally Sign PDFs. Work with Digital certificates

Make assets and print styles PDF-ready

Use reachable stylesheets, fonts, images, and scripts

Every asset needed by the document must be accessible to DocRaptor. With HTML content, use absolute URLs or configure a base URL when relative paths would otherwise resolve incorrectly. With a document URL, check that linked assets are reachable in the same conversion context.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check print media and page layout

DocRaptor applies print media rules by default. A page designed for screen display may therefore look different in the PDF. Review @media print styles, page size, margins, and page-break behavior. Use screen media only when the document is intentionally styled for that output. The API overview documents media behavior; its print production example demonstrates CSS @page features.

Best Value
Doxillion Free Document Converter for Mac – Converts DOCX, DOC, PDF, WPS and Many More Files Quickly [Download]
  • Convert over 50 document file formats.
  • Preview your files from Doxillion before converting them.
  • Use batch conversion to convert thousands of files at once.
  • Enjoy an easy-to-use, intuitive interface with a Drag and Drop file option.
  • Burn your converted or original files directly to disc.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep the API key out of public React code

Do not embed a private DocRaptor API key in a client-side bundle. DocRaptor’s tutorial warns that its browser-side JavaScript library exposes the key in page source and recommends server-side use or referrer-based documents for public pages.

A server-side route is the straightforward choice when the application controls PDF generation. DocRaptor also documents a referrer-based route for configured domains; it requires allowed-domain setup and should not be treated as a general replacement for server-side authorization. See referrer-based documents.

Troubleshoot blank or incorrect PDFs

  • React content is missing: Confirm that javascript: true is set and that you are using the intended engine.
  • Data is missing or stale: The page may have been converted before asynchronous work finished. Configure the documented delay or completion signal and verify the result with realistic data.
  • Images, fonts, or styles are missing: Check that asset URLs are reachable and that relative paths have the correct base URL.
  • The layout differs from the browser: Review print-specific CSS, since print media is the default, and inspect page size, margins, and page breaks.
  • JavaScript runs twice: Check whether both the standard JavaScript option and Prince’s JavaScript option are enabled.
  • The browser exposes your API key: Move the request to a trusted server route, or use the documented referrer-based configuration where appropriate.
  • Your code cannot parse the response as a PDF: Check the HTTP status and response body. Generation errors may be XML; asynchronous and hosted modes return different result forms from synchronous PDF generation.

Or skip the browser setup

For a screenshot of a rendered page rather than a DocRaptor PDF, ScreenshotNeo offers a one-request website screenshot API. Use the following cURL example with your API key and target URL; see the ScreenshotNeo documentation for options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server lets AI agents take screenshots, and the Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month with no card.

Frequently Asked Questions

Can DocRaptor accept a React component directly?

No. It accepts HTML/XML content or a document URL; your application must make the rendered document available in one of those forms.

Does DocRaptor return PDF bytes for every request?

No. Synchronous generation returns PDF bytes; hosted-document and asynchronous modes return a URL and a status ID, respectively.

Quick Recap

Bestseller No. 1
PDF Converter Ultimate - Convert PDF files into Word, Excel, PowerPoint and others - PDF converter software with OCR recognition compatible with Windows 11 / 10 / 8.1 / 8 / 7
PDF Converter Ultimate - Convert PDF files into Word, Excel, PowerPoint and others - PDF converter software with OCR recognition compatible with Windows 11 / 10 / 8.1 / 8 / 7
Convert your PDF files into Word, Excel & Co. the easy way; Convert scanned documents thanks to our new 2022 OCR technology
Bestseller No. 2
Doxillion Free Document Converter – Converts DOCX, DOC, PDF, WPS and Many More Files Quickly [Download]
Doxillion Free Document Converter – Converts DOCX, DOC, PDF, WPS and Many More Files Quickly [Download]
Convert over 50 document file formats.; Preview your files from Doxillion before converting them.
Bestseller No. 3
PDF Extra Ultimate | Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Yearly License | 1 Windows PC & 2 Mobile Devices | 1 User
PDF Extra Ultimate | Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Yearly License | 1 Windows PC & 2 Mobile Devices | 1 User
READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.; CREATE, COMBINE, SCAN and COMPRESS PDFs
$83.88
Bestseller No. 4
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.; EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
$99.99
Bestseller No. 5
Doxillion Free Document Converter for Mac – Converts DOCX, DOC, PDF, WPS and Many More Files Quickly [Download]
Doxillion Free Document Converter for Mac – Converts DOCX, DOC, PDF, WPS and Many More Files Quickly [Download]
Convert over 50 document file formats.; Preview your files from Doxillion before converting them.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.