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

Border default #682

Closed
btecu opened this issue Nov 20, 2020 · 7 comments · Fixed by #696
Closed

Border default #682

btecu opened this issue Nov 20, 2020 · 7 comments · Fixed by #696

Comments

@btecu
Copy link
Contributor

btecu commented Nov 20, 2020

If a TextField has a background color but no border (transparent), the library adds a black border of value one by default:

const borderWidth = bs?.getWidth() ?? 1;

So a field with a white background color end up looking like this:
image

Instead they should look like this:
image

@vielhuber
Copy link

This is still the case on 1.17.1, or am I wrong?

image

@btecu
Copy link
Contributor Author

btecu commented Mar 25, 2022

@vielhuber check your PDF, maybe the inputs have a border set.

@vielhuber
Copy link

vielhuber commented Mar 25, 2022

Hmm, this looks quite clean beforehand:
image
image

Output with pdf-lib:
image

This is the original PDF:
dummy2.pdf

When the "fill color" is transparent and no border is set in the pdf, it has a border after processing it with pdf-lib:
image
image

If the "fill color" is set to white and no border is set in the pdf, the behaviour is correct and it has no border after processing with pdf-lib:
image

@vielhuber
Copy link

Can you reproduce this issue on your side?

@epratt000
Copy link

I'm running into this same issue. I'm using V1.17.1.

I'm creating a bran new text field on a page and I'm only setting x, y, width, and height.

It shows a black border around the field.

    const pdfPage = pdf.getPage(1);
    const font = await pdf.embedFont(StandardFonts.Helvetica);
    const options = {
        x: 250,
        Y: 715,
        width: 25,
        height: 10
    };
    const newField = pdf.getForm().createTextField('newField');
    newField.addToPage(pdfPage, options);
    newField.defaultUpdateAppearances(font);
    
    const savedPdf = await pdf.save({ updateFieldAppearances: true });

The existing PDF that was loaded has no border selected on every single existing field

image

@stx-chris
Copy link

This issue still persists for PDFCheckBox fields which have transparent background. Currently it is not possible to get rid of the border (by setting it to 0 or undefined). Is there a workaround?

@lbesiche
Copy link

lbesiche commented Jan 1, 2024

I don't know if this answers your question, but if you would like to remove the border of a text field. I notice you can set the borderColor when you add the textfield to the page:

const page = pdfDoc.getPage(0);
  const textField = form.createTextField(fieldName);

  textField.addToPage(page, {
    x,
    y,
    width,
    height,
    borderColor: rgb(1, 1, 1),
  });

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

Successfully merging a pull request may close this issue.

5 participants