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

skips invisible form fields #265

Open
jelizarovas opened this issue Feb 22, 2022 · 1 comment
Open

skips invisible form fields #265

jelizarovas opened this issue Feb 22, 2022 · 1 comment

Comments

@jelizarovas
Copy link

image

If a field is set to initially hidden (even though can be changed visibility with custom calculation script:

if (this.getField("needsWeight").value == "Yes") {
event.target.display = display.visible;
} else {
event.target.display = display.hidden;
}

These fields (hidden ones) will not be parsed, and you will not get any data on them (coordinates, names, etc.)

Was this intended and is there a way to enable hidden field parsing?

@jelizarovas
Copy link
Author

async function testp2j() {
  const fs = require("fs"),
    PDFParser = require("pdf2json");
    const cuid = require("cuid");

  const pdfParser = new PDFParser();
  pdfParser.on("pdfParser_dataError", (errData) => console.error(errData.parserError));
  pdfParser.on("pdfParser_dataReady", (pdfData) => {
    fs.writeFile(`../build/${cuid.slug()}.json`, JSON.stringify(pdfData), () => {
      console.log("Done.");
    });
  });

  pdfParser.loadPDF(filePath);
}


See the following form
invisibleForm.pdf

Output is:

[...]
 "Pages": [
    {
      "Width": 38.25,
      "Height": 49.5,
      "HLines": [],
      "VLines": [],
      "Fills": [],
      "Texts": [],
      "Fields": [
        {
          "style": 48,
          "T": { "Name": "alpha", "TypeInfo": {} },
          "id": { "Id": "Visible", "EN": 0 },
          "TI": 0,
          "AM": 0,
          "x": 11.599,
          "y": 13.964,
          "w": 10.707,
          "h": 1.876
        }
      ],
      "Boxsets": []
    }
  ]
[...]

But if i change second field to visible i get this output:

[...]
"Pages": [
    {
      "Width": 38.25,
      "Height": 49.5,
      "HLines": [],
      "VLines": [],
      "Fills": [],
      "Texts": [],
      "Fields": [
        {
          "style": 48,
          "T": { "Name": "alpha", "TypeInfo": {} },
          "id": { "Id": "Visible", "EN": 0 },
          "TI": 0,
          "AM": 0,
          "x": 11.599,
          "y": 13.964,
          "w": 10.707,
          "h": 1.876
        },
        {
          "style": 48,
          "T": { "Name": "alpha", "TypeInfo": {} },
          "id": { "Id": "Hidden", "EN": 0 },
          "TI": 1,
          "AM": 0,
          "x": 11.388,
          "y": 21.836,
          "w": 11.29,
          "h": 2.188
        }
      ],
      "Boxsets": []
    }
  ]
[...]

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