Some times we need make a series PDF from an single PDF Template
From above two article we know how to make an single PDF. And how to add page to new pdf.
From some other actile of Internet we may be get writer. copypolicform (Reader)
But I find just the last PDF (copy from the single PDF) have these values.
Other fields are empty
OK how to do it. memorystream stream = new memorystream ();
Document Doc = new document ();
Synchronized copy writer = new synchronized copy (Doc, stream );
Doc. open ();
String path;
Path = httpcontext. Current. server. mappath ("~ /Templae.pdf ");
String sessionid = httpcontext. Current. session. lcid. tostring ();
String path2 = httpcontext. Current. server. mappath ("~ /Define template/Temp "+ sessionid +". pdf ");
Pdfimportedpage;
For (INT I = 0; I <list. Count; I ++)
{
// Memorystream itemstream = new memorystream ();
Filestream itemstream = new filestream (path2, filemode. Create );
Pdfreader reader = new pdfreader (PATH );
Int KK = reader. numberofpages;
Pdfstamper Stamper = new pdfstamper (reader, itemstream );
Required Fields AF = Stamper. Required Fields;
Af. setfield ("currentdate", datetime. Now. tostring ());
Af. renamefield ("currentdate", "currentdate _" + I );
Stamper. Close ();
Pdfreader pF = new pdfreader (path2 );
Page = writer. getimportedpage (PF, 1 );
Writer. addpage (PAGE );
Page = writer. getimportedpage (PF, 2 );
Writer. addpage (PAGE );
PF. Close ();
}
File. Delete (path2);/** // Delete the Temp File
Doc. Close ();
Return stream;
As you see I am use filestream. I can't use memorystream. Some error was occur.
Lovebanyi lookcode.net
How to merge a PDF containing multiple terraform data
How to merge more than form.