title: How to Access PageNumber and TotalPages variables in Puppeteer
body: <p>So im generating multiple PDFs from URLS, then i use easy-pdf-merge to combine these PDFs,</p>
  
  <p>I would like to be able to update the pageNumber and totalPages in every footer, so i would like to get the first PDFs totalPages and Page number and save that in a variable, then every PDF that gets created after will use the new variable i created + the previous pageNumber and totalPages.
  "Search Page number" and you will find the options.
  <a href="https://pptr.dev/#?product=Puppeteer&amp;version=v1.19.0&amp;show=api-class-page" rel="noreferrer">https://pptr.dev/#?product=Puppeteer&amp;version=v1.19.0&amp;show=api-class-page</a></p>
  
  <p>Is this possible? I see in the pdf.options there are totalPages and pageNumber options.</p>
  
  <pre><code>const puppeteer = require('puppeteer');
  
  class Webpage {
      static async generatePDF(url) {
          const browser = await puppeteer.launch({ headless: true }); // Puppeteer can only generate pdf in headless mode.
          const page = await browser.newPage();
  
          await page.goto(url); // Adjust network idle as required. 
          const pdfConfig = {
              path: 'home.pdf', // Saves pdf to disk. 
              // format: 'A4',
              printBackground: true,
              margin: { // Word's default A4 margins
                  top: '2.54cm',
                  bottom: '2.54cm',
                  left: '2.54cm',
                  right: '2.54cm'
              },
              width: 1860,
              height: 2631
  
          };
          await page.emulateMedia('screen');
          const pdf = await page.pdf(pdfConfig); // Return the pdf buffer. Useful for saving the file not to disk. 
  
          await browser.close();
  
          return pdf;
      }
  }
  
  (async() =&gt; {
      const url = ['https://google.com/'];
      // doing some checks here to get more than 1 url
      if(url &gt; 1){
          for(i=0;i&lt;url.length;i++){
                  await Webpage.generatePDF(url[i]);
          }
      }
  })();
  </code></pre>
  
  <p>i have done some digging, and found this question <a href="https://stackoverflow.com/questions/51458286/how-does-header-and-footer-printing-work-in-puppeters-page-pdf-api/51460641#51460641">How does header and footer printing work in Puppeter&#39;s page.pdf API?</a></p>
  
  <p>which helps a lot with understanding what is going on with puppeteer at the time, it seems to use Skia, which in turn uses chrome tools and this is where the page numbers come from in the end. </p>
  
  <p><a href="https://chromedevtools.github.io/devtools-protocol/tot/Page#method-printToPDF" rel="noreferrer">https://chromedevtools.github.io/devtools-protocol/tot/Page#method-printToPDF</a></p>
  
  <p>but i still have no idea how i can save and use this variable for what i want to do.</p>