Having consistent margins for each page with chrome-pdf



  • I'm using jsreport-core together with jsreport-chrome-pdf. I'm using following code:

    import jsreportCore, { Response } from "jsreport-core";
    
    const _jsreport = jsreportCore({
      extensions: {
        "chrome-pdf": {
          marginTop: "30px",
          marginLeft: 100,
        },
      },
    });
    

    which doesn't seem to work. I have along table that spans across multiple pages and following pages does not have any margin at all.


  • administrators

    hi!

    which doesn't seem to work. I have along table that spans across multiple pages and following pages does not have any margin at all

    there are two types of options, extensions options and template request options, the extension options are the ones you can pass during core initialization, the template options are the options you can pass in .render().

    the marginTop, marginLeft options of chrome are part of template options, so in order for them to work you need to pass it like this:

    .render({
      template: {
        // ... other options here...
        chrome: {
          marginTop: '30px',
          marginLeft: '10px'
        }
        // ... other options here...
      }
    })
    


  • Thank you @bjrmatos ,

    But typescript complains:

    Type '{ chrome: { marginTop: string; marginLeft: string; }; content: string; engine: string; recipe: string; }' is not assignable to type 'Template'.
      Object literal may only specify known properties, and 'chrome' does not exist in type 'Template'.ts(2322)
    index.d.ts(61, 9): The expected type comes from property 'template' which is declared here on type 'Request'
    

  • administrators

    did you saw this example with typescript? you probably are missing some typedef installation


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.