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
Stitch PDF documents
This code sample shows how to stich PDF pages from an existing PDF document to a newly generated PDF using TallPDF.NET.
Code sample to stitch PDF documents
using System;
using System.IO;
using TallComponents.PDF.Layout;
using TallComponents.PDF.Layout.Paragraphs;
using TallComponents.PDF.Layout.Shapes;
using TallComponents.PDF.Layout.Fonts;
namespace PageShapeSample
{
class Program
{
static void Main(string[] args)
{
//open two existing PDFs
using (FileStream fileA = new FileStream(
"input.pdf", FileMode.Open, FileAccess.Read))
using (FileStream fileB = new FileStream(
"input.pdf", FileMode.Open, FileAccess.Read))
{
//create a new document and add new content to it
Document document = new Document();
addNewContent(document);
//add the content of the two PDFs
addPages(document, fileA);
addPages(document, fileB);
//save new PDF to disk
using (FileStream file = new FileStream(
"out.pdf", FileMode.Create, FileAccess.Write))
{
document.Write(file);
}
}
}
//adds some filler text to a pdf section
static void addNewContent(Document document)
{
Section section = new Section();
document.Sections.Add(section);
for (int i = 0; i < 10; i++)
{
TextParagraph text = new TextParagraph();
text.SpacingAfter = 18;
section.Paragraphs.Add(text);
Fragment fragment = new Fragment();
fragment.Font = Font.Helvetica;
fragment.FontSize = 18;
fragment.Text = "Filler text...";
text.Fragments.Add(fragment);
}
}
//copy content from input filestream to the document
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);
//clone the page to the new document
Drawing drawing = new Drawing(
pageShape.Width, pageShape.Height);
drawing.Shapes.Add(pageShape.Clone());
section.Paragraphs.Add(drawing);
}
}
}
}

Download TallPDF.NET 4.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.