From single PDF template make a series PDF

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.