none
Print merged PDF's without saving RRS feed

  • Question

  • I am trying to print PDF's that I merged using iTextSharp

    Below is the code I use to merge the PDF's

    public void CreatePdf(string targetPDF1, string targetPDF2, string pdfDestination)
    {
    
      String[] source_files = { targetPDF1, targetPDF2 };  
      //create Document object                        
      using (Document document = new Document())
      {     
         //create PdfCopy object
           PdfCopy copy = new PdfCopy(document, new FileStream(pdfDestination, FileMode.Create));
    
         //open the document                            
           document.Open();                            
    
        //PdfReader variable                            
          PdfReader reader;         
    
         for (int i = 0; i < source_files.Length; i++)         
         {      
           //create PdfReader object 
             reader = new PdfReader(source_files[i]);                                
    
            //merge combine pages  
            for (int page = 1; page <= reader.NumberOfPages; page++)         
            {                                    
              copy.AddPage(copy.GetImportedPage(reader, page));                                
            }
         }
      }  
    }
     

    I have tried using MemoryStream() to temporarily save it:

    public void CreatePdf(string targetPDF1, string targetPDF2, string pdfDestination) { String[] source_files = { targetPDF1, targetPDF2 }; //create Document object using (Document document = new Document()) { //Use MemoryStream to temporarily save it MemoryStream ms = new MemoryStream(); PdfCopy copy = new PdfCopy(document, ms); //open the document document.Open(); //PdfReader variable PdfReader reader; for (int i = 0; i < source_files.Length; i++) { //create PdfReader object reader = new PdfReader(source_files[i]); //merge combine pages for (int page = 1; page <= reader.NumberOfPages; page++) { copy.AddPage(copy.GetImportedPage(reader, page)); } }

    //Print the merged PDF's

    } }

    However, I don't know how to print the object.

    Is there a way of doing this?

    • Moved by CoolDadTx Monday, June 18, 2018 2:06 PM Third party product
    Monday, June 18, 2018 12:06 PM

All replies

  • These forums are for MS products only. Please post questions related to third party products like iTextSharp in their forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, June 18, 2018 2:06 PM