c# - Merge and Renumber Pages with ITextSharp -


we trying merge 2 page numbered pdfs new pdf. want have new pdf start page number 1 e.g.

  1. pdf pages sorted 1,2,3,4,5
  2. pdf pages sorted 1,2,3,4,5

merged pdf should have page number 1,2,3,4,5,6,7,8,9,10 , other old page labels should not seen on newly merged pdf.

this our sample code labels not showing on page.

string output_file = "~/output/output.pdf"; document document = new document(); using (var inputpdfstream = new filestream(@"c:\test.pdf", filemode.open)) {     pdfreader reader = new pdfreader(inputpdfstream);     pdfreader.unethicalreading = true;      using (pdfwriter writer = pdfwriter.getinstance(document, new filestream(server.mappath(output_file), filemode.create)))     {         document.open();         pdfcontentbyte cb = writer.directcontent;         pdfimportedpage page;          (int = 1; <= reader.numberofpages; i++)         {             page =writer.getimportedpage(reader, i);             document.newpage();             cb.addtemplate(page, 0, 0);             pdfpagelabels olabel = new pdfpagelabels();             olabel.addpagelabel(i, pdfpagelabels.decimal_arabic_numerals);             writer.pagelabels = olabel;         }          document.close();     } } 


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -