第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在c#.net中使用iTextSharp合并多個PDF

在c#.net中使用iTextSharp合并多個PDF

紫衣仙女 2019-11-13 15:45:40
好吧,我正在嘗試將多個PDF合并為一個。編譯時我沒有給出任何錯誤。我嘗試首先合并文檔,但由于我正在使用表,因此出現(xiàn)了錯誤。這是asp.net背后的代碼if (Button.Equals("PreviewWord")) {        String eventTemplate = Server.MapPath("/ERAS/Badges/Template/EventTemp" + EventName + ".doc");        String SinglePreview = Server.MapPath("/ERAS/Badges/Template/PreviewSingle" + EventName + ".doc");        String PDFPreview = Server.MapPath("/ERAS/Badges/Template/PDFPreviewSingle" + EventName + ".pdf");        String previewPDFs = Server.MapPath("/ERAS/Badges/Template/PreviewPDFs" + EventName + ".pdf");        if (System.IO.File.Exists((String)eventTemplate))        {            if (vulGegevensIn == true)            {              //This creates a Worddocument and fills in names etc from database                CreateWordDocument(vulGegevensIn, eventTemplate, SinglePreview, false);                //This saves the SinglePreview.doc as a PDF @param place of PDFPreview                CreatePDF(SinglePreview, PDFPreview);                //Trying to merge                String[] previewsSmall=new String[1];                previewsSmall[0] = PDFPreview;                PDFMergenITextSharp.MergeFiles(previewPDFs, previewsSmall);            }            // merge PDFs here...........................;            //here            //no here//            //...    } }這是PDFMergenITextSharpClass公共靜態(tài)類PDFMergenITextSharp {public static void MergeFiles(string destinationFile, string[] sourceFiles){    try    {        int f = 0;        // we create a reader for a certain document        PdfReader reader = new PdfReader(sourceFiles[f]);        // we retrieve the total number of pages        int n = reader.NumberOfPages;        //Console.WriteLine("There are " + n + " pages in the original file.");        // step 1: creation of a document-object        Document document = new Document(reader.GetPageSizeWithRotation(1));        // step 2: we create a writer that listens to the documen
查看完整描述

3 回答

?
PIPIONE

TA貢獻(xiàn)1829條經(jīng)驗 獲得超9個贊

在Itextsharp中合并PDF的代碼


 public static void Merge(List<String> InFiles, String OutFile)

    {


        using (FileStream stream = new FileStream(OutFile, FileMode.Create))

        using (Document doc = new Document())

        using (PdfCopy pdf = new PdfCopy(doc, stream))

        {

            doc.Open();


            PdfReader reader = null;

            PdfImportedPage page = null;


            //fixed typo

            InFiles.ForEach(file =>

            {

                reader = new PdfReader(file);


                for (int i = 0; i < reader.NumberOfPages; i++)

                {

                    page = pdf.GetImportedPage(reader, i + 1);

                    pdf.AddPage(page);

                }


                pdf.FreeReader(reader);

                reader.Close();

                File.Delete(file);

            });

        }


查看完整回答
反對 回復(fù) 2019-11-13
  • 3 回答
  • 0 關(guān)注
  • 2055 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號