Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9187965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:54:05+00:00 2026-06-17T19:54:05+00:00

I have a dynamic PDF form that has a DropDownList. I’m using iTextSharp to

  • 0

I have a dynamic PDF form that has a DropDownList. I’m using iTextSharp to try and modify the values inside the PDF before sending it out to the client. Here’s what I’m trying, as per an answer in this question:

PdfReader reader = new PdfReader(myPdfPath);
XmlDocument xdoc = reader.AcroFields.Xfa.DomDocument;
XmlNode dropdown = xdoc.SelectSingleNode("/*/template/subform[@name='form1']/subform[@name='form2']/field[@name='DropDownList1']");

But no matter what XPath expression I use (ex: //subform or field[@name='DropDownList1']), SelectSingleNode always returns null, and SelectNodes returns an empty list.

Am I doing something wrong here? If there is a better way of doing this, I’d love to know.

Here’s some the xml (I want the field node):

<?xml version="1.0" encoding="UTF-8"?>

<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2013-01-18T13:22:31Z" uuid="3c6141a4-56b4-4f6e-8a2d-4519050f1c69">  

<template xmlns="http://www.xfa.org/schema/xfa-template/3.0/">  
<?formServer defaultPDFRenderFormat acrobat9.1dynamic?>  
    <subform name="form1" layout="tb" locale="en_US" restoreState="auto"> 
        <pageSet> 
            <pageArea name="Page1" id="Page1"> 
                <contentArea x="0.25in" y="0.25in" w="576pt" h="756pt"/>  
                <medium stock="default" short="612pt" long="792pt"/>  <?templateDesigner expand 0?> 
            </pageArea>
            <?templateDesigner expand 0?> 
        </pageSet>  
        <subform w="576pt" h="756pt" name="form2"> 
            <field name="DropDownList1" y="22.225mm" x="6.35mm" w="62mm" h="9mm"> 
                <ui> 
                    <choiceList> 
                        <border> 
                            <edge stroke="lowered"/> 
                        </border>  
                        <margin/> 
                    </choiceList> 
                </ui>  
                <font typeface="Myriad Pro"/>  
                <margin topInset="1mm" bottomInset="1mm" leftInset="1mm" rightInset="1mm"/>  
                <para vAlign="middle"/>  
                <caption reserve="25mm"> 
                    <para vAlign="middle"/>  
                    <value> 
                        <text>Drop-down List</text> 
                    </value> 
                </caption>  
                <items save="1"> 
                    <text>Item 1</text>  
                    <text>Item 2</text>  
                    <text>Item 3</text> 
                </items> 
            </field>  
        </subform>  
        <proto/>  
        <desc> 
            <text name="version">10.0.2.20120224.1.869952.867557</text> 
        </desc>
        <?templateDesigner expand 1?>
        <?renderCache.subset "Myriad Pro" 0 0 ISO-8859-1 4 112 28 0001000E001200130023002400250027002D0033003500420044004500460049004A004C004D004F00500051005300540055005600580059 -12BCDFLRTacdehiklnoprstuwx?>
    </subform>  
    <?templateDesigner DefaultPreviewDynamic 1?>
    <?templateDesigner DefaultRunAt client?>
    <?templateDesigner Grid show:1, snap:1, units:0, color:ff8080, origin:(0,0), interval:(125000,125000)?>
    <?templateDesigner DefaultCaptionFontSettings face:Myriad Pro;size:10;weight:normal;style:normal?>
    <?templateDesigner DefaultValueFontSettings face:Myriad Pro;size:10;weight:normal;style:normal?>
    <?templateDesigner DefaultLanguage JavaScript?>
    <?acrobat JavaScript strictScoping?>
    <?templateDesigner WidowOrphanControl 0?>
    <?templateDesigner SaveTaggedPDF 1?>
    <?templateDesigner SavePDFWithEmbeddedFonts 1?>
    <?templateDesigner FormTargetVersion 30?>
    <?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?>
    <?templateDesigner Zoom 92?>
</template>  
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
    <annots/>
</xfdf>
<datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"></datasets>
</xdp:xdp>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:54:06+00:00Added an answer on June 17, 2026 at 7:54 pm

    The reason your XPaths don’t work is that most of the XML is in the namespace http://www.xfa.org/schema/xfa-template/3.0/.

    In cases like these, the appropriate practice is to create an XmlNamespaceManager and declare the namespaces, then use them in your XPath. Please see this post for an explanation.

    PdfReader reader = new PdfReader(myPdfPath);
    XmlDocument xdoc = reader.AcroFields.Xfa.DomDocument;
    XmlNamespaceManager nsm = new XmlNamespaceManager(xdoc.NameTable);
    nsm.AddNamespace("xfa", "http://www.xfa.org/schema/xfa-template/3.0/");
    XmlNode dropdown = 
      xdoc.SelectSingleNode("/*/xfa:template/xfa:subform[@name='form1']/xfa:subform[@name='form2']/xfa:field[@name='DropDownList1']",
      nsm);
    

    I also don’t see a subform element with the name “form2”. Was that a piece you just didn’t include in your XML sample?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a dynamic PDF form using Adobe LiveCycle designer and have
I have a PDF form that has 450 fields in it and I'm going
I have a dynamic tableview which has a prototype cell with a button that,
I'm automatically generating a PDF-file with Platypus that has dynamic content. This means that
I'm using iTextSharp v5.3 to build a PDF with one or more tables that
I have a web application that builds a dynamic PDF with FPDF and allows
I have dynamic listview on my android client app that receive data from remote
I have some divs that have dynamic heights controlled by a 'click' function as
I have some divs that have dynamic heights controlled by a 'click' function as
I have form where are 2 input fields and then i have dynamic dataTables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.