Hello Adeel,
I ran the code you sent me. The result was a two page doc with one page missing the fdf form fields. All I changed in your code was the path to the files and added close statements for the input streams so I could rerun this as needed. The tmp files where the input and the asdf file was the output. I also combined the files manually in acrobat to see what would happen. They combined fine even with the same ids. Any ideas?
Thanks,
Tim
[Code Example 1 Using Concatenate]
protected void Page_Load(object sender, EventArgs e)
{
string inFile1 = @"C:/Inetpub/wwwroot/BarcodeApp300/Tmp/tmp000463.pdf";
string inFile2 = @"C:/Inetpub/wwwroot/BarcodeApp300/Tmp/tmp003897.pdf";
string outFile = @"C:/Inetpub/wwwroot/BarcodeApp300/Tmp/asdf.pdf";
FileStream inStream1 = new FileStream(inFile1, FileMode.Open);
FileStream inStream2 = new FileStream(inFile2, FileMode.Open);
FileStream outputStream = new FileStream(outFile, FileMode.Create);
//Concatnate input Pdf file1 and file2, output is saved in innerStream.
PdfFileEditor editor = new PdfFileEditor();
editor.Concatenate(inStream1, inStream2, outputStream);
outputStream.Close();
inStream1.Close();
inStream2.Close();
}
[Code Example 2 Using Insert ]
public static byte[] PastePage(byte[] destPdf, byte[] srcPdf, int insertPage)
{
byte[] returnArray = new byte[0];
try{
MemoryStream srcStream = new MemoryStream(srcPdf, false);
MemoryStream destStream = new MemoryStream(destPdf, true);
MemoryStream tmpStream = new MemoryStream();
PdfFileInfo pfi = new PdfFileInfo(srcStream);
int numPgs = pfi.NumberofPages;
int[] pgs = new int[numPgs];
for(int i = 0; i < numPgs; i++)
{
pgs[i] = i+1;
}
PdfFileEditor pfe = new PdfFileEditor();
pfe.Insert(srcStream, insertPage, destStream, pgs, tmpStream);
returnArray = tmpStream.ToArray();
srcStream.Close();
destStream.Close();
tmpStream.Close();
}
catch(Exception e)
{
throw e;
}
return returnArray;
}
This message was posted using Email2Forum by graves. (attachment)