How to Change CheckBox Icon from Checkmark to Cross  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
RudiRo
User
Posts: 6
Joined: Mon Jul 24, 2023 6:50 am

How to Change CheckBox Icon from Checkmark to Cross

Post by RudiRo »

Hi,

I'm trying to create a new Pdf Document with some FormFields.
The Default Checkbox Icon Displayed in my Document is a Checkmark.
Checkmark
Checkmark
image.png (1.04 KiB) Viewed 11065 times
Is it possible to change the Icon to a Cross instead ? In the Editor a Option is given.
Cross
Cross
image(1).png (698 Bytes) Viewed 11065 times
Code to Create CheckBox:

var ff = m_Document.AcroForm.CreateField("AB", PXC_FormFieldType.FFT_CheckBox, currentPage, mediaBox);
ff.CheckWidget(0, true);

Creation of the CheckBox works fine, i just need a hint where i could find the Option to Change the IconStyle.
For TextFields Color and FontSize could be set with the Interface "IPXC_AnnotData_Widget" , but can't find a suitable Interface / Method for Changing the Icon.

Thank you
Rudi
User avatar
Sean - Tracker
Site Admin
Posts: 175
Joined: Wed Sep 14, 2016 5:42 pm
Location: British Columbia

Re: How to Change CheckBox Icon from Checkmark to Cross

Post by Sean - Tracker »

Hi Rudiro,

You can determine that option in the properties pane for selected check boxes, in the CheckBox Style property dropdown menu, where a range of options are available, including the 'cross' option which you requested:

image.png

Kind regards,
Sean Godley
Technical Writer
Tracker Software Products (Canada) LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
RudiRo
User
Posts: 6
Joined: Mon Jul 24, 2023 6:50 am

Re: How to Change CheckBox Icon from Checkmark to Cross

Post by RudiRo »

Hi Sean,

Thank you very much, but im looking for a option to achieve this style, in the Creation of the Checkbox in my C# Code.

Sample Code for Visualisation:

PXV_Inst m_PdfInst = new PXV_Inst();
IPXC_Document m_Document = m_PdfInst.NewCoreDoc();
var mediaBox = new PXC_Rect();
mediaBox.top = m_PageHeight;
mediaBox.right = m_PageWidth;
mediaBox.left = 0;
mediaBox.bottom = 0;
m_Document.Pages.AddEmptyPages(0, 1, mediaBox, null, out undoData);
uint currentPage = m_Document.Pages.Count - 1;
var mediaBox = new PXC_Rect();
mediaBox.top = m_PageHeight - 20;
mediaBox.bottom = m_PageHeight - 40;
mediaBox.left = 220;
mediaBox.right = 240;

var ff = m_Document.AcroForm.CreateField("AB", PXC_FormFieldType.FFT_CheckBox, currentPage, mediaBox);
ff.CheckWidget(0, true);

And here im looking for the Option to Change the Icon of my created CheckBox

IAFS_Inst fsInst = (IAFS_Inst)m_PdfInst.GetExtension("AFS");
IAFS_Name destPath = fsInst.DefaultFileSys.StringToName(fileName);
m_Document.WriteTo(destPath);

Thank you
Rudi
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: How to Change CheckBox Icon from Checkmark to Cross

Post by Tracker Supp-Stefan »

Hello Rudi,

Thanks for the additional details.
I've asked a colleague from the dev team who works on the JS engine to take a look, and will post further info here in this topic once I've received their feedback.

Kind regards,
Stefan
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: How to Change CheckBox Icon from Checkmark to Cross

Post by Ivan - Tracker Software »

CheckBox 'icon' is set using the Content property of the corresponding widget. Just use the IPXC_AnnotData_Widget interface as you did for setting up font size and color, but now use the Content property.
It should have the following value:
"4" - for check-mark
"l" - (small letter L) - for circle
"8" - cross
"u" - diamond
"n" - square
"H" - star

That's because for rendering the icon, one of the standard built-in PDF fonts - ZapfDingbats - is used. Technically, you can use any of its characters as an icon. I attached screenshots from the PDF specification with its characters set. Please note, values in the "Code" columns are octal.

P.S. In the case of the cross ("8") font is not used.
image.png
image(1).png
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
RudiRo
User
Posts: 6
Joined: Mon Jul 24, 2023 6:50 am

Re: How to Change CheckBox Icon from Checkmark to Cross

Post by RudiRo »

Hello Ivan,

Thank you for the explanation.
Sadly i can't seem to get it to work.

I get the IPXC_AnnotData_Widget interface from my created FormField.

var ff = m_Document.AcroForm.CreateField("AB", PXC_FormFieldType.FFT_CheckBox, currentPage, mediaBox);
IPXC_Annotation widget = ff.Widget[0];
IPXC_AnnotData aData = widget.Data;
IPXC_AnnotData_Widget aWData = (IPXC_AnnotData_Widget)aData;


The aWData.Contents Property returns an Empty String("")

Setting it to another value and returning it to the widget has no effect.

aWData.Contents = "8";
widget.Data = aWData;


Am i misinterpreting the "Content" property ?

I can't find a Property in aWData with a Default Value of "4" for the Default Checkmark.

Thanks in Advance
Rudi
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: How to Change CheckBox Icon from Checkmark to Cross  SOLVED

Post by Ivan - Tracker Software »

Sorry, my bad, I mislead you a little bit.
Instead of using aWData.Contents = "8", please use

Code: Select all

aWData.SetCaption(AAT_Normal, "8", true)
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
RudiRo
User
Posts: 6
Joined: Mon Jul 24, 2023 6:50 am

Re: How to Change CheckBox Icon from Checkmark to Cross

Post by RudiRo »

Hello,

Thank you all very much.
Works perfectly.

Rudi
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

How to Change CheckBox Icon from Checkmark to Cross

Post by Tracker Supp-Stefan »

:)
Post Reply