using System;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
public class field_merge
{
private static void usage()
{
System.Console.Out.WriteLine("Field merging and flattening");
System.Console.Out.WriteLine("usage: field_merge [-f] infile_pdf outfile_pdf [[name1=value1][namex=valuex]]");
System.Console.Out.WriteLine(" -f - flatten the fields");
}
[STAThread]
public static void Main(string[] args)
{
if (args.Length < 2)
{
usage();
return ;
}
int idx = 0;
if (args[0].Equals("-f"))
++idx;
if (args.Length - idx < 2)
{
usage();
return ;
}
string in_pdf = args[idx];
string out_pdf = args[idx + 1];
try
{
PdfReader reader = new PdfReader(in_pdf);
PdfStamper stamp = new PdfStamper(reader, new FileStream(out_pdf, FileMode.Create));
AcroFields form = stamp.AcroFields;
for (int k = idx + 2; k < args.Length; ++k)
{
string t = args[k];
int x = t.IndexOf((System.Char) '=');
if (x > 0)
{
string field = t.Substring(0, (x) - (0));
string value_Renamed = t.Substring(x + 1);
form.SetField(field, value_Renamed);
}
}
if (idx > 0)
stamp.FormFlattening=(true);
stamp.Close();
System.Console.Out.WriteLine("Done.");
}
catch (System.Exception e)
{
System.Console.Error.WriteLine(e.Message);
}
}
}
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
public class field_merge
{
private static void usage()
{
System.Console.Out.WriteLine("Field merging and flattening");
System.Console.Out.WriteLine("usage: field_merge [-f] infile_pdf outfile_pdf [[name1=value1][namex=valuex]]");
System.Console.Out.WriteLine(" -f - flatten the fields");
}
[STAThread]
public static void Main(string[] args)
{
if (args.Length < 2)
{
usage();
return ;
}
int idx = 0;
if (args[0].Equals("-f"))
++idx;
if (args.Length - idx < 2)
{
usage();
return ;
}
string in_pdf = args[idx];
string out_pdf = args[idx + 1];
try
{
PdfReader reader = new PdfReader(in_pdf);
PdfStamper stamp = new PdfStamper(reader, new FileStream(out_pdf, FileMode.Create));
AcroFields form = stamp.AcroFields;
for (int k = idx + 2; k < args.Length; ++k)
{
string t = args[k];
int x = t.IndexOf((System.Char) '=');
if (x > 0)
{
string field = t.Substring(0, (x) - (0));
string value_Renamed = t.Substring(x + 1);
form.SetField(field, value_Renamed);
}
}
if (idx > 0)
stamp.FormFlattening=(true);
stamp.Close();
System.Console.Out.WriteLine("Done.");
}
catch (System.Exception e)
{
System.Console.Error.WriteLine(e.Message);
}
}
}