Acroform object not refreshed after adding fields  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
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Acroform object not refreshed after adding fields

Post by shaunh »

Hi Support,

It seems the acroform object is not refreshed after the users add fields to a document. The acroform object is null when retrieved directly after adding the fields. If the form is saved, closed and re-opened then the acroform object can be retrieved correctly. Can you please advise how I can programmatically force a refresh of the acroform object?

Code: Select all

if (axPXV_Control1.Inst.ActiveDoc.CoreDoc.HasAcroForm == true)	// this is false even though the user has added fields now
Your direction here would be greatly appreciated.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Acroform object not refreshed after adding fields

Post by Sasha - Tracker Dev Team »

Hello shaunh,

How are you adding the form fields exactly?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Re: Acroform object not refreshed after adding fields

Post by shaunh »

Hi Alex,

The user is adding the fields with the end user forms tools built into the SDK. Once they are done I have functionality for them to submit it as a template to a webservice. I need to do some validation on the fields before I let them submit it. This is where it fails as the acroform object is still null and I can't perform the validation.

Any pointers on how I can refresh the acroform object to pick up the new fields?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Acroform object not refreshed after adding fields

Post by Sasha - Tracker Dev Team »

Hello shaunh,

What I was asking what level are you using and how (IPXC and IPXV). When using the Editor SDK it can be crucial to update the IPXV level correctly if you are working with the Core level only. So a code prototype should be OK to understand.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Acroform object not refreshed after adding fields

Post by Sasha - Tracker Dev Team »

Hello shaunh,

What I was asking what level are you using and how (IPXC and IPXV). When using the Editor SDK it can be crucial to update the IPXV level correctly if you are working with the Core level only. So a code prototype should be OK to understand.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Re: Acroform object not refreshed after adding fields

Post by shaunh »

Hi Alex,

The end user is creating a new PDF document and adding fields to the document using the Editor ActiveX object. Just using the built in commands so nothing fancy there. The user then uses one of my custom commands in the ActiveX Editor to submit the PDF form as a template to my webservice. In the button code I try to use the core layer to retrieve the acroform object to do my validation, which is null. If I save the document, close it and open it again then the acroform object is refreshed and I can do the validation. So again, the question is how to I refresh the AcroForm object to contain the form objects without having to save, close and re-open the document?

Here is a mock up of what is happening. "HasAcroForm" returns false, and when checking the "AcroForm" object it is null even though the user has added fields.

Code: Select all

 // Confirm this is a form
if (axPXV_Control1.Inst.ActiveDoc.CoreDoc.HasAcroForm == true)
{
	// Confirm all required fields exist
        IPXC_AcroForm acroForm = axPXV_Control1.Inst.ActiveDoc.CoreDoc.AcroForm;

	IPXC_FormField formF1 = acroForm.GetFieldByName("Field1");
        IPXC_FormField formF2 = acroForm.GetFieldByName("Field2");


	if (formF1 == null || formF2 == null)
        {
		MessageBox.Show("The required fields are not populated on the form.", "Upload Form Template", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
	}
	else
	{
		// Do my processing here
	}
}
else
	MessageBox.Show("The document is not an AcroForm.", "Upload Form Template", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Please let me know if there is anything that is not clear, or if you need any other information.
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Re: Acroform object not refreshed after adding fields

Post by shaunh »

Hi Alex,

Just following up to see if you have some feedback for me, or need additional info?
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Re: Acroform object not refreshed after adding fields

Post by shaunh »

Hi Alex,

This issue is becoming rather urgent and I assuming by the silence that what I am trying to achieve is not possible. What I am seeing is that the Core objects are not refreshed when form changes are made with the editor. So let's change the question ... is there a way to find a specific form field and value using editor code, I researched and do not see anything obvious. Can you please advise.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Acroform object not refreshed after adding fields  SOLVED

Post by Ivan - Tracker Software »

Yes, there is an issue with updating HasAcroform property, we will fix it.
But in any case, I would recommend to use

Code: Select all

if (axPXV_Control1.Inst.ActiveDoc.CoreDoc.AcroForm.FieldsCount != 0)
{
    ...
}
instead of HasAcroform as this property may become true even if there are no form fields in the document. It actually means that there is /AcroForm 'record' in documents root dictionary. But this record is used not only to hold form fields but as a storage for some common resources used by some type of annotations.
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.
shaunh
User
Posts: 23
Joined: Mon May 18, 2020 7:03 am

Re: Acroform object not refreshed after adding fields

Post by shaunh »

Thank you for the advice Ivan. Implemented as suggested and this is working now.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17937
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Acroform object not refreshed after adding fields

Post by Tracker Supp-Stefan »

:)
Post Reply