PowerBuilder and Form Fields
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.
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.
-
- User
- Posts: 31
- Joined: Thu Sep 20, 2018 12:45 am
PowerBuilder and Form Fields
We're looking for examples (and don't immediately see any in the Full Demo Samples) of Form Field methods. Specifically, for example with the attached PDF, we'd like to be able to do the following:
a) get a count of all the form fields in the PDF Form
b) get the name and type (checkbox, text, etc.) of each field
c) loop thru each form field and get the value that has been pre-populated in the field. In the case of a drop down combobox, would also like to get each value in the list
d) for each field in the form, set a value.
Our development platform is PowerBuilder 2018, but any examples in C#, Delphi or VB would be appreciated.
a) get a count of all the form fields in the PDF Form
b) get the name and type (checkbox, text, etc.) of each field
c) loop thru each form field and get the value that has been pre-populated in the field. In the case of a drop down combobox, would also like to get each value in the list
d) for each field in the form, set a value.
Our development platform is PowerBuilder 2018, but any examples in C#, Delphi or VB would be appreciated.
- Attachments
-
- test_form.pdf
- (86.75 KiB) Downloaded 108 times
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: PowerBuilder and Form Fields
Hello greg.rusak@mustimuhw.solutions,
Try this project - there are many form fields samples that you can try to understand them a little:
https://github.com/tracker-software/PDFCoreSDKExamples
Also, here's an operation to modify the form fields with few samples included (you can search for more on forums):
https://sdkhelp.pdf-xchange.com/vi ... lds_modify
Though if you have a XFA document, you can't modify those fields.
Cheers,
Alex
Try this project - there are many form fields samples that you can try to understand them a little:
https://github.com/tracker-software/PDFCoreSDKExamples
Also, here's an operation to modify the form fields with few samples included (you can search for more on forums):
https://sdkhelp.pdf-xchange.com/vi ... lds_modify
Though if you have a XFA document, you can't modify those fields.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 31
- Joined: Thu Sep 20, 2018 12:45 am
Re: PowerBuilder and Form Fields
Hello Alex,
Thanks for your help so far.
We've made a bit of progress, but are still not able to loop through all of the form fields on a form and get the field name or value. None of the examples, from what we can see get a name of a field by an index value. We see that there is the GetFieldByName Methond of the IPXC_AcroForm Interface, but that appears to require a "named" field. Here's what we done so far:
So we can get a handle to the AcroForm and get a count of the number of fields on the form, but the loop that currently doesn't work needs to get the name of each of these fields.
Any suggestions on what we can do here?
Thanks again.
Greg
Thanks for your help so far.
We've made a bit of progress, but are still not able to loop through all of the form fields on a form and get the field name or value. None of the examples, from what we can see get a name of a field by an index value. We see that there is the GetFieldByName Methond of the IPXC_AcroForm Interface, but that appears to require a "named" field. Here's what we done so far:
Code: Select all
lb_result = ole_tracker_pdf.Object.SetLicKey(ls_key)
ole_tracker_pdf.object.OpenDocFromPath(this.is_temp_file, lole_null)
lole_frame = ole_tracker_pdf.object.frame
lole_inst = ole_tracker_pdf.object.inst
lole_doc = ole_tracker_pdf.Object.doc
lole_coredoc = lole_doc.CoreDoc
IF lole_coredoc.HasAcroForm THEN
MessageBox("PDF", "Has AcroForm")
END IF
ll_fieldscount = lole_coredoc.AcroForm.FieldsCount
MessageBox("FieldsCount", String(ll_fieldscount))
// The following loop currently does not work.
FOR ll_count = 0 TO ll_fieldscount
lole_field = lole_coredoc.AcroForm.Field[ll_count]
ls_formfield = String(lole_field.MappingName)
MessageBox("Field", String(ls_formfield))
NEXT
Any suggestions on what we can do here?
Thanks again.
Greg
- Ivan - Tracker Software
- Site Admin
- Posts: 3550
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
- Contact:
Re: PowerBuilder and Form Fields
While Alex on vacation, I can try to help you. Unfortunately, I do not work with PowerBuilder or C#, but I can show you an example on C++. It is quite simple, and I guess there are no problem to get the concept:
Code: Select all
IPXC_AcroFormPtr pAcroForm = coredoc->AcroForm;
int numFields = pAcroForm->FieldsCount;
for (int i = 0; i < numFields; i++)
{
IPXC_FormFieldPtr pField = pAcroForm->Field[i];
cout << "name: " << pField->FullName;
cout << "type: " << (int)pField->Type;
cout << "value: " << pField->GetValueText();
}
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.
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.
-
- User
- Posts: 31
- Joined: Thu Sep 20, 2018 12:45 am
Re: PowerBuilder and Form Fields
Hello Ivan,
Thank you very much for the quick response and the simple code snippet. We were able to get our PowerBuilder code to work based on your C++.
We'll likely have more questions as we progress, but for now, can you tell me what Type = 4 and Type = 5 represents. I don't see any documentation on this. I'm guessing it's something like 4 = textbox and 5 = combobox? Do you have a complete mapping for all values?
Again thanks for this. Looking better now from our stand point.
Regards,
Greg
Thank you very much for the quick response and the simple code snippet. We were able to get our PowerBuilder code to work based on your C++.
We'll likely have more questions as we progress, but for now, can you tell me what Type = 4 and Type = 5 represents. I don't see any documentation on this. I'm guessing it's something like 4 = textbox and 5 = combobox? Do you have a complete mapping for all values?
Again thanks for this. Looking better now from our stand point.
Regards,
Greg
-
- User
- Posts: 31
- Joined: Thu Sep 20, 2018 12:45 am
Re: PowerBuilder and Form Fields
After some more digging into the help files, I was able to find:
So now I guess my next step is to determine how to populate the ComboBox with a list of values. Is that something that can be done with this interface.
It would be something like the following:
Can you help with inserting a list of values into a combobox.
Thanks in advance.
Greg
Code: Select all
enum PXC_FormFieldType
{
FFT_Unknown = 0,
FFT_PushButton = 1,
FFT_RadioButton = 2,
FFT_CheckBox = 3,
FFT_Text = 4,
FFT_ComboBox = 5,
FFT_ListBox = 6,
FFT_Signature = 7,
FFT_Barcode = 8,
FFT_TypeMax = 9,
};
It would be something like the following:
Code: Select all
lole_field = lole_AcroForm.Field[ll_count]
ls_formfield = String(lole_field.FullName)
ls_type = String(lole_field.Type)
ls_value = String(lole_field.GetValueText())
IF ls_type = '5' THEN // a combobox
// Insert a number of rows into the combobox identifying both a code and a display description
END IF
Thanks in advance.
Greg
-
- User
- Posts: 31
- Joined: Thu Sep 20, 2018 12:45 am
Re: PowerBuilder and Form Fields
Maybe I'll thoroughly check the help files next time before posting. The following code now works to populate items in a combobox. Your help regardless has been appreciated.
Code: Select all
FOR ll_count = 0 TO ll_fieldscount - 1
lole_field = lole_AcroForm.Field[ll_count]
ls_formfield = String(lole_field.FullName)
ls_type = String(lole_field.Type)
ls_value = String(lole_field.GetValueText())
MessageBox("Field", String(ls_formfield) + "~r~n~r~n" + String(ls_type) + "~r~n~r~n" + String(ls_value))
IF ls_type = '5' THEN //combobox
lole_field.InsertOptRecord("lable1", "First Item");
END IF
NEXT
- Tracker Supp-Stefan
- Site Admin
- Posts: 17941
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: PowerBuilder and Form Fields
Hello Greg!
Glad to hear all is now working well!
And thanks for sharing your working code - hope it will be useful to others as well!
Cheers,
Stefan
Glad to hear all is now working well!
And thanks for sharing your working code - hope it will be useful to others as well!
Cheers,
Stefan
-
- User
- Posts: 31
- Joined: Thu Sep 20, 2018 12:45 am
Re: PowerBuilder and Form Fields
Hello Stefan,
We're still in the process of evaluating your product (after getting side tracked for other work for the past little while), and have come across something else we do not understand.
According to your documentation, the SrcInfo Property (https://sdkhelp.pdf-xchange.com/vi ... nt_SrcInfo) and the Info Property (https://sdkhelp.pdf-xchange.com/vi ... ument_Info) are very similar in that they both return pointers as follows:
HRESULT get_SrcInfo([out, retval] IPXC_DocSrcInfo** pInfo);
HRESULT get_Info([out, retval] IPXC_DocumentInfo** pDocInfo);
However when we try the following code in our PowerBuilder application, the SrcInfo returns a valid pointer to the ole object and we are able to reference properties of the IPXC_DocSrcInfo Interface, but for the Info Interface we get a NULL pointer to the ole object.
For example, this code to get the SrcInfo works and the properties of the SrcInfo are displayed in the messageboxes::
... but this code does not and returns a NULL pointer and the messagebox shows "Not Valid":
Once we figure this out, we have one more similar issue we are dealing with for the AddImageFromFile() method - but let's understand this first if you can help.
If you could provide a similar code example in VB (win32) that shows what we are doing wrong here or a known issue, we can use that to translate to our PowerBuilder code.
Thanks You.
Greg
We're still in the process of evaluating your product (after getting side tracked for other work for the past little while), and have come across something else we do not understand.
According to your documentation, the SrcInfo Property (https://sdkhelp.pdf-xchange.com/vi ... nt_SrcInfo) and the Info Property (https://sdkhelp.pdf-xchange.com/vi ... ument_Info) are very similar in that they both return pointers as follows:
HRESULT get_SrcInfo([out, retval] IPXC_DocSrcInfo** pInfo);
HRESULT get_Info([out, retval] IPXC_DocumentInfo** pDocInfo);
However when we try the following code in our PowerBuilder application, the SrcInfo returns a valid pointer to the ole object and we are able to reference properties of the IPXC_DocSrcInfo Interface, but for the Info Interface we get a NULL pointer to the ole object.
For example, this code to get the SrcInfo works and the properties of the SrcInfo are displayed in the messageboxes::
Code: Select all
lole_sourceinfo = lole_coredoc.SrcInfo
IF IsValid(lole_sourceinfo) THEN
MessageBox("lole_coredoc.SrcInfo", "Valid")
MessageBox("ActualFileName", String(lole_sourceinfo.ActualFileName))
MessageBox("CustDispFileName", String(lole_sourceinfo.CustDispFileName))
MessageBox("DispFileName", String(lole_sourceinfo.DispFileName))
MessageBox("DispFileTitle", String(lole_sourceinfo.DispFileTitle))
MessageBox("DispTitle", String(lole_sourceinfo.DispTitle))
MessageBox("File", String(lole_sourceinfo.File))
ELSE
MessageBox("lole_coredoc.SrcInfo", "Not Valid")
END IF
Code: Select all
lole_info = lole_coredoc.Info
IF IsValid(lole_info) THEN
MessageBox("lole_coredoc.Info", "Valid")
MessageBox("DocInfo_Title", String(lole_info.DocInfo_Title))
ELSE
MessageBox("lole_coredoc.Info", "Not Valid")
END IF
If you could provide a similar code example in VB (win32) that shows what we are doing wrong here or a known issue, we can use that to translate to our PowerBuilder code.
Thanks You.
Greg
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: PowerBuilder and Form Fields
Hello Greg,
If you could have noticed, the DocInfo_Title is not a property/method of the IPXC_DocumentInfo but an element of the PXC_DocumentInfoKey - thus the error occurs when you try to call it like you did. This method should be used in your language:
https://sdkhelp.pdf-xchange.com/vi ... fo_InfoStr
Cheers,
Alex
If you could have noticed, the DocInfo_Title is not a property/method of the IPXC_DocumentInfo but an element of the PXC_DocumentInfoKey - thus the error occurs when you try to call it like you did. This method should be used in your language:
https://sdkhelp.pdf-xchange.com/vi ... fo_InfoStr
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 31
- Joined: Thu Sep 20, 2018 12:45 am
Re: PowerBuilder and Form Fields
Hello Alex,
I understand where you are going with that, BUT that doesn't appear to be the problem. To be clear, it appears we can get a handle to the SrcInfo Interface. Here's a clearer example of how we get a "Not Valid" pointer (NULL pointer) to the Info Interface:
whereas this gives a "Valid" pointer to the SrcInfo interface:
I hope that is clearer.
We need to understand why we get a null pointer to the Info Interface. What is different with this Interface as compared to the SrcInfo Interface that our PowerBuilder application using the same approach can NOT get a valid handle to the Info Interface.
Thank You.
Greg
I understand where you are going with that, BUT that doesn't appear to be the problem. To be clear, it appears we can get a handle to the SrcInfo Interface. Here's a clearer example of how we get a "Not Valid" pointer (NULL pointer) to the Info Interface:
Code: Select all
// Declare variables - Note ole_pdf is the ActiveX control painted on the Window
OLEObject lole_Doc
OLEObject lole_coredoc
OLEObject lole_info
lole_Doc = ole_pdf.Object.Doc
lole_coredoc = lole_doc.CoreDoc
lole_info = lole_coredoc.Info
IF IsValid(lole_info) THEN
MessageBox("lole_coredoc.Info", "Valid")
ELSE
MessageBox("lole_coredoc.Info", "Not Valid")
END IF
Code: Select all
// Declare variables - Note ole_pdf is the ActiveX control painted on the Window
OLEObject lole_Doc
OLEObject lole_coredoc
OLEObject lole_sourceinfo
lole_Doc = ole_pdf.Object.Doc
lole_coredoc = lole_doc.CoreDoc
lole_sourceinfo = lole_coredoc.SrcInfo
IF IsValid(lole_sourceinfo) THEN
MessageBox("lole_coredoc.SrcInfo", "Valid")
ELSE
MessageBox("lole_coredoc.SrcInfo", "Not Valid")
END IF
We need to understand why we get a null pointer to the Info Interface. What is different with this Interface as compared to the SrcInfo Interface that our PowerBuilder application using the same approach can NOT get a valid handle to the Info Interface.
Thank You.
Greg