Recommended Free Tools
To convert a web page URL to PDF in a Laravel application, call DocRaptor’s PHP client from server-side code: set the API key, create a PDF document with setDocumentUrl(), then pass the returned binary PDF to a Laravel download response or save it to storage. DocRaptor must be able to retrieve the URL you provide.
Install the DocRaptor PHP client
From your Laravel project directory, install the official package with Composer:
composer require docraptor/docraptor
Keep the DocRaptor API key on the server. Its API supports HTTP Basic Authentication with the key as the username and an empty password; the PHP client example sets the username on DocRaptorDocApi. Do not put the key in browser JavaScript or other publicly accessible code. See DocRaptor’s API documentation and PHP client guide.
For example, add a key to your environment configuration and expose it through Laravel’s services configuration:
#1 Best Overall
// .env
DOCRAPTOR_API_KEY=your_api_key
// config/services.php
'docraptor' => [
'key' => env('DOCRAPTOR_API_KEY'),
],
Use your project’s normal secret-management process in production. Do not commit a real key to source control.
Convert an accessible URL to a PDF
This server-side PHP-client flow uses the URL as DocRaptor’s input and returns the PDF as binary data. The Laravel download handling below is an implementation example; it is not a Laravel-specific integration supplied by DocRaptor.
<?php
use DocRaptorApiException;
use DocRaptorDoc;
use DocRaptorDocApi;
use IlluminateSupportFacadesLog;
public function download(string $url)
{
$api = new DocApi();
$api->getConfig()->setUsername(config('services.docraptor.key'));
$doc = new Doc();
$doc->setTest(true); // Development only: the PDF is watermarked.
$doc->setDocumentType('pdf');
$doc->setDocumentUrl($url);
try {
$pdf = $api->createDoc($doc); // Binary PDF string on success.
} catch (ApiException $e) {
Log::error('DocRaptor PDF generation failed', [
'message' => $e->getMessage(),
'code' => $e->getCode(),
'response_body' => $e->getResponseBody(),
]);
abort(502, 'The PDF could not be generated.');
}
return response()->streamDownload(
static function () use ($pdf): void {
echo $pdf;
},
'page.pdf',
['Content-Type' => 'application/pdf']
);
}
Replace the example URL with an appropriate application value and validate it for your use case. Avoid logging the API key or exposing exception details to users. DocRaptor’s successful synchronous response contains PDF bytes, but an error response may contain XML instead; use the client’s exception handling rather than assuming every response is a PDF.
Save the binary output instead of downloading it
If the application should store the generated PDF, write the binary string using Laravel’s storage API. This is a Laravel-side handling example:
Free tools Windows power users keep installed
One-click scans. No signup required.
use IlluminateSupportFacadesStorage;
Storage::disk('local')->put('pdfs/page.pdf', $pdf);
The output is binary, so handle it as bytes rather than converting it to text or JSON.
Choose URL input or HTML input
| Input | Use it when | Important consideration |
|---|---|---|
document_url via setDocumentUrl($url) |
The page already exists at a URL that DocRaptor can retrieve. | A URL on localhost or behind authentication is not automatically accessible to DocRaptor. The reviewed documentation does not specify a recipe for authenticating to private Laravel routes. |
document_content |
Laravel has already generated the HTML and you want to send that content directly. | When HTML contains relative asset paths, provide a base URL or use an HTML <base> tag so assets can resolve. |
DocRaptor accepts either URL input or HTML/XML content. If your page requires a user session or is only reachable inside your application’s network, do not assume the URL method will work; use an input flow that DocRaptor can actually access. The source documentation does not establish a private-route authentication approach.
Rank #3
Set rendering options for the page
Test mode and production mode
Use setTest(true) while developing. Test PDFs are watermarked, and DocRaptor’s API reference says test documents do not count against monthly limits. Disable test mode for production output, subject to your account configuration.
Print CSS or screen CSS
Print media is the default. If the page looks wrong because its print styles hide or rearrange content, set prince_options[media] to screen to use screen styles instead. The PHP guide and API reference document this rendering choice.
JavaScript-dependent pages
JavaScript is disabled by default. Enable it when the page needs client-side rendering, such as charts or data loaded by scripts. Rendering completion can be difficult to infer for dynamically populated pages; the PHP documentation recommends an explicit delay in such cases. Enabling JavaScript does not guarantee that every external-data or timing-dependent page will render as intended.
Rank #4
Handle longer jobs with asynchronous generation
A synchronous createDoc() call returns the binary document directly, which suits a request that can wait for generation. For a workflow that should not keep a web request open, DocRaptor also documents asynchronous API usage: it returns a status identifier and supports callbacks after successful completion.
Do not rely on a callback alone to detect every outcome. DocRaptor states that generation errors do not call the callback, so the application must still check job status and handle errors. The correct choice depends on request duration and how your application delivers completed files; the documentation does not prescribe one universal approach.
Troubleshoot common failures
- The URL cannot be downloaded: Confirm that the address is valid and reachable by DocRaptor. A URL that works only from your browser, a local development machine, or an authenticated Laravel session may not be retrievable by the service. The reviewed sources do not provide a private-route access recipe.
- The response is not a PDF: A failed request can return an XML error body rather than PDF bytes. Inspect the HTTP status and
ApiExceptiondetails; do not write an error payload with a.pdfextension. - Images or styles are missing from submitted HTML: Relative paths need a resolvable base URL. Configure a base URL or include an HTML
<base>element. - Content is missing or laid out unexpectedly: Check whether the page’s print CSS is responsible. Print is the default; try screen media when browser-like screen styles are needed.
- A chart or dynamic section is blank: JavaScript is disabled by default. Enable it when required, and consider an explicit delay for content that depends on asynchronous loading.
- The development PDF has a watermark: That is expected in test mode. Turn off test mode for production output when your account is configured for it.
- The Laravel request takes too long: If synchronous generation does not fit the request’s timing needs, consider the documented asynchronous flow and implement status/error handling as well as success callbacks.
Or skip the browser setup
If the job is taking a clean screenshot of a page rather than producing a paginated, print-oriented PDF, ScreenshotNeo is a website screenshot API and MCP server. A single request can return an image or PDF; it is not a replacement for DocRaptor when you need DocRaptor’s document-generation workflow.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
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 API documentation for parameters and response details. Its pre-capture cleanup accepts cookie or consent banners and removes 60+ known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo: get 1,000 screenshots a month free, with no card.
Frequently Asked Questions
Can DocRaptor convert a URL to PDF from Laravel?
Yes. The PHP client accepts a document URL through setDocumentUrl(); your Laravel server calls the client and handles the returned binary PDF.
Does DocRaptor’s PHP client return a Laravel response object?
No. The synchronous client call returns binary document data; your Laravel application decides whether to download or store those bytes.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →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.

