Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php use Spatie\Browsershot\Browsershot; it('can save a pdf by using the pdf extension'..
Decoded Output download
<?php
use Spatie\Browsershot\Browsershot;
it('can save a pdf by using the pdf extension', function () {
$targetPath = __DIR__.'/temp/testPdf.pdf';
Browsershot::url('https://example.com')
->save($targetPath);
expect($targetPath)->toBeFile();
expect(mime_content_type($targetPath))->toEqual('application/pdf');
});
it('can save a highly customized pdf', function () {
$targetPath = __DIR__.'/temp/customPdf.pdf';
Browsershot::url('https://example.com')
->hideBrowserHeaderAndFooter()
->showBackground()
->landscape()
->margins(5, 25, 5, 25)
->pages('1')
->savePdf($targetPath);
expect($targetPath)->toBeFile();
expect(mime_content_type($targetPath))->toEqual('application/pdf');
});
it('can save a highly customized pdf when using pipe', function () {
$targetPath = __DIR__.'/temp/customPdf.pdf';
Browsershot::url('https://example.com')
->usePipe()
->hideBrowserHeaderAndFooter()
->showBackground()
->landscape()
->margins(5, 25, 5, 25)
->pages('1')
->savePdf($targetPath);
expect($targetPath)->toBeFile();
expect(mime_content_type($targetPath))->toEqual('application/pdf');
});
it('can save a pdf with the taggedPdf option', function () {
$targetPath = __DIR__.'/temp/customPdf.pdf';
Browsershot::url('https://example.com')
->taggedPdf()
->pages('1')
->savePdf($targetPath);
expect($targetPath)->toBeFile();
expect(mime_content_type($targetPath))->toEqual('application/pdf');
});
it('can return a pdf as base 64', function () {
$base64 = Browsershot::url('https://example.com')
->base64pdf();
expect(is_string($base64))->toBeTrue();
});
it('can write options to a file and generate a pdf', function () {
$targetPath = __DIR__.'/temp/testPdf.pdf';
Browsershot::url('https://example.com')
->writeOptionsToFile()
->save($targetPath);
expect($targetPath)->toBeFile();
expect(mime_content_type($targetPath))->toEqual('application/pdf');
});
it('can generate a pdf with custom paper size unit', function () {
$command = Browsershot::url('https://example.com')
->paperSize(8.3, 11.7, 'in')
->margins(0.39, 0.78, 1.18, 1.57, 'in')
->createPdfCommand('screenshot.pdf');
$this->assertEquals([
'url' => 'https://example.com',
'action' => 'pdf',
'options' => [
'path' => 'screenshot.pdf',
'margin' => [
'top' => '0.39in',
'right' => '0.78in',
'bottom' => '1.18in',
'left' => '1.57in',
],
'viewport' => [
'width' => 800,
'height' => 600,
],
'width' => '8.3in',
'height' => '11.7in',
'args' => [],
],
], $command);
});
?>
Did this file decode correctly?
Original Code
<?php
use Spatie\Browsershot\Browsershot;
it('can save a pdf by using the pdf extension', function () {
$targetPath = __DIR__.'/temp/testPdf.pdf';
Browsershot::url('https://example.com')
->save($targetPath);
expect($targetPath)->toBeFile();
expect(mime_content_type($targetPath))->toEqual('application/pdf');
});
it('can save a highly customized pdf', function () {
$targetPath = __DIR__.'/temp/customPdf.pdf';
Browsershot::url('https://example.com')
->hideBrowserHeaderAndFooter()
->showBackground()
->landscape()
->margins(5, 25, 5, 25)
->pages('1')
->savePdf($targetPath);
expect($targetPath)->toBeFile();
expect(mime_content_type($targetPath))->toEqual('application/pdf');
});
it('can save a highly customized pdf when using pipe', function () {
$targetPath = __DIR__.'/temp/customPdf.pdf';
Browsershot::url('https://example.com')
->usePipe()
->hideBrowserHeaderAndFooter()
->showBackground()
->landscape()
->margins(5, 25, 5, 25)
->pages('1')
->savePdf($targetPath);
expect($targetPath)->toBeFile();
expect(mime_content_type($targetPath))->toEqual('application/pdf');
});
it('can save a pdf with the taggedPdf option', function () {
$targetPath = __DIR__.'/temp/customPdf.pdf';
Browsershot::url('https://example.com')
->taggedPdf()
->pages('1')
->savePdf($targetPath);
expect($targetPath)->toBeFile();
expect(mime_content_type($targetPath))->toEqual('application/pdf');
});
it('can return a pdf as base 64', function () {
$base64 = Browsershot::url('https://example.com')
->base64pdf();
expect(is_string($base64))->toBeTrue();
});
it('can write options to a file and generate a pdf', function () {
$targetPath = __DIR__.'/temp/testPdf.pdf';
Browsershot::url('https://example.com')
->writeOptionsToFile()
->save($targetPath);
expect($targetPath)->toBeFile();
expect(mime_content_type($targetPath))->toEqual('application/pdf');
});
it('can generate a pdf with custom paper size unit', function () {
$command = Browsershot::url('https://example.com')
->paperSize(8.3, 11.7, 'in')
->margins(0.39, 0.78, 1.18, 1.57, 'in')
->createPdfCommand('screenshot.pdf');
$this->assertEquals([
'url' => 'https://example.com',
'action' => 'pdf',
'options' => [
'path' => 'screenshot.pdf',
'margin' => [
'top' => '0.39in',
'right' => '0.78in',
'bottom' => '1.18in',
'left' => '1.57in',
],
'viewport' => [
'width' => 800,
'height' => 600,
],
'width' => '8.3in',
'height' => '11.7in',
'args' => [],
],
], $command);
});
Function Calls
None |
Stats
MD5 | b8164380683de6052fddd68f878b4516 |
Eval Count | 0 |
Decode Time | 89 ms |