Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globally background color #1502

Open
SamehArmouche opened this issue Mar 15, 2024 · 0 comments
Open

Globally background color #1502

SamehArmouche opened this issue Mar 15, 2024 · 0 comments

Comments

@SamehArmouche
Copy link

SamehArmouche commented Mar 15, 2024

Globally background color

When I add data to pdf and the data overflow to next page, background color is not showing in the next page, any suggestion?

Code sample

      const doc = new PDFDocument({autoFirstPage:false});
      const stream = doc.pipe(new Base64Encode());
      const fullnameKeys = ["firstname","fathername","lastname","id","img","img_url1","img_url2","img_url3"]
      //doc
      //.rect(0, 0, doc.page.width, doc.page.height).fill('#0A0A0A')

        data.map((item)=>{

          const fullname = getValue(item.firstname) + ' ' + getValue(item.fathername) + ' ' + getValue(item.lastname);
          
          doc
          .addPage()
          .font("fonts/static/Cairo-Bold.ttf")
          //.rect(0, 0, doc.page.width, doc.page.height).fill('#0A0A0A')
          .fontSize(20)
          .fillColor('black')
          .text(fullname, {align:'center',features: ['rtla']})
          doc.moveDown(1);
          Object.entries(item).forEach((entry) => {
            const [key, value] = entry;
            const string = key.toUpperCase() + " : " + getValue(value);
            if(!fullnameKeys.includes(key)){
              doc
              .font("fonts/static/Cairo-Light.ttf")
              .fontSize(12)
              .fillColor('black')
              .text(key.toUpperCase(), {align:'left', continued: true})
              .text(" : ", {align:'left', continued: true})
              .text(getValue(value).length>0?getValue(value):' ', {align:'left',features: ['rtla']});
              doc.moveDown(0.2);
            }

          });
          doc.moveDown(2);
        })
        
        doc.end();
     
## Your environment

* pdfkit version: 0.14.0
* Node version: 9.6.7
* Operating System: windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant