Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Sep 12, 2024 10:56 am

We want to decrese the checkbox size in editable pdf. We have try size , location , font size nothing works.

Code:

float xsize = 0f;
float ysize = 0f;
checkBoxField.Size = new System.Drawing.SizeF(xsize, ysize);

I have also attached the file for your ref.

Version# Spire.PDF 10.2.0

shankargidwani
 
Posts: 1
Joined: Thu Sep 12, 2024 10:47 am

Fri Sep 13, 2024 7:44 am

Hello,

Thanks for your inquiry. You can refer to the following code to set the size and position of the checkbox. If your test code is different, please provide your complete code for reference. Meanwhile, you can also directly test my code. If it still doesn't work, please also provide us with your system environment information(E.g. Win10, 64 bit). Thank you in advance.
Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"BSS-CMS-1500-Fillable-2022 1.pdf");
var form = (PdfFormWidget)doc.Form;
foreach (var field in form.FieldsWidget.OfType<PdfStyledFieldWidget>())
{
    // Determine if it is a checkbox
    if (field is PdfCheckBoxWidgetFieldWidget cb)
    {
        // Set checkbox size
        cb.Size = new SizeF(0f, 0f);
        // Set checkbox position
        PointF oldLocation = cb.Location;
        cb.Location = new PointF(oldLocation.X, oldLocation.Y + 4f);
    }
}
doc.SaveToFile(@"result.pdf");

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 164
Joined: Mon Jul 15, 2024 5:40 am

Return to Spire.PDF

cron