Code Monkey home page Code Monkey logo

Comments (11)

zeroasterisk avatar zeroasterisk commented on July 29, 2024 1

Since: #32 (found on #28)

You can set this in your options (all of which are passed to wkhtmltopdf):

$config = [
    'CakePdf' => [
        'engine' => 'CakePdf.WkHtmlToPdf',
        'options' => [
            'print-media-type' => false,
            'outline'          => true,
            'dpi'              => 96,
            'footer-center'     => 'foobar HERE © ' . date('Y'),
            'footer-right'     => 'Page [page] of [toPage]',
        ],
        'pageSize' => 'letter',
        'orientation' => 'landscape',
        'margin' => [
            'bottom' => 15,
            'left'   => 50,
            'right'  => 30,
            'top'    => 45
        ],

It looks like there are some forks which have better integration for these settings

from cakepdf.

nizam27391 avatar nizam27391 commented on July 29, 2024

Also how to set the page number also. Can I know this. Because this seems to be an important features. If you already did it, perhaps you can put it in a proper documentation.

Thanx

from cakepdf.

zeroasterisk avatar zeroasterisk commented on July 29, 2024

fyi: #83

from cakepdf.

nizam27391 avatar nizam27391 commented on July 29, 2024

Hi zeroasterisk, nice info.
Does it support element to be set as header / footer also. I've seen quite a discussion about this in #83.

Do you happen to have a really good documentation on how to do this? Thanks

from cakepdf.

zeroasterisk avatar zeroasterisk commented on July 29, 2024

I have some example documentation with my PR on the README:
https://github.com/FriendsOfCake/CakePdf/pull/83/files#diff-04c6e90faac2675aa89e2176d2eec7d8R122

I haven't looked at this in a while, so the PR has not progressed, but I still think this is a good idea... header/footer being a very important piece of any PDF system. The truth is, you can make it work without my PR, my PR was tooling to try to make it simpler and more obvious... You can make a .html file and pass the path to that as an option to wkhtmltopdf and that should work.

from cakepdf.

nizam27391 avatar nizam27391 commented on July 29, 2024

Nice zeroasterisk, so we can just use $this->element('element') as our header and footer right.. Thanks!

from cakepdf.

amit4mins avatar amit4mins commented on July 29, 2024

Hi,

Is there any way to add html content to footer Like "Powered By with an image"??

Thanks In Advance,
Amit

from cakepdf.

zeroasterisk avatar zeroasterisk commented on July 29, 2024

@amitpanwar86 yes - just put it in the HTML as an <img with a full URL as the src

from cakepdf.

filippogiordano avatar filippogiordano commented on July 29, 2024

This code doesn't add any header/footer on my pdf..
Do you know why?
I'm using cakephp 3.1 and my cakepdf component is working on the engine WkHtmlToPdf.
This is my code:
$this->viewBuilder()->options([
'pdfConfig' => [
'filename' => 'audizione_' . $id.'.pdf',
//'print-media-type' => false,
//'outline' => true,
'dpi' => 500,
'margin' => [
'bottom' => 5,
'left' => 4,
'right' => 4,
'top' => 5
],
'orientation' => 'portrait',
'download' => true,
'header-html' =>'Ciao'
//'engine' => 'CakePdf.WkHtmlToPdf',
'options' => [
'print-media-type' => false,
'outline' => true,
'dpi' => 96,
'footer-center' => 'foobar HERE © ' . date('Y'),
'footer-right' => 'Page [page] of [toPage]',
],
]
]);

from cakepdf.

rthakur avatar rthakur commented on July 29, 2024

@filippogiordano please check wkhtmltopdf --version

from cakepdf.

filippogiordano avatar filippogiordano commented on July 29, 2024

I solved the problem with this configuration.
Configure::write('CakePdf', [
'engine' => [
'className' => 'CakePdf.WkHtmlToPdf',
'binary' => '/usr/local/bin/wkhtmltopdf',
'options' => [
'print-media-type' => false,
'outline' => true,
'dpi' => 500,
'header-html'=>"http://.....headeraddress",
'footer-html'=>"http://...footeraddress",
'footer-right'=>"Pag. [page] di [toPage]",
'header-spacing'=>1,
'footer-spacing' => '1',
],
],
'margin' => [
'bottom' => 20,
'left' => 20,
'right' => 20,
'top' => 45
],
'download' => false
]);

and adding to the first line of my header and footer html:

from cakepdf.

Related Issues (20)

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.