Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# itext 7 PdfDocument from byte array

using (MemoryStream ms = new MemoryStream())
using (PdfDocument pdf = new PdfDocument(new PdfWriter(ms).SetSmartMode(true)))
{
    // Create reader from bytes
    using (MemoryStream memoryStream = new MemoryStream(pdf1.DocumentBytes))
    {
        // Create reader from bytes
        using (PdfReader reader = new PdfReader(memoryStream))
        {
            PdfDocument srcDoc = new PdfDocument(reader);
            srcDoc.CopyPagesTo(1, srcDoc.GetNumberOfPages(), pdf);
        }
    }

    // Create reader from bytes
    using (MemoryStream memoryStream = new MemoryStream(pdf2.DocumentBytes))
    {
        // Create reader from bytes
        using (PdfReader reader = new PdfReader(memoryStream))
        {
            PdfDocument srcDoc = new PdfDocument(reader);
            srcDoc.CopyPagesTo(1, srcDoc.GetNumberOfPages(), pdf);
        }
    }

    // Close pdf
    pdf.Close();

    // Return array
    return ms.ToArray();
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: emgucv open image c# 
Csharp :: char array 
Csharp :: c# wpf timer 
Csharp :: meaning of ??= in c# 
Csharp :: Winform on exit run method 
Csharp :: asp.net core identity get all roles 
Csharp :: wasd code for unity 
Csharp :: how to make a string a list of characters c# 
Csharp :: c# example code 
Csharp :: unity time scale 
Csharp :: c# yield 
Csharp :: json serialization 
Csharp :: c# split string by index 
Csharp :: C# Read() and ReadKey() 
Csharp :: c# best way to loop and remove 
Csharp :: c# recursion formula for the factorial 
Csharp :: remove item from list in for loop c# 
Csharp :: XMLWriter write xml C# 
Csharp :: Scrollable WPF ListBox 
Csharp :: longest substring without repeating characters c# 
Csharp :: enum in c# 
Csharp :: c# for 
Csharp :: join dictionaries keys c# 
Csharp :: group-by-in-linq 
Csharp :: Get Mac address of Device in Xamarin 
Csharp :: c# console delete last character 
Csharp :: c# read excel file into datatable 
Csharp :: monogame print debug 
Csharp :: Unity Object rotation along any axis 
Csharp :: irrrtate throught an matrix c# 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =