Giter VIP home page Giter VIP logo

laravel-pdf's Introduction

Warning

niklasravnsborg/laravel-pdf is not maintained! This repository has been deprecated and archived on 2023-08-22. Look at https://github.com/misterspelik/laravel-pdf for a potential alternative.

Laravel PDF: mPDF wrapper for Laravel 5

Easily generate PDF documents from HTML right inside of Laravel using this mPDF wrapper.

Installation

Require this package in your composer.json or install it by running:

composer require niklasravnsborg/laravel-pdf

Note: This package supports auto-discovery features of Laravel 5.5+, You only need to manually add the service provider and alias if working on Laravel version lower then 5.5

To start using Laravel, add the Service Provider and the Facade to your config/app.php:

'providers' => [
	// ...
	niklasravnsborg\LaravelPdf\PdfServiceProvider::class
]
'aliases' => [
	// ...
	'PDF' => niklasravnsborg\LaravelPdf\Facades\Pdf::class
]

Now, you should publish package's config file to your config directory by using following command:

php artisan vendor:publish

Basic Usage

To use Laravel PDF add something like this to one of your controllers. You can pass data to a view in /resources/views.

use PDF;

function generate_pdf() {
	$data = [
		'foo' => 'bar'
	];
	$pdf = PDF::loadView('pdf.document', $data);
	return $pdf->stream('document.pdf');
}

Other methods

It is also possible to use the following methods on the pdf object:

output(): Outputs the PDF as a string.
save($filename): Save the PDF to a file
download($filename): Make the PDF downloadable by the user.
stream($filename): Return a response with the PDF to show in the browser.

Config

If you have published config file, you can change the default settings in config/pdf.php file:

return [
	'format'           => 'A4', // See https://mpdf.github.io/paging/page-size-orientation.html
	'author'           => 'John Doe',
	'subject'          => 'This Document will explain the whole universe.',
	'keywords'         => 'PDF, Laravel, Package, Peace', // Separate values with comma
	'creator'          => 'Laravel Pdf',
	'display_mode'     => 'fullpage'
];

To override this configuration on a per-file basis use the fourth parameter of the initializing call like this:

PDF::loadView('pdf', $data, [], [
  'format' => 'A5-L'
])->save($pdfFilePath);

You can use a callback with the key 'instanceConfigurator' to access mpdf functions:

$config = ['instanceConfigurator' => function($mpdf) {
    $mpdf->SetImportUse();
    $mpdf->SetDocTemplate(/path/example.pdf, true);
}]
 
PDF::loadView('pdf', $data, [], $config)->save($pdfFilePath);

Headers and Footers

If you want to have headers and footers that appear on every page, add them to your <body> tag like this:

<htmlpageheader name="page-header">
	Your Header Content
</htmlpageheader>

<htmlpagefooter name="page-footer">
	Your Footer Content
</htmlpagefooter>

Now you just need to define them with the name attribute in your CSS:

@page {
	header: page-header;
	footer: page-footer;
}

Inside of headers and footers {PAGENO} can be used to display the page number.

Included Fonts

By default you can use all the fonts shipped with mPDF.

Custom Fonts

You can use your own fonts in the generated PDFs. The TTF files have to be located in one folder, e.g. /resources/fonts/. Add this to your configuration file (/config/pdf.php):

return [
	// ...
	'font_path' => base_path('resources/fonts/'),
	'font_data' => [
		'examplefont' => [
			'R'  => 'ExampleFont-Regular.ttf',    // regular font
			'B'  => 'ExampleFont-Bold.ttf',       // optional: bold font
			'I'  => 'ExampleFont-Italic.ttf',     // optional: italic font
			'BI' => 'ExampleFont-Bold-Italic.ttf' // optional: bold-italic font
			//'useOTL' => 0xFF,    // required for complicated langs like Persian, Arabic and Chinese
			//'useKashida' => 75,  // required for complicated langs like Persian, Arabic and Chinese
		]
		// ...add as many as you want.
	]
	// ...
];

Note: If you are using laravel-pdf for producing PDF documents in a complicated language (like Persian, Arabic or Chinese) you should have useOTL and useKashida indexes in your custom font definition array. If you do not use these indexes, your characters will be shown dispatched and incorrectly in the produced PDF.

Now you can use the font in CSS:

body {
	font-family: 'examplefont', sans-serif;
}

Set Protection

To set protection, you just call the SetProtection() method and pass an array with permissions, an user password and an owner password.

The passwords are optional.

There are a fews permissions: 'copy', 'print', 'modify', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-highres'.

use PDF;

function generate_pdf() {
	$data = [
		'foo' => 'bar'
	];
	$pdf = PDF::loadView('pdf.document', $data);
	$pdf->SetProtection(['copy', 'print'], '', 'pass');
	return $pdf->stream('document.pdf');
}

Find more information to SetProtection() here: https://mpdf.github.io/reference/mpdf-functions/setprotection.html

Testing

To use the testing suite, you need some extensions and binaries for your local PHP. On macOS, you can install them like this:

brew install imagemagick ghostscript
pecl install imagick

License

Laravel PDF is open-sourced software licensed under the MIT license

laravel-pdf's People

Contributors

britishwerewolf avatar danielimi avatar daveismynamecom avatar erfansahaf avatar ianmustafa avatar niklasravnsborg avatar panovalexey avatar pavinthan avatar stefanullrich avatar tezkerek avatar urielo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-pdf's Issues

Landscape PDF Generation

Hi, I'm trying to generate PDF. When I create a PDF with "Portrait" it works. On changing orientation to "Landscape", it still generates PDF with "Portrait" view.
Please help me resolve this.

Error "A non-numeric value encountered"

Hello!

Thank you for this package.
I've installed it but with PHP 7.1.1 I've encountered with error "A non-numeric value encountered".
As I read that's because you use mpdf 6, how can I replace it on mpdf 7?
Thank you!

Kind Regards, Dmitry.

Set custom config through a function

Hi,

Great work on making this wrapper! :)

I just want to ask if there is a way to set the config through a function?

Eg.

function generate_pdf() {
$data = [
'foo' => 'bar'
];
$pdf = PDF::loadView('pdf.document', $data);
$pdf->SetProtection(['copy', 'print'], '', 'pass');
$pdf->setConfig([
'mode' => '',
'format' => 'A4',
'default_font_size' => '12',
'default_font' => 'sans-serif',
'margin_left' => 10,
'margin_right' => 10,
'margin_top' => 10,
'margin_bottom' => 10,
'margin_header' => 0,
'margin_footer' => 0,
'orientation' => 'P',
'title' => 'Laravel mPDF',
'author' => '',
'watermark' => '',
'show_watermark' => false,
'watermark_font' => 'sans-serif',
'display_mode' => 'fullpage',
'watermark_text_alpha' => 0.1
]);

return $pdf->stream('document.pdf');

}

Cheers!
Michael

Getting permssion failed error on laravel 5.2 version

ErrorException in ttfontsuni.php line 1264:
file_put_contents(/home/nextbrain/workspace/tijik_web/vendor/mpdf/mpdf/ttfontdata/dejavusanscondensed.GSUBGPOStables.dat): failed to open stream: Permission denied

Used below code

$pdf = PDF::loadHTML('pdf.document', $data);
$pdf->SetDirectionality('rtl');
return $pdf->stream('document.pdf');

mpdf

Change orientation at run-time

Does the orientation have to be specific in the config/pdf.php file and be the same for all PDFs generated? Or can you dynamically override the config settings when you create a PDF?

Thanks!

Extend CSS Support

First of all, Well done on an awesome package.

I want to find out if there's a way to make this package work with css frameworks such as Bootstrap...

Regards
O.M

Call to undefined method mPDF::loadView()

i'm trying to work with this package but i'm seeing this error

Call to undefined method mPDF::loadView() also tried any other actions and its not woking

This is my code:

use MPDF;
$data = [
'foo' => 'bar'
];
$pdf = MPDF::loadloadHTML('web.pdf.contract', $data);
return $pdf->stream('document.pdf');

in the service provider and aliases array:
'niklasravnsborg\LaravelPdf\PdfServiceProvider',
'MPDF' => 'niklasravnsborg\LaravelPdf\Facades\Pdf'

and im using Laravel 5.0

WatermarkImage not working

I had this working in mPDF outside of Laravel without a problem.

I can't get SetWatermarkImage() working regardless of whether I set showWatermarkImage to true. I even tried using the HTML control tag and it doesn't work either.

I did get the image to load using the Image() method, but that isn't really what I was I hoping for.

Arabic font issue

Arabic font not connected and its showing like this

captdddure

The right word is
الإسم

Error with Laravel 5.0.*

Hi, I'm trying to install this package with laravel 5.0.* and composer can't get the right version of the package, any ideas to fix it? Thanks.

Can't save to server

Hi!

The only issue for me is that I cant save PDF document to disk. I tried with:
$pdf->Output('filename.pdf','F');
It does not save to any directory.
Thank you!

facade cannot be found

Hi! We're getting undefined niklasravnsborg\LaravelPdf\Facades\Pdf. We just follow the instructions in the Read.me, and just like other package we add the service provider and facade in the app.php.

PhpUnit testing error

In my method in the controller

public function estimate(Estimate $estimate)
{
	$pdf = PDF::loadView('documents.estimate', ['estimate' => $estimate]);
	return $pdf->download($estimate->name . '.pdf'); // <--- the 12th line, error is here.
}

my test

/** @test */
	public function it_makes_pdf_from_estimate_and_downloads_it()
	{
		$estimate = create(Estimate::class);

		$this->get('/estimates/' . $estimate->id . '/pdf')
			->assertStatus(200)
			->assertHeader('Content-type', 'application/pdf')
		;
    }

the error

Cannot modify header information - headers already sent by (output started at D:\Dropbox\OpenServer\domains\estimate.dev\vendor\phpunit\phpunit\src\Util\Printer.php:110)
 D:\Dropbox\OpenServer\domains\estimate.dev\vendor\mpdf\mpdf\mpdf.php:9420
 D:\Dropbox\OpenServer\domains\estimate.dev\vendor\niklasravnsborg\laravel-pdf\src\LaravelPdf\Pdf.php:137
 D:\Dropbox\OpenServer\domains\estimate.dev\app\Http\Controllers\DocumentsController.php:12

Any advice would be appreciated.

PHP 7.1 A non-numeric value encountered

Hi, PHP 7.1 return error:

in mpdf.php line 30648
at HandleExceptions->handleError('2', 'A non-numeric value encountered', '/.../vendor/mpdf/mpdf/mpdf.php', '30648', array('size' => '0', 'maxsize' => '190.001555556', 'fontsize' => '3.175', 'usefontsize' => false)) in mpdf.php line 30648

Non numerica value encountered

After upgrading my php version to 7.1, when I try to generate pdf, it generates a non numeric value encountered error.
Could this be a problem with the version?

Image watermark doesn't show in first page

I'm trying to set an image watermark to my document but the first page of the rendered document doesn't contain image watermark.
Image watermark only shows after the first page:

View:

<html lang="fa">
<body>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <style type="text/css">
        body {
            font-family: yekan;
        }

        th {
            background: #2a2a2a;
            color: white;
            font-size: 22px;
            padding: 5px
        }

        td {
            font-size: 18px;
            padding: 10px 20px;
            text-align: center;
        }

        table {
            margin-left: auto;
            margin-right: auto;
        }

        h1 {
            margin: 20px 0 10px;
        }

        @page {
            header: page-header;
            footer: page-footer;
        }

        .text-center {
            text-align: center
        }
    </style>
</head>
<body>
<htmlpageheader name="page-header">
    <div><h1 class="text-center">سامانه آنلاین اعلام برنامه هفتگی دانشکده شمسی پور</h1></div>
    <hr>
</htmlpageheader>
<div>
    <?php $i = 0; $len = count($data); ?>
    @foreach($data as $day => $plans)
        <h2 class="text-center">برنامه دروس روز {{config('system.DAYS')[$day]}}</h2>
        <Br>
        <div>
            <table border="1">
                <thead>
                <tr>
                    <th>ساعت</th>
                    <th>نام درس</th>
                    <th>نام استاد</th>
                    <th>کلاس</th>
                </tr>
                </thead>
                <tbody>
                @foreach($plans as $plan)
                    <tr>
                        <td>{{$plan->start}} الی {{$plan->end}}</td>
                        <td>{{$plan->lname}}</td>
                        <td>{{$plan->teacher->name}} {{$plan->teacher->family}}</td>
                        <td>{{$plan->class}}</td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
        @if($i != $len -1)
            <pagebreak></pagebreak>
        @endif
        <?php $i++; ?>
    @endforeach
</div>
</body>
</html>

Controller:

$pdf = PDF::loadView('pdf.single', ["data" => $plans]);
$pdf->setWatermarkImage(public_path('img/logo1.png'));
$pdf->save(public_path('plans.pdf'));

readme.md uses old Config

in the readme.md Config section, it shows wrong configuration array, please update.

return [
	'mode'                  => '',
	'format'                => 'A4',
	'default_font_size'     => '12',
	'default_font'          => 'sans-serif',
	'margin_left'           => 10,
	'margin_right'          => 10,
	'margin_top'            => 10,
	'margin_bottom'         => 10,
	'margin_header'         => 0,
	'margin_footer'         => 0,
	'orientation'           => 'P',
	'title'                 => 'Laravel mPDF',
	'author'                => '',
	'watermark'             => '',
	'show_watermark'        => false,
	'watermark_font'        => 'sans-serif',
	'display_mode'          => 'fullpage',
	'watermark_text_alpha'  => 0.1
];

Call to undefined method niklasravnsborg\LaravelPdf\Facades\Pdf::SetTitle()

Hey there,

Trying to use your library, but whenever I generate a PDF I get the following error:

Call to undefined method niklasravnsborg\LaravelPdf\Facades\Pdf::SetTitle()

I'm using the example code from your readme.md, so nothing fancy. Have tried it on a view other views with no luck either.

Sorry I don't have more information to provide, I simply followed the 'Installation' then 'Basic Usage' steps and am unable to go any further.

Thanks for any help.

Pdf include

Hi, the include in the PdfServiceProvider is not working anymore, now that you've change to the mpdf/mpdf, he's looking in the wrong directory. Can you update the path there also? thanks.

[Help request] I get error during testing 'Undefined index: data'

My code

public static function managePdf($view, $vars = [], $file = null)
{
	$pdf = PDF::loadView($view, $vars);

	if (request()->exists('save'))
		return Storage::put($file, $pdf->output($file))
			? 'PDF saved to ' . $file
			: null
		;
	return $pdf->download($file);
}

Everything works fine.

But when I run my phpunit test.

// there are two nested foreach-loops by `testings` and `clients`
// inside the inner loop I run a command
//dump(sprintf('/result/client-%d-testing-%d/%s?save', $client->id, $testing->id, $filename));
$this->get(sprintf('/result/client-%d-testing-%d/%s?save', $client->id, $testing->id, $filename))
    ->assertResponseOk()
    ->see('Pdf saved to ' . $filename);

I get an error:

[2016-12-29 22:17:04] testing.ERROR: exception 'ErrorException' with message 'Undefined index: data' in D:\Dropbox\OpenServer\domains\testing-system\vendor\niklasravnsborg\mpdf\mpdf.php:10944
Stack trace:
#0 D:\Dropbox\OpenServer\domains\testing-system\vendor\niklasravnsborg\mpdf\mpdf.php(10944): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined index...', 'D:\Dropbox\Open...', 10944, Array)
#1 D:\Dropbox\OpenServer\domains\testing-system\vendor\niklasravnsborg\mpdf\mpdf.php(26283): mPDF->_putimages()
#2 D:\Dropbox\OpenServer\domains\testing-system\vendor\niklasravnsborg\mpdf\mpdf.php(11325): mPDF->_putresources()
#3 D:\Dropbox\OpenServer\domains\testing-system\vendor\niklasravnsborg\mpdf\mpdf.php(2142): mPDF->_enddoc()
#4 D:\Dropbox\OpenServer\domains\testing-system\vendor\niklasravnsborg\mpdf\mpdf.php(9275): mPDF->Close()
#5 D:\Dropbox\OpenServer\domains\testing-system\vendor\niklasravnsborg\laravel-pdf\src\LaravelPdf\PdfWrapper.php(74): mPDF->Output('', 'S')
#6 D:\Dropbox\OpenServer\domains\testing-system\app\Testing.php(330): niklasravnsborg\LaravelPdf\PdfWrapper->output('1115_1019.pdf')
#7 D:\Dropbox\OpenServer\domains\testing-system\app\Http\Traits\ManagingResults.php(68): App\Testing::managePdf('testings.result...', Array, '1115_1019.pdf')

If I use dump to print out the "bad" URL and follow the URL in a browser - everything is working fine Really rare I get an error about unlink(some_tmp_png_image_in_the_vendor_folder): Access denied. But I refresh the page and it disappears.

Did I do anything wrong?

SetProtection() method

Hi man, if you have some time implement this please!!
In your file PdfWrapper.php

/**
     * Encrypts and sets the PDF document permissions
     * 
     * @param $permisson a array with permisson ex: ['copy','print',]
     * @param $user_password a string with user password
     * @param $owner_password a string with owner password
     * 
     */
    public function SetProtection($permisson = array(), $user_password,$owner_password){
        return $this->mpdf->SetProtection($permisson,$user_password,$owner_password);
    } 

thank you!!!

How to insert a page break

Hello. BTW, thanks for the package.

I want to insert a page break from inside my blade file.

Like this

@foreach($documents as $document)

    {!! $document->body !!}

    // Here I want to break the page. Each document's body must start from a new page.

@endforeach

I want all documents in 1 file.

Is there a way to do it?

I can't turn `showWatermarkImage` off

Hi,
I'm facing a problem that I want to show a water mark in first page only and not all pages.
So, I think we need to make $this->mpdf->showWatermarkImage false and sometimes $this->mpdf->showWatermarkText false also.
I suggest it's better to make a new function called obj() which referenced to $mpdf.

Thanks in Advance

Auto publishing config file instead of copying manually

In this project, you should copy pdf.php (located on laravel-pdf/src/config/pdf.php file into your application config folder manually but it has to be published automatically by running php artisan vendor:publish command.
I opened this issue for those have the same question. Don't worry, I'll send a PR to fix it.

ErrorException in cssmgr.php line 1302

Hey,

Please help :(

I just installed this package. Have followed your instructions point to point, but is give me an error message when I try to display a pdf.

Error details:
ErrorException in cssmgr.php line 1302.
Illegal string offset 'ID'
in cssmgr.php line 1302
at HandleExceptions->handleError('2', 'Illegal string offset 'ID'', '.../vendor/niklasravnsborg/mpdf/classes/cssmgr.php', '1302', array('inherit' => 'BLOCK', 'tag' => 'BODY', 'attr' => '', 'p' => array(), 'zp' => array(), 'classes' => array())) in cssmgr.php line 1302
at cssmgr->MergeCSS('BLOCK', 'BODY', '') in mpdf.php line 15961

Save multiple pdf to folder

This works great! Thanks for the tutorial!

However is there a way to save multiple pdf's to a folder instead of opening them via browser?

like say I click a button and it generates many pdf's in a folder I specifiy...Hope this makes sense?

Send as Attachment

is it possible to save the file instead of view or send as an attachment in the mail .

Persian words showing dispatched

I'm trying to render multiple PDF documents using following codes:

foreach($plans as $day => $plan){
	$pdf = PDF::loadView('pdf.single', ["day" => $day, "plans" => $plan]);
	$pdf->mpdf->SetWatermarkImage(public_path('img/logo1.png'));
	$pdf->mpdf->showWatermarkImage = true;
	if(file_exists(public_path('plans/plans-'.$day.'.pdf')))
		Storage::delete(public_path('plans/plans-'.$day.'.pdf'));
	$pdf->save(public_path('plans/plans-'.$day.'.pdf'));
}

But there is a problem. As you know, Persian (Farsi) language is similar to Arabic (in writing) and each word contains a couple of letters that should be patched to each other to shape the word. In the first rendered document everything is fine, but after that, every rendred document contains dispatched letters and it causes dispatched words.

Here is my first rendered document which is OK:
image

And my second document which is NOT OK:
image

Add template for the background

We need to add a pdf as background template for our pdf's and we would like to add this function.
We will do a pull request soon.

Showing Error With Php 7.1

I am trying to update composer php vesion 5.6 top 7.1 but mpdf showing error message

` Problem 1

- mpdf/mpdf v6.1.4 requires php ^5.4.0 || 7.0.* -> your PHP version (7.1.9) does not satisfy that requirement.

- Installation request for mpdf/mpdf v6.1.4 -> satisfiable by mpdf/mpdf[v6.1.4].`

Landscape not rendering

Hi everyone, I have to create a A5 paper with landscape orientation, but only portrait is rendered.

I'm using:

  • PHP 7.1
  • Laravel 5.4
  • laravel-pdf 1.5

This is my code:

$pdf = PDF::loadView('estimates.pdf.badge', ['estimate_row' => $estimate_row], [], ['orientation' => 'L', 'format' => 'A5']);
return $pdf->stream('badge.pdf');

The rendition of html barcode gives me a solid black box.

I'm using a barcode generator that returns a block of html (see below). In Chrome it renders just fine, but when I apply your pdf tool, all I get is a solid block of black. If I had to guess I would say laravel-pdf doesn't manage position:absolute very well.

Barcode html:

<div style="font-size:0;position:relative;width:160px;height:30px;">
<div style="background-color:black;width:2px;height:30px;position:absolute;left:0px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:8px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:12px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:20px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:28px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:32px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:36px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:44px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:48px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:56px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:64px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:72px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:80px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:88px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:92px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:96px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:104px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:112px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:116px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:124px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:128px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:136px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:140px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:148px;top:0px;">&nbsp;</div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:156px;top:0px;">&nbsp;</div>
</div>

Custom Pdf Configuration Style Not Working

I am changing mpdf code codeigniter to laravel.

Codeigniter

$pdf = $this->pdf->load();
$pdf->mPDF('utf-8',    // mode - default ''
                'A4',  // format - A4, for example, default ''
                0,     // font size - default 0
                '',    // default font family
                0,    // margin_left
                0,    // margin right
                0,    // margin top
                0,    // margin bottom
                0,     // margin header
                0,     // margin footer
                'L');  // L - landscape, P - portrait

but in laravel I am using below code but it's not working.

Laravel

$pdf = PDF::loadView('pdf.invoice', $data);
 $pdf->mPDF('utf-8',    // mode - default ''
                'A4',  // format - A4, for example, default ''
                0,     // font size - default 0
                '',    // default font family
                0,    // margin_left
                0,    // margin right
                0,    // margin top
                0,    // margin bottom
                0,     // margin header
                0,     // margin footer
                'L');  // L - landscape, P - portrait
 $pdf->save($pdfFilePath);

Merge PDFs

Is it possible to merge PDFs using this package?

Custom Fonts Not Work

hi

i can't use custom font as follow ( for UTF-8 / Persian ) :

'custom_font_path' => public_path('/fonts/'),
'custom_font_data' => [
	'pdfFont' => [
		'R'  => 'mine.ttf',   
	]
]

or change `default_font' in pdf.php file

nothing changed

Svg is not included in the PDF as Image

I tried in my blade view include the SVG as string with the following code

`

<title>Layouts PDF</title> @foreach ($layouts as $key => $layout) {{$layout}} @Endforeach `

But the string was done.

Also I tryed
<img src="{{$layout}}" alt="">

Bu I got this

ErrorException in mpdf.php line 30648:
A non-numeric value encountered

Here is more about the error
in mpdf.php line 30648
at HandleExceptions->handleError('2', 'A non-numeric value encountered', '/home/vagrant/Code/spiffy/vendor/mpdf/mpdf/mpdf.php', '30648', array('size' => '0', 'maxsize' => '190.00155555556', 'fontsize' => '4.2333333333333', 'usefontsize' => false)) in mpdf.php line 30648
at mPDF->ConvertSize('0', '190.00155555556', '4.2333333333333', false) in mpdf.php line 20968
at mPDF->setCSS(array('MARGIN-COLLAPSE' => 'COLLAPSE', 'LINE-HEIGHT' => 'N', 'DIRECTION' => 'ltr', 'TEXT-INDENT' => '0mm', 'FONT-FAMILY' => 'dejavusanscondensed', 'FONT-SIZE' => '12pt', 'HYPHENS' => 'manual', 'WIDTH' => '"296"', 'HEIGHT' => '"440"'), 'BLOCK', 'DIV') in Tag.php line 1746

How to set a background image

Hello,
We want to add a image in background and in my html view its working bt when i stream its as pdf my background image not show

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.