PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.
- Calculate the height of a paragraph in PDF
- Multipage TIFF to PDF
- Create PDF in C#
- Text formatting
- How to add page numbers to your PDF
- Append multiple PDF documents
- Add text field to PDF
- Convert XHTML to PDF
- Add footer with left and right aligned text on same line
- XhtmlParagraph and TrueType fonts
- What is the resulting fontsize in PDF for rich text used in a SimpleXhtmlShape
- Read and write meta data from PDF
- Merge PDF
- Stitch PDF documents
- Convert TXT to PDF
- Bulleted list from XML and XSL
- Use multiple licenses
- Generate PDF form from XML
- Generate PDF with local images from XML with Xamarin.iOS
Merge PDF
It is possible to merge PDFs in .NET using TallPDF. In this code sample we will create a new PDF by stitching two existing PDF documents.
C# merge PDF code sample
using System;
using System.IO;
using TallComponents.PDF.Layout;
using TallComponents.PDF.Layout.Paragraphs;
using TallComponents.PDF.Layout.Shapes;
namespace PageShapeSample
{
class Program
{
static void Main(string[] args)
{
using ( FileStream fileA = new FileStream(
"SuccesStory_Gems.pdf", FileMode.Open, FileAccess.Read))
using ( FileStream fileB = new FileStream(
"SuccesStory_Netco.pdf", FileMode.Open, FileAccess.Read))
{
Document document = new Document();
addPages(document, fileA);
addPages(document, fileB);
using (FileStream file = new FileStream(
"out.pdf", FileMode.Create, FileAccess.Write))
{
document.Write(file);
}
}
}
static void addPages(Document document, FileStream file)
{
PageShape pageShape = new PageShape(file, 0, "");
int n = pageShape.PageCount;
for (int i = 0; i < n; i++)
{
pageShape.PageIndex = i;
Section section = new Section();
section.StartOnNewPage = true;
section.PageSize = new PageSize(
pageShape.Width, pageShape.Height);
section.Margin.Left = 0;
section.Margin.Right = 0;
section.Margin.Top = 0;
section.Margin.Bottom = 0;
document.Sections.Add(section);
Drawing drawing = new Drawing(
pageShape.Width, pageShape.Height);
drawing.Shapes.Add(pageShape.Clone());
section.Paragraphs.Add(drawing);
}
}
}
}
Sub Main()
' Find all pdf documents in input folder.
Dim directoryInfo As New DirectoryInfo("..\..\../inputdocuments")
Dim allPDFs As FileInfo() = directoryInfo.GetFiles("*.pdf")
' Create a document for the merged result.
Dim mergedDocument As New Document()
' Keep a list of input streams to close when done.
Dim streams As New List(Of FileStream)()
For Each fileInfo As FileInfo In allPDFs
' Open input stream and add to list of streams.
Dim stream As New FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read)
streams.Add(stream)
' Open input document.
Dim document As New Document(stream)
' Append all pages to target document.
' The target document holds references to data in the input stream.
' For efficiency it does not copy this data so the input streams
' should not be closed before the merged document is saved.
mergedDocument.Pages.AddRange(document.Pages.CloneToArray())
Next
' Save merged document.
Using output As New FileStream("..\..\output.pdf", FileMode.Create, FileAccess.Write)
mergedDocument.Write(output)
End Using
' Close all input streams.
For Each stream As FileStream In streams
stream.Close()
Next
End Sub

Download TallPDF.NET 5.0
We will send you a download link
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download
We have sent an email with a download link.