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

Generate the PDF as bytes, a stream, or a local file, then upload that representation with the AWS SDK for PHP v3. For bytes, pass them as Body to putObject; for a file, use the SDK’s file-upload operation. Set a deliberate object key and ContentType to application/pdf, catch upload errors, and keep the object private unless your access design requires otherwise.

Choose the upload method that matches your PDF output

The key decision is what your PDF generator returns. A renderer that returns a PHP string can send those bytes in the S3 request body. A renderer that writes a file can upload from its path. If you have a stream, you can pass it as the body, but check whether its size is available and whether the SDK consumes or closes the resource.

PDF representation Upload approach What to check
In-memory bytes Pass the string as Body in putObject. Memory available for the PDF and request; retry and exception handling.
Stream Pass the stream as Body. Whether the stream exposes a usable size; provide content length if the operation requires it. The SDK may consume and close a raw PHP stream resource.
Local file Use the SDK file-upload operation with the file path as the source. Temporary-directory permissions, cleanup, disk capacity, and retention of sensitive files.
S3 stream wrapper Write with PHP file functions to an S3 URI. Register the wrapper and explicitly check fflush; write errors may not appear until flush.

AWS documents both file and stream sources for S3 uploads, but does not establish one universally best choice for every PDF size or hosting setup. Choose based on the renderer’s output and your application’s memory, disk, and retry requirements. See the AWS SDK for PHP file operations guide and S3 code examples.

Upload PDF bytes with AWS SDK for PHP v3

This example assumes your application has the AWS SDK for PHP v3 installed, a configured credential provider, and a bucket in the region supplied to the client. It also assumes $pdfBytes contains the completed PDF as a PHP string. The SDK resolves credentials through its configured provider chain; do not commit long-lived access keys in application source.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Epson EcoTank ET-2800 Wireless Color All-in-One Supertank Printer - Black
  • INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
  • COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
  • ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
  • HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs
<?php

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

use AwsS3S3Client;
use AwsS3ExceptionS3Exception;

$bucket = 'your-private-bucket';
$key = 'invoices/2026/invoice-1042.pdf';
$region = 'us-east-1';

// Replace this with the bytes returned by your PDF renderer.
$pdfBytes = $dompdf->output();

$s3 = new S3Client([
    'version' => 'latest',
    'region'  => $region,
]);

try {
    $result = $s3->putObject([
        'Bucket'      => $bucket,
        'Key'         => $key,
        'Body'        => $pdfBytes,
        'ContentType' => 'application/pdf',
    ]);

    printf("Uploaded s3://%s/%sn", $bucket, $key);
    if (isset($result['ETag'])) {
        printf("ETag: %sn", $result['ETag']);
    }
} catch (S3Exception $e) {
    error_log('S3 upload failed: ' . $e->getAwsErrorMessage());
    throw $e;
}

The version => 'latest' setting selects the latest service API model available in the installed SDK package; it does not install or update the package. Keep the installed package version under your normal dependency management. For the current operation shape, consult the AWS SDK for PHP S3 examples.

Generate PDF bytes with Dompdf

Dompdf is one option when your source document is HTML. Its output() method returns the rendered PDF as a string, which fits the Body example above. In outline, the generation step looks like this:

$dompdf->loadHtml($html);
$dompdf->setPaper('A4');
$dompdf->render();
$pdfBytes = $dompdf->output();

This is only a renderer example; the S3 upload works with bytes from another PDF library too. Dompdf documents restrictions relevant to layout and security: for example, it does not support CSS flexbox or grid, and table rows cannot split across pages. It also controls local and remote resource access through options such as chroot and isRemoteEnabled. Review the Dompdf project documentation for the version you use, test the layouts you need, and do not enable embedded PHP for untrusted documents.

Upload a renderer-created file instead

If the renderer has already saved the PDF to disk, use the SDK file-operation helper rather than reading the whole file into a PHP string. The source must be a readable local path:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
$result = $s3->upload(
    $bucket,
    $key,
    '/path/to/generated/invoice-1042.pdf',
    'private',
    [
        'params' => [
            'ContentType' => 'application/pdf',
        ],
    ]
);

Use a temporary location with appropriate permissions, and remove the file when your success or failure policy allows. If the document contains personal or financial data, account for temporary-file retention as well as S3 access.

Rank #2
Sale
Epson EcoTank Photo ET-8550 Wireless Wide-Format All-in-One Tank Printer
  • CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
  • INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
  • PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
  • ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴

Choose the bucket, key, metadata, and overwrite behavior

Bucket and region

Configure the S3 client for the bucket’s region and ensure the application identity is authorized for the required operation. Region mismatches and insufficient permissions are common reasons an otherwise valid request fails. The exact IAM policy depends on your deployment and access design; grant only the permissions the application needs.

Object key

The key is the object’s path-like name inside the bucket, not a local filesystem path. Use a stable naming scheme such as invoices/{year}/{invoice-id}.pdf when a later generation should replace the same object. Use a unique identifier or timestamp when each generation must remain separately addressable. Decide intentionally: writing a new object to an existing key replaces the prior object.

Content type and access

Set ContentType to application/pdf so clients receive the correct media type. Do not add a public-read ACL just to make a PDF downloadable. S3 objects are private by default, and AWS recommends keeping Block Public Access enabled and granting access through policies to intended identities or readers. An application can provide authorized downloads without making the bucket public. See Amazon S3 access control.

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

AWS says new S3 uploads are encrypted by default. Check the bucket’s encryption configuration and your compliance requirements rather than assuming that the application must attach a separate encryption field to every request. The upload’s success also does not prove that the intended readers can access the PDF; verify permissions through the same path those readers will use.

Use a stream or the S3 stream wrapper when it fits

For a stream body, rewind the stream before upload if an earlier step has read from it. Confirm that its size can be determined; AWS’s operation may need a content length when the stream does not expose one. A raw PHP stream resource supplied to an SDK command is consumed and closed by the SDK, so do not assume you can reuse it afterwards. Refer to the S3 stream wrapper documentation for the SDK’s stream behavior.

Rank #3
HP Smart Tank 5000 Wireless All-in-One Ink Tank Printer, Scanner, Copier with 2 Years of Ink Included, Best-for-Home, Cartridge-Free, Refillable and AI-Enabled. (5D1B6A)
  • SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
  • INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
  • KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
  • PREMIUM SUPPORT - Strong technical expertise to solve issues faster
  • THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.

The stream wrapper is useful when ordinary PHP file functions suit your workflow. After registering the wrapper and opening an S3 URI for writing, explicitly flush and check the return value before closing. AWS documents: “File write errors are only returned when a call to fflush is made.” A close without a checked flush is not a reliable confirmation that the write succeeded. Opening a key in w mode overwrites an existing object, so account for that in the key design.

Verify the upload and plan for retries

For a robust application, treat PDF generation and S3 storage as separate failure points. Validate that the renderer produced a non-empty PDF before uploading. Catch the SDK exception around the S3 operation, log a useful error without logging document contents or credentials, and decide whether the job can be retried. If a retry writes the same key, it may overwrite the object; if every attempt needs an immutable artifact, use a unique key and record it alongside the application record.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Confirm the bucket and client region match.
  • Check that the application identity can write to the target bucket and key prefix.
  • Use a deterministic content type and a deliberate overwrite policy.
  • After upload, verify the object exists and has the expected metadata and access behavior in the deployed environment.
  • For large PDFs, compare a stream or file approach against holding all bytes in PHP memory; the better choice depends on your renderer and host limits.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

Access denied

Check the configured credentials and the bucket policy, identity permissions, and any organization-level restrictions. Confirm that the role used by the running application—not just a developer’s local credentials—has permission for the intended bucket and key.

Wrong region or bucket name

Verify the bucket name and configure the client for the bucket’s actual region. Check environment-specific configuration so staging and production are not silently using different bucket values.

The uploaded file is empty, truncated, or unreadable

Check the renderer output before calling S3. With a stream, ensure it is positioned at the beginning and has a usable size or the required content-length information. If using the S3 stream wrapper, check fflush and handle a false result before closing.

Rank #4
NDYIN Portable Printers Wireless for Travel, N80 Bluetooth Thermal Printer
  • Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
  • No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
  • Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
  • Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
  • The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art

The object uploads but the user cannot download it

Successful storage does not make a private object public. Check the application’s authorization and download mechanism, and grant intended readers access through an appropriate policy or application flow. Do not enable public access as a troubleshooting shortcut.

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

The PDF layout differs from the browser preview

HTML-to-PDF rendering is not identical to browser rendering. Check the renderer’s CSS support and resource-loading rules, especially for remote fonts, images, and stylesheets. Restrict untrusted HTML and local file access using the renderer’s documented settings.

Or skip the browser setup

If the PDF you need is a capture of a web page rather than a PDF produced by your own PHP renderer, ScreenshotNeo can return a screenshot from one GET request. That is a different input path from generating an arbitrary PDF in PHP; use your renderer and S3 upload flow above when the document must be created from application data. ScreenshotNeo accepts consent banners before capture and removes 60+ known consent platforms, newsletter popups, and chat widgets, with each step switchable. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides screenshot and PDF-capture tools for AI agents.

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

This example saves a webpage capture locally; it does not upload it to S3 or generate a PDF from your PHP application’s data. For endpoint options and response handling, see the ScreenshotNeo API documentation. ScreenshotNeo has 1,000 free shots per month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month, with no card.

Frequently Asked Questions

Does uploading a PDF to S3 make it public?

No. S3 objects are private by default; access must be granted through the access design you configure.

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.

Can I upload a PDF without saving it to disk first?

Yes. If your PDF generator returns bytes, pass them as the SDK request’s Body; a suitable stream can also be used.

Quick Recap

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.