Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to stream the pdf #228

Open
SanthoshSivan-Dev opened this issue Apr 15, 2024 · 1 comment
Open

Unable to stream the pdf #228

SanthoshSivan-Dev opened this issue Apr 15, 2024 · 1 comment

Comments

@SanthoshSivan-Dev
Copy link

SanthoshSivan-Dev commented Apr 15, 2024

Hi,

I am using the basic code you mentioned on the doc to generate a pdf. code mentioned below,

$customer = new Buyer([
    'name'          => 'John Doe',
    'custom_fields' => [
        'email' => '[email protected]',
    ],
]);

$item = InvoiceItem::make('Service 1')->pricePerUnit(2);

$invoice = Invoice::make()
    ->buyer($customer)
    ->discountByPercent(10)
    ->taxRate(15)
    ->shipping(1.99)
    ->addItem($item);

return $invoice->stream();

when I load the pdf URL. I was getting errors like

Dompdf\Options::validateArtifactPath(): Argument # 1 ($path) must be of type string, null given, called in /home/krf/Documents/Projects/student-management/vendor/dompdf/dompdf/src/Options.php on line 1075

Laravel version: "^11.0"
PHP version: "8.2"

is there any solution for this?

@mustafaalharethi
Copy link

mustafaalharethi commented Jul 23, 2024

Use this

return response()->streamDownload(function () use ($invoice) { echo $invoice->stream(); }, 'name.pdf');

if you want get PDF Link use this

$link = $invoice->url(); return redirect($link);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants