PowerBuilder and Form Fields

PDF-XChange Editor SDK for Developers

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

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
greg.rusak@mustimuhw.solutions
User
Posts: 26
Joined: Thu Sep 20, 2018 12:45 am

PowerBuilder and Form Fields

Post by greg.rusak@mustimuhw.solutions » Thu Sep 20, 2018 6:28 pm

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.
Attachments
test_form.pdf
(86.75 KiB) Downloaded 31 times

User avatar
Sasha - Tracker Dev Team
User
Posts: 4087
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: PowerBuilder and Form Fields

Post by Sasha - Tracker Dev Team » Fri Sep 21, 2018 11:49 am

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.tracker-software.com/vi ... lds_modify
Though if you have a XFA document, you can't modify those fields.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

greg.rusak@mustimuhw.solutions
User
Posts: 26
Joined: Thu Sep 20, 2018 12:45 am

Re: PowerBuilder and Form Fields

Post by greg.rusak@mustimuhw.solutions » Mon Sep 24, 2018 11:31 pm

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:

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
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

Ivan - Tracker Software
Site Admin
Posts: 3591
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: PowerBuilder and Form Fields

Post by Ivan - Tracker Software » Tue Sep 25, 2018 6:24 pm

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.

greg.rusak@mustimuhw.solutions
User
Posts: 26
Joined: Thu Sep 20, 2018 12:45 am

Re: PowerBuilder and Form Fields

Post by greg.rusak@mustimuhw.solutions » Tue Sep 25, 2018 10:07 pm

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

greg.rusak@mustimuhw.solutions
User
Posts: 26
Joined: Thu Sep 20, 2018 12:45 am

Re: PowerBuilder and Form Fields

Post by greg.rusak@mustimuhw.solutions » Wed Sep 26, 2018 10:25 pm

After some more digging into the help files, I was able to find:

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,
};
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:

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
Can you help with inserting a list of values into a combobox.

Thanks in advance.

Greg

greg.rusak@mustimuhw.solutions
User
Posts: 26
Joined: Thu Sep 20, 2018 12:45 am

Re: PowerBuilder and Form Fields

Post by greg.rusak@mustimuhw.solutions » Wed Sep 26, 2018 10:34 pm

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

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

Re: PowerBuilder and Form Fields

Post by Tracker Supp-Stefan » Thu Sep 27, 2018 8:30 am

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

greg.rusak@mustimuhw.solutions
User
Posts: 26
Joined: Thu Sep 20, 2018 12:45 am

Re: PowerBuilder and Form Fields

Post by greg.rusak@mustimuhw.solutions » Wed Nov 21, 2018 11:28 pm

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.tracker-software.com/vi ... nt_SrcInfo) and the Info Property (https://sdkhelp.tracker-software.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
... but this code does not and returns a NULL pointer and the messagebox shows "Not Valid":

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
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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4087
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: PowerBuilder and Form Fields

Post by Sasha - Tracker Dev Team » Thu Nov 22, 2018 7:48 am

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.tracker-software.com/vi ... fo_InfoStr

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

greg.rusak@mustimuhw.solutions
User
Posts: 26
Joined: Thu Sep 20, 2018 12:45 am

Re: PowerBuilder and Form Fields

Post by greg.rusak@mustimuhw.solutions » Thu Nov 22, 2018 5:14 pm

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:

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
whereas this gives a "Valid" pointer to the SrcInfo 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_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
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

Post Reply