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?
If we could add a method name PageNo() on PDFPage level then from textField we can refer to PDFPage & from page. we can get page number.
I am not 100% sure about how this could be implemented, but it is for sure improve performance for large pdf files i.e. pdf files with large no of of fields per page & lot of pages.
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?
I am working on a api that extracts fillable pdf fields in order of the display on the pdf.
multipage_pdf_fields.pdf
To sort all the fields I need page no, x coordinate, y coordinate .
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
How could this be implemented?
PageNo()
on PDFPage level then from textField we can refer to PDFPage & from page. we can get page number.What problem are you trying to solve?
Why does this matter to you?
I am working on a api that extracts fillable pdf fields in order of the display on the pdf. multipage_pdf_fields.pdf
To sort all the fields I need
page no
,x coordinate
,y coordinate
.x & y coordinates are accessible using
getWidgets()
as in https://github.com/Hopding/pdf-lib/discussions/1490But for
pageno
its only possible through loop as discussed in https://github.com/Hopding/pdf-lib/issues/1090#issuecomment-970910486 which is not efficientI need efficient method to do so
Would others find this helpful?
pdf documents
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