SHARE
TWEET

Untitled

a guest Apr 18th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //合併PDF
  2. public MemoryStream MergePdfFiles(byte[][] msa)
  3. {
  4.     MemoryStream ms = new MemoryStream();
  5.     PdfReader reader;
  6.     Document document = new Document();
  7.     PdfWriter writer = PdfWriter.GetInstance(document, ms);
  8.     document.Open();
  9.     PdfContentByte cb = writer.DirectContent;
  10.     PdfImportedPage newPage;
  11.     for (int i = 0; i < msa.Length; i++)
  12.     {
  13.         reader = new PdfReader(msa[i]);
  14.         int iPageNum = reader.NumberOfPages;
  15.         for (int j = 1; j <= iPageNum; j++)
  16.         {
  17.             document.NewPage();
  18.             newPage = writer.GetImportedPage(reader, j);
  19.             cb.AddTemplate(newPage, 0, 0);
  20.         }
  21.     }
  22.     document.Close();
  23.     return ms;
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top