none
powershell and itext fill text into pdf template RRS feed

  • Question

  • I have to write a script which fill automatically some data into source PDF template and save as another file. But when I load g.xml the form is empty it is powershell script


    Add-Type -Path “C:\temp\itextsharp.dll”
    $reader = New-Object iTextSharp.text.pdf.PdfReader -ArgumentList “C:\temp\iike.pdf"
    $stamper = New-Object iTextSharp.text.pdf.PdfStamper($reader,[System.IO.File]::Create("c:\temp\vvv44445.pdf"),7,"$true")
    $stamper.AcroFields.Xfa.FillXfaForm("C:\temp\g.xml")
    $stamper.close()

    g.xml looks

    <subform locale="pl_PL" name="Deklaracja" xmlns="http://www.xfa.org/schema/xfa-form/2.8/">
      <instanceManager name="_Strona1" />
      <subform name="Strona1">
        <instanceManager name="_Naglowek" />
        <subform name="Naglowek">
          <field name="NIP1">
            <value override="1">
              <float>5212887341.00000000</float>
            </value>
          </field>
          <field name="Naczelnik">
            <value override="1">
              <text>tomi</text>
            </value>
          </field>
        </subform>
        <area name="B">
          <field name="NazwaPelna">
            <value override="1">
              <text>My firmm</text>
            </value>
          </field>
          <field name="NazwaSkrocona">
            <value override="1">
              <text>FIRMMMMM</text>
            </value>
          </field>
          <field name="REGON_SCR">
            <value override="1">
              <text>01295677</text>
            </value>
          </field>

    itst xfa or xdp format

    $stamper.AcroFields.Xfa.DomDocument.xdp
    
    
    xdp       : http://ns.adobe.com/xdp/
    timeStamp : 2012-05-14T13:07:14Z
    uuid      : 06313b2c-5774-4e62-8df5-4b14256231ea
    config    : config
    template  : template
    localeSet : localeSet
    xmpmeta   : xmpmeta
    datasets  : datasets
    form      : form

    I wont change value of field Nazwapelna,zawaskrocona,regon_scr in xml file and than run powershell scrip. But when i run script then in destination pdf i dont have new value of records. someone can help me ?




    • Edited by qwewqrsfdasdsdaS Saturday, June 2, 2018 2:56 PM
    • Moved by Bill_Stewart Sunday, July 29, 2018 11:15 PM This is not "scripts on demand"
    Saturday, June 2, 2018 2:49 PM

All replies