Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
6.74k stars 645 forks source link

Method to get pageNumber for each TextFields in pdf-lib #1494

Open satyajitnayk opened 1 year ago

satyajitnayk commented 1 year ago

Describe your idea

:rocket: A method to get pageNo for each text fields can be implemented. :hourglass_flowing_sand: It will optimise time take to find page number using loop method as described in https://github.com/Hopding/pdf-lib/issues/1090#issuecomment-970910486

import {PDFDocument} from 'pdf-lib';
const pdfDocument = PDFDocument.load("file_path")
pdfDocument
        .getForm()
        .getFields()
        .map((_) => {
          return {
            pageNo: // ??? Need Logic to do so//
            name: _.getName(),
            type: _ instanceof PDFCheckBox ? 'generic' : 'string',
          };
        })

How could this be implemented?

What problem are you trying to solve?

import {PDFDocument} from 'pdf-lib';
const pdfDocument = PDFDocument.load("file_path")
pdfDocument
        .getForm()
        .getFields()
        .map((_) => {
          return {
            pageNo: // ??? Need Logic to do so//
            name: _.getName(),
            type: _ instanceof PDFCheckBox ? 'generic' : 'string',
          };
        })

Why does this matter to you?

Would others find this helpful?

Are you interested in implementing your proposal?

Yes, but might need inputs from maintainer/others too.

Why are you submitting a proposal?

Additional Notes

No response