ScreenshotNeo

BlogHow-to

How to Convert a Shopify Product Page to PDF with PDFShift

Convert a public Shopify product page URL to PDF with PDFShift. Get runnable cURL, Python, and Node.js examples, plus layout tips and troubleshooting.

By the ScreenshotNeo team4 October 20267 min read

To convert a Shopify product page to PDF with PDFShift, send the page’s public URL as the source to PDFShift’s v3 conversion endpoint, authenticate with your API key in the X-API-Key header, and save the response body as a PDF. This is a URL-to-PDF API workflow, not a Shopify-specific app or a guarantee that every storefront page will render identically. Inspect the resulting PDF to confirm it contains the product details you need. PDFShift describes URL and HTML conversion; its documented endpoint and request pattern are shown in its API guide.

1. Get the product page URL and API key

  1. Open the product page on your Shopify storefront and copy its public URL. For example: https://store.example/products/example-product. Replace this example with your real product URL.
  2. Obtain a PDFShift API key through your PDFShift account. Keep it private: do not put it in browser-side JavaScript, a public repository, or a URL that might be logged.
  3. Choose a server or local environment where you can make an HTTPS request and write the returned bytes to a file.

The PDFShift endpoint is https://api.pdfshift.io/v3/convert/pdf. The request contains a JSON object with source set to the product URL, and sends the API key in the X-API-Key header.

2. Convert the Shopify product page to PDF

These examples make the same request and write the response body to product-page.pdf. Set the API key and target URL for your store before running one.

cURL

curl --fail-with-body --silent --show-error \
  --request POST \
  --url https://api.pdfshift.io/v3/convert/pdf \
  --header "X-API-Key: YOUR_PDFSHIFT_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"source":"https://store.example/products/example-product"}' \
  --output product-page.pdf

--fail-with-body makes curl return an error status for unsuccessful HTTP responses while preserving the response body for inspection. If your curl version does not support that flag, remove it and check the HTTP status separately.

Python

import requests

api_key = "YOUR_PDFSHIFT_API_KEY"
product_url = "https://store.example/products/example-product"

response = requests.post(
    "https://api.pdfshift.io/v3/convert/pdf",
    headers={
        "X-API-Key": api_key,
        "Content-Type": "application/json",
    },
    json={"source": product_url},
    timeout=120,
)
response.raise_for_status()

content_type = response.headers.get("Content-Type", "")
if "pdf" not in content_type.lower() and not response.content.startswith(b"%PDF"):
    raise RuntimeError(f"Expected a PDF response, got Content-Type: {content_type}")

with open("product-page.pdf", "wb") as pdf_file:
    pdf_file.write(response.content)

print("Saved product-page.pdf")

Node.js

import { writeFile } from "node:fs/promises";

const apiKey = "YOUR_PDFSHIFT_API_KEY";
const productUrl = "https://store.example/products/example-product";

const response = await fetch("https://api.pdfshift.io/v3/convert/pdf", {
  method: "POST",
  headers: {
    "X-API-Key": apiKey,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ source: productUrl }),
  signal: AbortSignal.timeout(120_000),
});

if (!response.ok) {
  const errorBody = await response.text();
  throw new Error(`PDFShift returned HTTP ${response.status}: ${errorBody}`);
}

const pdf = Buffer.from(await response.arrayBuffer());
if (!pdf.subarray(0, 4).equals(Buffer.from("%PDF"))) {
  throw new Error("The response did not begin with a PDF signature");
}

await writeFile("product-page.pdf", pdf);
console.log("Saved product-page.pdf");

The Node example uses the built-in fetch API available in current Node.js releases and writes binary response bytes. PDFShift’s official Node example uses the same endpoint, API-key header, URL source, and file-saving flow; its library choice is not required. The PDFShift documentation is the reference for request behavior and options.

3. Check the PDF contents and layout

Open the downloaded file and verify the content that matters for your task:

  • Product title, price, variant details, and description are present and readable.
  • The main product image and any other required images appear at useful resolution.
  • Text is not cut off, overlapped, or split in a way that makes the document hard to use.
  • Important information below the initial viewport is included if you expect a full product-page document.
  • The page does not contain unexpected banners, menus, or storefront elements that make the PDF unsuitable.

A successful conversion request means a PDF was returned; it does not establish that every Shopify theme, script, or gated page rendered exactly as intended. If a particular section is missing, first check whether it appears on the public page in a normal browser. Then investigate whether the content is inserted dynamically or whether the page needs a different print layout.

4. Adjust PDF styling with CSS

PDFShift documents a css customization parameter that accepts CSS content or a URL. Use it when the storefront’s screen layout is unsuitable for a document, such as when navigation, promotional sections, or multi-column layouts take too much space. The CSS guide explains the supported customization input: PDFShift CSS documentation.

For example, print-oriented rules can request a white background, hide a known navigation selector, and avoid breaking a product summary across pages. The selectors below are illustrative; inspect your own theme and replace them with selectors that actually exist. Supply the CSS using the documented css parameter in the API request.

/* Example print rules: replace selectors to match your storefront theme. */
@media print {
  body { background: #fff; }
  header, footer, .site-navigation, .cookie-banner { display: none !important; }
  .product__info, .product__media { break-inside: avoid; }
}

Do not assume a selector such as .product__info is used by your theme. A selector that matches nothing has no effect. Keep the CSS focused, then regenerate and inspect the file.

5. Or skip the browser setup

If what you need is a clean image or PDF capture of a public product page, ScreenshotNeo is a website screenshot API and MCP server. Its PDF endpoint returns a PDF for a URL in one GET request. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" \
  -d access_key=YOUR_API_KEY \
  --data-urlencode url=https://store.example/products/example-product \
  -o product-page.pdf

Use the PDF output option documented for the API when requesting a PDF. ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

Troubleshooting

Symptom Likely cause What to do
Unauthorized or forbidden response The API key is missing, incorrect, or sent under the wrong header. Send the key as X-API-Key, check for accidental whitespace, and keep the key out of the URL.
Request rejected The request body is malformed or the URL is not provided as a string in source. Send valid JSON with a fully qualified public URL, and include Content-Type: application/json.
HTML or JSON saved with a .pdf extension The API returned an error response, but the client wrote its body to the output path. Check the HTTP status before saving, inspect the error body, and verify the saved file begins with the PDF signature %PDF.
PDF opens but product content is missing The page content may be dynamically rendered, unavailable to the converter, or absent from the public page. Check the URL in a normal browser, confirm the content is public, and inspect whether the relevant product details are present after the page renders. Review PDFShift’s documented customization options if layout changes are needed.
Images or price are absent The storefront may load assets or product information through scripts or delayed requests. Confirm those assets display on the public page and retry after checking the page itself. The reviewed documentation does not guarantee results for every theme or script.
Text is clipped or pages break awkwardly The storefront’s screen styling is not a good print layout. Use the documented CSS customization to hide irrelevant elements or adjust print rules, then inspect a fresh PDF.
Client times out The conversion or target page took longer than the client’s timeout. Set a suitable client timeout, avoid issuing many duplicate requests while one is still running, and check the response before retrying.

Performance, reliability, and cost considerations

  • Conversion time: The request depends on both the conversion service and the target page’s loading behavior. Set a client timeout appropriate for your workflow and handle timeout errors explicitly.
  • Retries: Retry only transient failures, with a limited backoff. Do not blindly retry authentication or malformed-request errors. Avoid launching duplicate conversions while an earlier request may still be running.
  • Output validation: Check the HTTP status and, where appropriate, the response content type or PDF signature before treating the file as complete.
  • Storefront changes: Theme updates can change page structure and selectors. If the PDF is generated repeatedly, inspect it after meaningful storefront changes.
  • Cost: The reviewed PDFShift materials establish the endpoint and conversion workflow but do not provide current pricing or quota details. Check PDFShift’s current pricing directly before estimating production cost.
  • Privacy: The API request sends the target URL to the conversion service. Keep API credentials server-side and avoid putting private or customer-specific data in a publicly reachable URL unless your data handling requirements allow it.

FAQ

Does PDFShift have a Shopify app for this?

The sources used for this guide document a URL-to-PDF API workflow, not a Shopify-specific app or native integration.

Can I convert a product page that requires a customer login?

The documented examples establish conversion from a URL, but the reviewed materials do not establish support for authenticated Shopify storefront pages. Verify access behavior and the resulting document for your specific page.

Can I make the PDF look different from the live storefront?

Yes. PDFShift documents CSS customization, including CSS content or a CSS URL, for changing PDF rendering.

How do I know the PDF is complete?

Open it and check the specific product details and images you need. A successful API response alone does not guarantee a complete rendering for every storefront.