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 Dec 13, 2018 12:22 pm

I have an intelligent pdf with some buttons and when i click a button i can import from an XML or just show/hide/ add fields.
Can i use spire with c# to trigger that button when i open the pdf?

birledaniel
 
Posts: 4
Joined: Thu Dec 13, 2018 12:19 pm

Fri Dec 14, 2018 8:10 am

Hi,

Thanks for your inquiry.
Our product cannot achieve your requirement at present. Sorry for inconvenience caused.
Sincerely,
Mike
E-iceblue support team
User avatar

Mike.Zhang
 
Posts: 93
Joined: Thu Sep 27, 2018 7:11 am

Fri Dec 14, 2018 1:06 pm

so i tried to set the field programaticly like this
Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
doc.LoadFromFile(SRC);
PdfFormWidget formWidget = doc.Form as PdfFormWidget;
List<XfaField> xfafields = formWidget.XFAForm.XfaFields;
foreach (XfaField xfaField in xfafields)
{
if (xfaField is XfaTextField)
{
XfaTextField xf = xfaField as XfaTextField;
switch (xfaField.Name)
{
case "form1[0].MainForm[0].sbfrmAntet[0].nume_ip[0]":
xf.Value = "ZORRO";
break;
default:
break;
}
}
}
doc.SaveToFile(DEST);

but when i open the pdf i get error 110

Also, how can i set the value for 2 dropdownlists(2nd depends on the 1st valuer)

birledaniel
 
Posts: 4
Joined: Thu Dec 13, 2018 12:19 pm

Mon Dec 17, 2018 10:56 am

Hi,

1. About the error issue, please provide your input file for further investigation.
2. As for setting the value, to help us provide the solution for you ASAP, please tell us which dropdownlists in your input file you want to set and what is your expected result.
Sincerely,
Mike
E-iceblue support team
User avatar

Mike.Zhang
 
Posts: 93
Joined: Thu Sep 27, 2018 7:11 am

Mon Dec 17, 2018 12:02 pm

the dropdowns: Sector Bugetar(form1[0].MainForm[0].sbfrmAntet[0].SectorBug[0]) is the 1st and Sursa de finantare(form1[0].MainForm[0].SbfrmAddIndicator[0].SursaFin[0]) is the 2nd

i uploaded all the files

birledaniel
 
Posts: 4
Joined: Thu Dec 13, 2018 12:19 pm

Tue Dec 18, 2018 10:42 am

Hi,

Thanks for your file.
Regarding the issue of error 100, I have reproduced the issue and logged it in our bug tracking system. Once there is any update, we will let you know. Sorry for the inconvenience caused.
As for setting the value for 2 dropdownlists, please refer to below code to set the value.
Code: Select all
            PdfDocument pdf = new PdfDocument();
            pdf.LoadFromFile(path + "F1115.pdf");
            PdfFormWidget formWidget = pdf.Form as PdfFormWidget;
            var xfafields = formWidget.XFAForm.XfaFields;
            foreach (var xfaField in xfafields)
            {
                if (xfaField is XfaChoiceListField)
                {
                    XfaChoiceListField xfaChoiceListField = xfaField as XfaChoiceListField;

                    if (xfaChoiceListField.Name == "form1[0].MainForm[0].sbfrmAntet[0].SectorBug[0]")
                    {
                        xfaChoiceListField.SelectedItem = ""// you could change the value according to your requirements
                    };
                    if (xfaChoiceListField.Name == "form1[0].MainForm[0].SbfrmAddIndicator[0].SursaFin[0]")
                    {
                        xfaChoiceListField.SelectedItem = "B. Credite externe";// you could change the value according to your requirements
                    };
                };
            };
            pdf.SaveToFile(path + "yy.pdf");

Note there is still the error when opening the result file. I have logged it to our bug tracking system. Once there is any update, I will let you know.
Sincerely,
Mike
E-iceblue support team
User avatar

Mike.Zhang
 
Posts: 93
Joined: Thu Sep 27, 2018 7:11 am

Fri Jan 11, 2019 7:23 am

Hi,

Glad to inform you that the two issues are solved in Spire.PDF Pack(Hot Fix) Version:5.1.4. Welcome to download and use it.
Our website: https://www.e-iceblue.com/Download/down ... t-now.html
NuGet: https://www.nuget.org/packages/Spire.PDF/5.1.4

Best wishes,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Jan 15, 2019 8:22 am

I downloaded the hotfix and indeed the error is gone. But i try now to add an action to the pdf, according to
https://www.e-iceblue.com/Tutorials/Spi ... -in-C.html
and its not working
this is my complete code

PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(SRC);
PdfFormWidget formWidget = pdf.Form as PdfFormWidget;
var xfafields = formWidget.XFAForm.XfaFields;

String script
= "app.alert({"
+ " cMsg: \"I'll lead; you must follow me.\","
+ " nIcon: 3,"
+ " cTitle: \"JavaScript Action\""
+ "});";
PdfJavaScriptAction action1 = new PdfJavaScriptAction(script);
pdf.AfterOpenAction = action1;
pdf.SaveToFile(DEST);

my main goal is to execute the code from a button inside the pdf: form1[0].sbfrmImportExport[0].sbfrmIET[0].import[0]

i opened the pdf with Live Cycle and the code behind the button is
"try { var TheCodSectorBugetar = csForm.GetInstance().SectorBugetar.rawValue; "+
" var TheCodProgramBugetar = csForm.GetInstance().ProgramBugetar.rawValue; "+
" var TheCodSursaFinantare = csForm.GetInstance().SursaFin.rawValue; "+
" var TheSectiune = csForm.GetInstance().SectiuneBugetara.rawValue; "+
" csMainTable.MainTableMethods().MainTableAdd(TheCodSectorBugetar, TheCodProgramBugetar, TheCodSursaFinantare, TheSectiune); "+
" csForm.GetInstance().FormPermitNull.access = \"readOnly\";"+
" csForm.GetInstance().ESectB.presence = 'visible'; "+
" }catch(e){ "+
" xfa.host.messageBox(e.message);"+
"}

birledaniel
 
Posts: 4
Joined: Thu Dec 13, 2018 12:19 pm

Tue Jan 15, 2019 10:15 am

Hi,

Thanks for your feedback.
After using your code to add the action to your PDF, the result file doesn't hint the message when opening. I have forwarded this issue to our DEV team for investigation. If there is any news, we will inform you.
What's more, as for your main goal, do you want to add an action with JS code to the button "form1[0].sbfrmImportExport[0].sbfrmIET[0].import[0]" ?
Could you please provide us more details?

Sincerely,
Anna
E-iceblue support team
User avatar

Anna.Zhang
 
Posts: 73
Joined: Thu Sep 27, 2018 3:20 am

Return to Spire.PDF