October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Composer

How to Add a Background Watermark With the Pdfcrowd HTML-to-PDF API for PHP

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

Use Pdfcrowd’s page-background methods when the artwork must sit behind the HTML content, and use its page-watermark methods when the mark must appear over that content. For a local asset, call setPageBackground() or setPageWatermark(); for an HTTP(S) asset, use the corresponding ...Url() method. If the artwork changes from page to page, use the multipage variant.

The official PHP client is installed with Composer. The guide displayed package version 6.7.0 on September 29, 2026, but package releases can change, so verify the version and method signatures in the current documentation before deploying.

Install the official Pdfcrowd PHP client

From your application directory, install the package and load Composer’s autoloader:

composer require pdfcrowd/pdfcrowd

Pdfcrowd’s PHP client accepts a URL, a local HTML file, or an HTML string as the conversion input. The examples below use an HTML string so the watermark choice is easy to see. Keep your Pdfcrowd username and API key in environment variables or another secret store, not in source control.

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

The official references are the PHP library reference, the PHP guide, and the API method index.

Background or watermark: choose the layer first

Pdfcrowd’s documentation summarizes the distinction this way: “Backgrounds appear beneath content, while watermarks layer on top.” That determines which setter you should call.

Requirement Local file HTTP(S) asset Layer and page behavior
One asset repeated on every output page setPageBackground($file) setPageBackgroundUrl($url) Behind the HTML; the first page of a PDF asset is reused.
Different background artwork by output page setMultipageBackground($file) setMultipageBackgroundUrl($url) Behind the HTML; source pages map to output pages.
One overlay repeated on every output page setPageWatermark($file) setPageWatermarkUrl($url) In front of the HTML; the first page of a PDF asset is reused.
Different overlay by output page setMultipageWatermark($file) setMultipageWatermarkUrl($url) In front of the HTML; source pages map to output pages.

For a multipage source that has fewer pages than the generated PDF, Pdfcrowd repeats the source’s final page for later output pages. A watermark can be a PDF or an image; for a multipage PDF or TIFF used with an ordinary page-watermark method, only its first page is used. The same first-page rule applies to an ordinary page background.

Repeat one local background on every page

Use this pattern for a letterhead, texture, border, or other static sheet that should appear underneath every page of the generated document:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<?php
declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

$username = getenv('PDFCROWD_USERNAME');
$apiKey   = getenv('PDFCROWD_API_KEY');
if (!$username || !$apiKey) {
    throw new RuntimeException('Set PDFCROWD_USERNAME and PDFCROWD_API_KEY first.');
}

$background = __DIR__ . '/assets/letterhead.pdf';
if (!is_file($background) || filesize($background) === 0) {
    throw new RuntimeException('The background file must exist and be non-empty.');
}

$html = '<!doctype html>
<html><body>
  <h1>Quarterly statement</h1>
  <p>This content is rendered above the page background.</p>
</body></html>';

$client = new PdfcrowdHtmlToPdfClient($username, $apiKey);
$client->setPageBackground($background);
$client->convertStringToFile($html, __DIR__ . '/output/statement.pdf');

Replace the asset and HTML with your own values. The local-file method requires a path to an existing, non-empty file. Check that the PHP process—not just your interactive shell—can read it and that the output directory is writable.

Put a watermark over the HTML instead

For “DRAFT,” a logo, a diagonal seal, or any other foreground mark, change the setter to setPageWatermark():

<?php
require __DIR__ . '/vendor/autoload.php';

$client = new PdfcrowdHtmlToPdfClient(
    getenv('PDFCROWD_USERNAME'),
    getenv('PDFCROWD_API_KEY')
);

$watermark = __DIR__ . '/assets/draft-watermark.png';
$client->setPageWatermark($watermark);
$client->convertStringToFile(
    '<html><body><h1>Internal copy</h1><p>Review text.</p></body></html>',
    __DIR__ . '/output/internal-copy.pdf'
);

A transparent PNG is suitable for a logo or text mark because the transparent portions leave the page visible. Whether the mark obscures important text depends on the asset and its rendered placement, so inspect the resulting PDF in the same environment in which your application runs.

Use an HTTP(S) background or watermark

When the asset is hosted remotely, use a URL method:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<?php
require __DIR__ . '/vendor/autoload.php';

$client = new PdfcrowdHtmlToPdfClient(
    getenv('PDFCROWD_USERNAME'),
    getenv('PDFCROWD_API_KEY')
);

$client->setPageBackgroundUrl('https://cdn.example.com/branding/letterhead.pdf');
$client->convertStringToFile(
    '<html><body><h1>Remote artwork</h1></body></html>',
    __DIR__ . '/output/remote-background.pdf'
);

The URL must use HTTP or HTTPS. Ensure the URL is reachable by Pdfcrowd’s service, does not require an interactive login, and returns the intended non-empty image or PDF. A remote URL gives you centralized asset management, while a local file avoids a dependency on an external host; choose according to your deployment and change-control needs.

Map different artwork to different output pages

Use a multipage method when page 1, page 2, and later pages need different artwork. For a local multipage PDF or TIFF:

<?php
require __DIR__ . '/vendor/autoload.php';

$client = new PdfcrowdHtmlToPdfClient(
    getenv('PDFCROWD_USERNAME'),
    getenv('PDFCROWD_API_KEY')
);

$client->setMultipageBackground(__DIR__ . '/assets/page-backgrounds.pdf');
$client->convertStringToFile(
    '<html><body>
       <h1>Page-specific design</h1>
       <div style="page-break-before: always">Second page</div>
     </body></html>',
    __DIR__ . '/output/page-specific.pdf'
);

For a foreground overlay, replace the call with setMultipageWatermark($path). URL equivalents are setMultipageBackgroundUrl($url) and setMultipageWatermarkUrl($url). Source page 1 is applied to output page 1, source page 2 to output page 2, and so on; if the source ends first, its last page repeats.

Convert a URL or local HTML file

The layer-setting calls are independent of the HTML input. After constructing the client and setting the background or watermark, use the conversion method appropriate to your application. The PHP guide documents conversion from URLs, local HTML files, and raw strings. Confirm the exact conversion method signature in the version installed by your project before copying a production integration, because client releases may alter ancillary APIs.

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

Keep the sequence consistent: construct the client, set the page layer, then invoke the conversion. If you set a background or watermark after conversion has started, it will not affect that job.

CSS backgrounds versus Pdfcrowd page backgrounds

A CSS rule such as body { background-image: url(...); } paints the HTML document during rendering. It is not the same as Pdfcrowd’s PDF/image page-background asset. Use CSS when the design is part of the HTML layout and should follow CSS sizing and page rules. Use setPageBackground() or its URL/multipage variants when you have a ready-made PDF or image sheet that should be composited beneath the rendered page content.

Validation checklist before production

  • Install the current pdfcrowd/pdfcrowd release and check the current reference for constructor and conversion signatures.
  • Verify the username and API key through environment configuration; do not commit secrets.
  • For local assets, confirm the runtime path exists, is non-empty, and is readable by the PHP worker.
  • For URL assets, use an HTTP or HTTPS URL that is reachable without an interactive session.
  • Choose background for an underlay and watermark for a foreground overlay.
  • Choose ordinary methods for one repeated source page and multipage methods for page-specific artwork.
  • Generate a document with enough pages to verify repetition or page mapping, then inspect the actual PDF output.
  • Check transparent areas, page breaks, margins, and whether the artwork covers or reveals the intended content.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

The class cannot be found

Run Composer in the project that executes the code and include require __DIR__ . '/vendor/autoload.php';. If deployment uses a separate release directory, make sure the worker is running the same release that contains vendor/.

The local asset is rejected

Pdfcrowd requires a local background or watermark file to exist and be non-empty. Log the resolved absolute path, check permissions for the PHP service account, and verify that the file is not a zero-byte upload. Relative paths are a frequent cause of mistakes; resolve them from __DIR__ or another known application root.

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

The remote asset does not appear

Confirm that the URL begins with http:// or https://, returns the intended file, and is reachable from Pdfcrowd’s service. Check redirects, access controls, expiring URLs, and certificate configuration. If you need deterministic deployments, package the asset with the application and use the local-file method.

The mark is behind text when it should be visible

You selected a background method. Use setPageWatermark() or setPageWatermarkUrl() for a foreground layer. Conversely, switch to a background method if the artwork should never cover document text.

Every page looks like page 1

That is the documented behavior of the ordinary page methods: the first page of a PDF asset is reused on every output page. Use the matching multipage method when each output page needs its own source page.

Later pages use an unexpected design

When a multipage source has fewer pages than the generated PDF, Pdfcrowd repeats the source’s final page. Add enough source pages or design the final source page intentionally for repetition.

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

The code works locally but not in deployment

Compare PHP user permissions, filesystem paths, environment variables, outbound network policy, and the installed Composer package between environments. Generate a small diagnostic PDF with a known-good asset before investigating your full HTML template.

Operational and cost considerations

Local assets remove a fetch from the conversion path but must be present on every worker. Remote assets simplify centralized updates but introduce network availability, redirects, and access-control dependencies. Multipage artwork increases the amount of source material you must maintain and verify. The documentation reviewed does not establish a rendering-speed benchmark, so test your own page sizes, asset formats, and concurrency rather than relying on an assumed throughput figure.

Keep conversion failures observable: record the input type, selected layer method, asset location category (local or URL), and the API error returned by your application, while excluding credentials. Retain representative generated PDFs so a branding change can be compared page by page.

Or skip the browser setup

If your actual requirement is a clean screenshot of a website rather than a PDF generated from HTML, ScreenshotNeo provides a direct screenshot API and MCP server. It is a different tool from Pdfcrowd: it captures web pages as PNG, JPEG, WebP, or PDF instead of applying a page asset to your own HTML-to-PDF conversion.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

One GET request is enough:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for all parameters. Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response reports the page verdict and billing status in headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account.

Frequently Asked Questions

Can I use an image instead of a PDF for a Pdfcrowd watermark?

Yes. The documented watermark and background setters accept image assets as well as PDF assets; local methods require an existing, non-empty file, while URL methods require an HTTP or HTTPS URL.

How do I repeat the same artwork on every page?

Use an ordinary page method such as setPageBackground() or setPageWatermark(). Pdfcrowd uses the first page of a multipage PDF asset for each output page.

How do I assign a different watermark to each page?

Use setMultipageWatermark() for a local source or setMultipageWatermarkUrl() for a remote source. Source pages map to output pages, and the final source page repeats if the output is longer.

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

Is ScreenshotNeo a replacement for Pdfcrowd page backgrounds?

No. ScreenshotNeo captures websites through an API or MCP server; Pdfcrowd’s page-background and watermark methods composite assets into PDFs generated from HTML.

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.

Leave a Reply

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

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

Read next

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.