Laravel Print with DomPDF - php

i was trying to print invoice with Laravel using barryvdh/laravel-dompdf
I used the following code to convert pdf:
$pdf = \PDF::loadView('print.service_x')->setPaper('a4','portrait');
return $pdf->download('invoice.pdf');
But the style got break...some of the text overlap the table. How do i solve this problem?
Style link is OK...As when i load the page without pdf it shows me correct view:

Related

Issue when generating fillable PDF in Laravel

I want generate a pdf file to the customer that can edit it and then download it,
I use Laravel 8, mpdf 0.8.15, niklasravnsborg/laravel-pdf 4.1 and php 7.4
I tried this code with mpdf package in controller :
$html = file_get_contents(resource_path('views/app/pdf/inventory/inventory2.blade.php'));
$pdf = new \Mpdf\Mpdf();
$pdf = Mpdf::loadView('app.pdf.inventory.inventory2');
$pdf->useActiveForms = true;
$pdf->WriteHTML($html);
return $pdf->Output();
// return $pdf->stream('document.pdf');
The view was rendred with blade syntax {{ }} #if... , so it's not useful
also I tried niklasravnsborg/laravel-pdf that can load view not write html content, but the pdf generated was not fillable, It create the form staticly (input, buttons ...) not editale
have you an idea to get a fillable pdf ?

Unable to export CSS when exporting large HTML to PDF using mPDF

I'm using mPDF to export a large table to a PDF. As I've read online, I need to break my HTML content into chunks and pass them to WriteHTML method one by one.
But looks like my bootstrap CSS is not getting exported when I do this. My table borders are not visible. No paddings...etc.
How can I achieve both these tasks?
This is my code:
$content_chunks = str_split($content, 1000);
$pdf = new Pdf();
$mpdf = $pdf->api; // fetches mpdf api
$mpdf->SetHTMLHeader(static::buildHeader());
$mpdf->SetHTMLFooter('Generated On: ' . date("r").'||{PAGENO}');
foreach($content_chunks as $html)
{
$mpdf->WriteHTML($html);
}
return $mpdf->Output($file_name,'D');
This is what the official docs say about breaking large HTML into chunks. But I can't find any information with related to exporting bootstrap css.

TCPDF breaking my output on PDF

I am using open cart. I am generating a PDF file using TCPDF. I load my html from a tpl file, which has form with dynamic data. here is my code
$pdf = new TCPDF()
$pdf->AddPage('P');
$html = $this->render();
$pdf->writeHTML($html);
$pdf->Output();
Its showing me output but its breaking the result.
I have five parts in my form but its just showing me first two why is this so.
Plus my css is not working well.

mpdf Skips CSS when i render the view into HTML?

i am using codeigniter i am working on invoice and i want to print a PDF file of my invoice page here is my controller.
$pdfFilePath ='invoice.pdf';
$data=$this->singleinvoice($invoiceId);
ini_set('memory_limit','32M');
$html = $this->load->view('invoice/invoicetopdf', $data, true);
$this->load->library('pdf');
$pdf = $this->pdf->load();
$pdf->SetFooter($_SERVER['HTTP_HOST'].'|{PAGENO}|'.date(DATE_RFC822));
$pdf->WriteHTML($html);
$pdf->Output($pdfFilePath, 'D');
redirect("invoice");
when i echo $html veriable is show fine but when it output the pdf .it has no css styling i mean it convert the HTML without any of my css Style.
i also tried the following but no luck.
$style=file_get_contents(base_url().'_assets/css/bootstrap.css');
$pdf->WriteHTML($style,1);
$pdf->Output($pdfFilePath, 'D');
Now i want to convert my HTML page to PDF as it is shown to the public with complete styling and markups.
does it possible any suggestion or solution ?
you have to convert your Page Structure from DIV to Traditional Table structure.
arrange your elements contents etc.into table or tables.
then try some basic CSS.
because most of CSS are not supported in mpdf or any other pdf converter.
Click here
to know what(CSS) is supported and what is not in mpdf.

dompdf render html codeigniter

i wanna render html page (using dompdf in CI) like this
but when i gererated, output to be
(http://i.stack.imgur.com/TNiHl.png)[second image]
before i edited, generating error error issue so i edited stylesheet.cls.php, but output as 2nd image...any idea...thanx

Categories