PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.

Relevant products

Crop content on a PDF page

This code sample shows how to remove all content that is outside a crop rectangle.

In the main method we enumerate all the pages in the PDF document and reduce the collection of shapes leaving only those shapes that reside within specified crop rectangle.

The original page:

Page

The cropped page:

Result

 

const string inputFileName = @"..\..\inputdocuments\PackingLightBrochure.pdf";
using (var inputStream = new FileStream(inputFileName, FileMode.Open, FileAccess.Read))
{
   //note that the coordinates are specified in 
   //the PDF coordinate system(left bottom corner)
   const float x = 100;
   const float y = 100;
   const float width = 300;
   const float height = 100;

   // define a crop rectangle
   var cropRectangle = new RectangleF(x, y, width, height);

   // open the source document
   var sourceDocument = new Document(inputStream);

   // create the target document
   var targetDocument = new Document();

   // enumerate the pages in the source document
   foreach (var sourcePage in sourceDocument.Pages)
   {
      ContentShape shapes = sourcePage.CreateShapes();

      // The prune method will create a new set of shapes. It will throw 
      // away shapes that are outside the provided crop rectangle.
      shapes = PruneShape(shapes, cropRectangle);

      // location of the returned shapes is relative to the crop rectangle
      // of the original page, so we need to move them.
      shapes.Transform = new MatrixTransform(shapes.Transform).Translate(-x, -y);

      // create new page and add the shapes
      var page = new Page(cropRectangle.Width, cropRectangle.Height);
      page.VisualOverlay.Add(shapes);

      // add the page to the resulting document
      targetDocument.Pages.Add(page);
   }

   // write the target document to disk
   const string fileName = @"..\..\cropped.pdf";
   using (var outFile = new FileStream(fileName, FileMode.Create, FileAccess.Write))
   {
      targetDocument.Write(outFile);
   }

   Process.Start(fileName);
}
Const inputFileName As String = "..\..\..\inputdocuments\PackingLightBrochure.pdf"
        Using inputStream = New FileStream(inputFileName, FileMode.Open, FileAccess.Read)
            'note that the coordinates are specified in 
            'the PDF coordinate system(left bottom corner)
            Const x As Single = 100
            Const y As Single = 100
            Const width As Single = 300
            Const height As Single = 100

            ' define a crop rectangle
            Dim cropRectangle = New RectangleF(x, y, width, height)

            ' open the source document
            Dim sourceDocument = New Document(inputStream)

            ' create the target document
            Dim targetDocument = New Document()

            ' enumerate the pages in the source document
            For Each sourcePage In sourceDocument.Pages
                Dim shapes As ContentShape = sourcePage.CreateShapes()

                ' The prune method will create a new set of shapes. It will throw 
                ' away shapes that are outside the provided crop rectangle.
                shapes = PruneShape(shapes, cropRectangle)

                ' location of the returned shapes is relative to the crop rectangle
                ' of the original page, so we need to move them.
                shapes.Transform = New MatrixTransform(shapes.Transform).Translate(-x, -y)

                ' create new page and add the shapes
                Dim page = New Page(cropRectangle.Width, cropRectangle.Height)
                page.VisualOverlay.Add(shapes)

                ' add the page to the resulting document
                targetDocument.Pages.Add(page)
            Next

            ' write the target document to disk
            Const fileName As String = "..\..\cropped.pdf"
            Using outFile = New FileStream(fileName, FileMode.Create, FileAccess.Write)
                targetDocument.Write(outFile)
            End Using

            Process.Start(fileName)
        End Using

The PruneShapes method will create a new set of shapes. It will throw away shapes that are outside the provided crop rectangle.

private static ContentShape PruneShape(ContentShape shape, RectangleF cropRectangle)
{
   // transform the crop rectangle in order to get it 
   // in the coordinate space of the shape
   cropRectangle = TransformRectangle(cropRectangle, shape.Transform);

   // Shape rectangle provides a rectangle where resides the shape.
   // Assume that shape resides in the crop rectangle.
   RectangleF shapeRectangle = cropRectangle;

   // get the shape rectangle
   if (shape is ShapeCollection)
   {
      shapeRectangle = GetShapeCollectionRect(shape as ShapeCollection);
   }
   else if (shape is ImageShape)
   {
      shapeRectangle = GetImageRectangle(shape as ImageShape);
   }
   else if (shape is TextShape)
   {
      shapeRectangle = GetTextRectangle(shape as TextShape);
   }
   else if (shape is FreeHandShape)
   {
      shapeRectangle = GetPathRectangle(shape as FreeHandShape);
   }

   // does crop rectangle intersect the shape rectangle?
   bool isInCroppedRectangle = cropRectangle.IntersectsWith(shapeRectangle);

   if (shape is ShapeCollection)
   {
      // we need to prune the shapes that are contained in the collection
      // when it is not clipped or resides in the cropped area
      var shapeCollection = shape as ShapeCollection;
      if (!shapeCollection.Clip || isInCroppedRectangle)
      {
         return PruneShapeCollection(shapeCollection, cropRectangle);
      }
      // otherwise return null
      return null;
   }

   // we return the shape when it resides in the cropped area
   if (isInCroppedRectangle)
      return shape;

   return null;
}

``` vb
Private Function PruneShape(shape As ContentShape, cropRectangle As RectangleF) As ContentShape
        ' transform the crop rectangle in order to get it 
        ' in the coordinate space of the shape
        cropRectangle = TransformRectangle(cropRectangle, shape.Transform)

        ' Shape rectangle provides a rectangle where resides the shape.
        ' Assume that shape resides in the crop rectangle.
        Dim shapeRectangle As RectangleF = cropRectangle

        ' get the shape rectangle
        If TypeOf shape Is ShapeCollection Then
            shapeRectangle = GetShapeCollectionRect(TryCast(shape, ShapeCollection))
        ElseIf TypeOf shape Is ImageShape Then
            shapeRectangle = GetImageRectangle(TryCast(shape, ImageShape))
        ElseIf TypeOf shape Is TextShape Then
            shapeRectangle = GetTextRectangle(TryCast(shape, TextShape))
        ElseIf TypeOf shape Is FreeHandShape Then
            shapeRectangle = GetPathRectangle(TryCast(shape, FreeHandShape))
        End If

        ' does crop rectangle intersect the shape rectangle?
        Dim isInCroppedRectangle As Boolean = cropRectangle.IntersectsWith(shapeRectangle)

        If TypeOf shape Is ShapeCollection Then
            ' we need to prune the shapes that are contained in the collection
            ' when it is not clipped or resides in the cropped area
            Dim shapeCollection = TryCast(shape, ShapeCollection)
            If Not shapeCollection.Clip OrElse isInCroppedRectangle Then
                Return PruneShapeCollection(shapeCollection, cropRectangle)
            End If
            ' otherwise return null
            Return Nothing
        End If

        ' we return the shape when it resides in the cropped area
        If isInCroppedRectangle Then
            Return shape
        End If

        Return Nothing
    End Function

The TransformRectangle method applies provided transformation to the specified rectangle.

private static RectangleF TransformRectangle(RectangleF rect, Transform transform)
{
   System.Drawing.Drawing2D.Matrix matrix = transform.CreateGdiMatrix();
   matrix.Invert();

   var p1 = new PointF(rect.Left, rect.Bottom);
   var p2 = new PointF(rect.Right, rect.Top);

   var points = new[] { p1, p2 };
   matrix.TransformPoints(points);

   p1 = points[0];
   p2 = points[1];

   float x = Math.Min(p1.X, p2.X);
   float y = Math.Min(p1.Y, p2.Y);
   float width = Math.Abs(p1.X - p2.X);
   float height = Math.Abs(p1.Y - p2.Y);

   return new RectangleF(x, y, width, height);
}
Private Function TransformRectangle(rect As RectangleF, transform As Transform) As RectangleF
        Dim matrix As System.Drawing.Drawing2D.Matrix = transform.CreateGdiMatrix()
        matrix.Invert()

        Dim p1 = New PointF(rect.Left, rect.Bottom)
        Dim p2 = New PointF(rect.Right, rect.Top)

        Dim points = {p1, p2}
        matrix.TransformPoints(points)

        p1 = points(0)
        p2 = points(1)

        Dim x As Single = Math.Min(p1.X, p2.X)
        Dim y As Single = Math.Min(p1.Y, p2.Y)
        Dim width As Single = Math.Abs(p1.X - p2.X)
        Dim height As Single = Math.Abs(p1.Y - p2.Y)

        Return New RectangleF(x, y, width, height)
    End Function

The PruneShapeCollection method will create a new set of shapes. It will throw away shapes that are outside the provided crop rectangle.

private static ContentShape PruneShapeCollection(ShapeCollection shapes, RectangleF cropRectangle)
{
   var result = new ShapeCollection(shapes.Width, shapes.Height);

   foreach (var shape in shapes)
   {
      var contentShape = shape as ContentShape;

      if (contentShape != null)
      {
         Shape prunedShape = PruneShape(contentShape, cropRectangle);
         if (prunedShape != null)
         {
            result.Add(prunedShape);
         }
      }
      else
      {
         // Keep shapes that are not content shapes.
         result.Add(shape);
      }
   }
   result.Transform = shapes.Transform;
   result.BlendMode = shapes.BlendMode;
   result.Clip = shapes.Clip;
   result.Dock = shapes.Dock;
   result.Margin = shapes.Margin;
   result.Opacity = shapes.Opacity;

   return result;
}
Private Function PruneShapeCollection(shapes As ShapeCollection, cropRectangle As RectangleF) As ContentShape
        Dim result = New ShapeCollection(shapes.Width, shapes.Height)

        For Each shape In shapes
            Dim contentShape = TryCast(shape, ContentShape)

            If contentShape IsNot Nothing Then
                Dim prunedShape As Shape = PruneShape(contentShape, cropRectangle)
                If prunedShape IsNot Nothing Then
                    result.Add(prunedShape)
                End If
            Else
                ' Keep shapes that are not content shapes.
                result.Add(shape)
            End If
        Next
        result.Transform = shapes.Transform
        result.BlendMode = shapes.BlendMode
        result.Clip = shapes.Clip
        result.Dock = shapes.Dock
        result.Margin = shapes.Margin
        result.Opacity = shapes.Opacity

        Return result
    End Function

Here are a number of methods that return a boundary rectangle of a specific shape.

private static RectangleF GetImageRectangle(ImageShape imageShape)
{
   return new RectangleF(0, 0, (float)imageShape.Width, (float)imageShape.Height);
}

private static RectangleF GetTextRectangle(TextShape textShape)
{
   return new RectangleF(0, 0, (float)textShape.MeasuredWidth, (float)textShape.MeasuredHeight);
}

private static RectangleF GetShapeCollectionRect(ShapeCollection shapeCollection)
{
   return new RectangleF(0, 0, (float)shapeCollection.Width, (float)shapeCollection.Height);
}

private static RectangleF GetPathRectangle(FreeHandShape freehandShape)
{
   double minX = double.MaxValue;
   double minY = double.MaxValue;
   double maxX = double.MinValue;
   double maxY = double.MinValue;

   foreach (var path in freehandShape.Paths)
   {
      foreach (var segment in path.Segments)
      {
         var bezierSegment = segment as FreeHandBezierSegment;
         if (bezierSegment != null)
         {
            minX = Math.Min(minX, bezierSegment.X1);
            minX = Math.Min(minX, bezierSegment.X2);
            minX = Math.Min(minX, bezierSegment.X3);
            maxX = Math.Max(maxX, bezierSegment.X1);
            maxX = Math.Max(maxX, bezierSegment.X2);
            maxX = Math.Max(maxX, bezierSegment.X3);
            minY = Math.Min(minY, bezierSegment.Y1);
            minY = Math.Min(minY, bezierSegment.Y2);
            minY = Math.Min(minY, bezierSegment.Y3);
            maxY = Math.Max(maxY, bezierSegment.Y1);
            maxY = Math.Max(maxY, bezierSegment.Y2);
            maxY = Math.Max(maxY, bezierSegment.Y3);
         }
         var lineSegment = segment as FreeHandLineSegment;
         if (lineSegment != null)
         {
            minX = Math.Min(minX, lineSegment.X1);
            maxX = Math.Max(maxX, lineSegment.X1);
            minY = Math.Min(minY, lineSegment.Y1);
            maxY = Math.Max(maxY, lineSegment.Y1);
         }
         var startSegment = segment as FreeHandStartSegment;
         if (startSegment != null)
         {
            minX = Math.Min(minX, startSegment.X);
            maxX = Math.Max(maxX, startSegment.X);
            minY = Math.Min(minY, startSegment.Y);
            maxY = Math.Max(maxY, startSegment.Y);
         }
      }
   }

   return new RectangleF((float)minX, (float)minY, 
                         (float)Math.Abs(maxX - minX), 
                         (float)Math.Abs(maxY - minY));
}
Private Function GetImageRectangle(imageShape As ImageShape) As RectangleF
        Return New RectangleF(0, 0, CSng(imageShape.Width), CSng(imageShape.Height))
    End Function

    Private Function GetTextRectangle(textShape As TextShape) As RectangleF
        Return New RectangleF(0, 0, CSng(textShape.MeasuredWidth), CSng(textShape.MeasuredHeight))
    End Function

    Private Function GetShapeCollectionRect(shapeCollection As ShapeCollection) As RectangleF
        Return New RectangleF(0, 0, CSng(shapeCollection.Width), CSng(shapeCollection.Height))
    End Function

    Private Function GetPathRectangle(freehandShape As FreeHandShape) As RectangleF
        Dim minX As Double = Double.MaxValue
        Dim minY As Double = Double.MaxValue
        Dim maxX As Double = Double.MinValue
        Dim maxY As Double = Double.MinValue

        For Each path In freehandShape.Paths
            For Each segment In path.Segments
                Dim bezierSegment = TryCast(segment, FreeHandBezierSegment)
                If bezierSegment IsNot Nothing Then
                    minX = Math.Min(minX, bezierSegment.X1)
                    minX = Math.Min(minX, bezierSegment.X2)
                    minX = Math.Min(minX, bezierSegment.X3)
                    maxX = Math.Max(maxX, bezierSegment.X1)
                    maxX = Math.Max(maxX, bezierSegment.X2)
                    maxX = Math.Max(maxX, bezierSegment.X3)
                    minY = Math.Min(minY, bezierSegment.Y1)
                    minY = Math.Min(minY, bezierSegment.Y2)
                    minY = Math.Min(minY, bezierSegment.Y3)
                    maxY = Math.Max(maxY, bezierSegment.Y1)
                    maxY = Math.Max(maxY, bezierSegment.Y2)
                    maxY = Math.Max(maxY, bezierSegment.Y3)
                End If
                Dim lineSegment = TryCast(segment, FreeHandLineSegment)
                If lineSegment IsNot Nothing Then
                    minX = Math.Min(minX, lineSegment.X1)
                    maxX = Math.Max(maxX, lineSegment.X1)
                    minY = Math.Min(minY, lineSegment.Y1)
                    maxY = Math.Max(maxY, lineSegment.Y1)
                End If
                Dim startSegment = TryCast(segment, FreeHandStartSegment)
                If startSegment IsNot Nothing Then
                    minX = Math.Min(minX, startSegment.X)
                    maxX = Math.Max(maxX, startSegment.X)
                    minY = Math.Min(minY, startSegment.Y)
                    maxY = Math.Max(maxY, startSegment.Y)
                End If
            Next
        Next

        Return New RectangleF(CSng(minX), CSng(minY), CSng(Math.Abs(maxX - minX)), CSng(Math.Abs(maxY - minY)))
    End Function

No results

Add Long Term Validation (LTV) data to an existing signature
Render PDF to multipage color TIFF
Render PDF page to Skia surface
Render PDF page as PNG
How to downscale all images in a PDF
This code sample shows how to downscale images in a PDF file. Read this Tall Components code sample or search our code sample base.
How to generate and export certificates
In this Tall Components code sample we will show you how you can create an RSA 2048-bit PEM certificate and how you can export it.
How to downscale all images in a PDF
This code sample shows how to downscale images in a PDF file. Read this Tall Components code sample or search our code sample base.
Add Stamp to PDF
This code sample shows how to stamp a PDF in C#. You can stamp images and watermarks to your PDF for example.
How to use a system font for rendering text
This code sample shows how you can render text using a system font. Read this Tall Components code sample or search our code sample base.
Customize the GUI interaction of a radio button
This sample shows how one can create a custom radio button interactor that responds to other key strokes than just the space bar.
Customize the UI interaction of a check box
This sample shows how one can create a custom check box interactor that responds to other key strokes than just the space bar.
PDF to grayscale TIFF
In the .NET framework the support for grayscale bitmaps is a bit puzzling. There is a way to convert PDF to grayscale Tiff in C#.
How to reduce PDF file size
Adobe Acrobat has an option to save a document with a reduced size. This article shows how to reduce pdf file size with PDFKit.NET.
How do I create graphics with Icc based colors
This article explains how one creates graphics that use Icc based colors. Read this code sample or search our code sample base.
Highlight fields in PDF
This code sample shows how to mark all fields in a PDF document. Read this Tall Components code sample or search our code sample base.
Add a note to PDF
This code sample shows how to add a note to a PDF document. Read this Tall Components code sample or search our code sample base.
Display PDF in a WPF app and stay responsive – the code
This article helps how to stay responsive while rendering a a PDF document in a WPF application. Read this or search our code sample base.
Draw interactively on a PDF page
This article allows users to interactively draw lines on PDF pages and save the resulting document. Read this or search our code sample base.
Resize PDF pages
This sample demonstrates how to change the size of pages in the PDF file. Read this code sample or search our code sample base.
Verify a custom digital PDF signature
In the article we explain how to verify a custom digital PDF signature. Read this Tall Components code sample or search our code sample base.
C# Print PDF documents from a WPF application
This code sample shows how to print PDF documents from a WPF application using C#. Read this code sample or search our code sample base.
Extract glyph boxes from PDF
This sample creates a bitmap for each page and draws boxes for each glyph. Read this code sample or search our code sample base.
Use TrueType font collections
This article describes how to select a font from a font collection and how this is embedded in a PDF document. Read or search our base.
Layout text with MultilineTextShape
This sample demonstrates how to format and layout text with MultilineTextShape. Read this code sample or search our code sample base.
Calculate the height of a paragraph in PDF
This code sample demonstrates how to use the event mechanism to calculate the height of a paragraph in a PDF.
Merge PDF files in C# .NET
In the following code sample you can see how you can easily merge PDF files into one. Read this code sample or search our code sample base.
How do I extract page destinations from bookmarks?
This article explains how one can determine which page a particular bookmark refers to. Read this code sample or search our code sample base.
Clip PDF page content in C#
This sample demonstrates how to mask out a rectangular area on a PDF page using a clip shape in C#. Read this or search our code sample base.
How do I use PDFControls.NET in a WPF application
This code sample shows you how PDFControls.NET can be used in a WPF application. Read this code sample or search our code sample base.
Fill PDF form
This code sample shows how to assign values to various types of PDF form fields. Read this code sample or search our code sample base.
Extract glyphs and sort by reading order
This code sample shows how to extract glyphs from PDF and sort. Read this Tall Components code sample or search our code sample base.
Add bookmarks to PDF
This code sample shows how to create bookmarks in an existing PDF document. Read this code sample or search our code sample base.
How to scale content of PDF
This code sample creates a copy of a PDF document but the content in the output PDF is scaled. Read this or search our code sample base.
Create rectangles with rounded corners
A Rectangle with rounded corners is not a standard shape. However it is easy to create these. Read this or search our code sample base.
Create text with decorations
Create a document with text with decorations like gradient color, shadow, emboss and glow. Read this or search our code sample base.
Create layers in PDF and draw on each layer
This code sample shows how to create a document and adds two new layers. Read this code sample or search our code sample base.
Multipage TIFF to PDF
This article shows you how to convert a multipage TIFF to PDF using TallPDF.NET. Read this code sample or search our code sample base.
TIFF to PDF C#
This article shows you how to convert a multipage TIFF to PDF using PDFKit.NET. Read this code sample or search our code sample base.
Crop content on a PDF page
This code sample shows how to remove all content that is outside a crop rectangle. Read this code sample or search our code sample base.
How to embed files in a PDF document
This code sample shows how to add embedded files (attachments) to a PDF document. Read this code sample or search our code sample base.
Remove graphics from PDF
This code sample shows how to partly erase images from a PDF under an explicitly specified rectangle. Read or search our code sample base.
Change the color inside a PDF
This code sample shows how to change color in a PDF using C# and VB.NET. Read this code sample or search our code sample base.
Create PDF in C#
This simple code sample shows you how to create a PDF using C# and print "Hello World" to it. Read or search our code sample base.
Text formatting
This code sample shows how to format your text. Read this Tall Components code sample or search our code sample base.
Import FDF into PDF
In this code sample we will show how you can easily import an FDF file and populate the form fields in a PDF.
Flatten PDF form
This code sample shows how to fill out a form and then flatten it. Read this code sample or search our code sample base.
Digitally sign a PDF form in C# or VB.NET
This code sample shows you how you can import a digital signature and use it to sign a PDF document in C# or VB.NET.
Vector graphics in PDF
This code sample shows how to draw different vector graphics such as line, ellipses and bezier curves. Read code sample or search our base.
Translate PDF page content
This code sample shows how to apply a single translation to all the content on a PDF page. Read or search our code sample base.
Extract graphics from PDF
This c# code sample shows how to extract text, images and curves as shapes from a PDF document. Read or search our code sample base.
Determine the content bounding box
This article shows how to determine the content bounding of a page. Read this Tall Components code sample or search our code sample base.
How to add page numbers to your PDF
This article shows how to add page numbers to PDF using TallPDF built-in features. Read or search our code sample base.
Create / impose PDF 2-up
This code sample shows how to do 2-up imposition using the PageShape class. Read this code sample or search our code sample base.
Search text in PDF
This article shows how to search a PDF for text in C# using the Document. Read this code sample or search our code sample base.
Append multiple PDF documents
This code sample illustrates to loop through a given folder and append each PDF documents found into a new generated PDF document.
Convert PDF to plain text
The following code sample shows how to convert the collection of glyphs on a PDF page to a text string. Read or search our code sample base.
Flatten Markup Annotation
This article illustrate how to turn markups to images by flatten markups. Read this code sample or search our code sample base.
Add text field to PDF
This code sample illustrates how you can add TextFields to your PDF. Read this Tall Components code sample or search our code sample base.
Extract embedded files from PDF
This code sample illustrates how to loop through embedded files in an existing PDF document and extract those attachments. Read more.
Extract images from PDF
This code sample illustrates how to iterate through existing content in a PDF document and save each images found as a new Image file.
Add a Diagonal Watermark to PDF in C#
This code sample shows how to add a diagonal watermark to an existing PDF in C#. Read this code sample or search our code sample base.
Fit image to PDF page
This code sample shows how to stamp an image on a PDF page and have the image fit to the size of the page. Read this code sample.
Add simple html text to PDF
The SimpleXhtmlShape lets you add text with simple HTML mark-up to a PDF document. Read or search our code sample base.
Add multiline text to a PDF document
The MultilineTextShape lets you add multiline text to PDF with mixed formatting and line-breaking. Read this code sample or search our code sample base.
Add single-line text to PDF
TextShape allows you to add single-line text to a PDF document. Read this Tall Components code sample or search our code sample base.
Create a new digitally signed PDF document
This code sample creates a new PDF document, adds a signature fields, and then digitally signs it. Read or search our code sample base.
PDF Viewer Preferences
The following code sample shows how to set the viewer preferences of a PDF document. Read or search our code sample base.
Change page orientation PDF
Code sample to change the page orientation PDF. Read this Tall Components code sample or search our code sample base.
Split PDF pages in C# and VB.NET
The following code sample shows how to split PDF pages in C# and VB.NET. Read this code sample or search our code sample base.
Append two or more existing PDF files
The following code sample shows how to append PDF files. Read this Tall Components code sample or search our code sample base.
Change colors of black-and-white TIFF after converting from PDF
In this article, we will demonstrate how to change the color palette after converting a PDF document to 1bpp TIFF in C#.
Determine if a PDF only contains images
The following sample code determines whether a PDF document only contains images (and not other shapes such as text fragments).
Add footer to PDF
This code sample shows how to add a footer in a PDF document. Read this Tall Components code sample or search our code sample base.
Convert SVG to PDF
This article explains how to use these text and fonts in SVG documents. Read this code sample or search our code sample base.
Fill in a PDF form using MVC
In this sample we will create a small ASP.NET application to fill in pdf forms, using a webform. Read or search our code sample base.
C# render pdf in browser using MVC
In this code sample we will be using the PDF Rasterizer package in a MVC context to render specific PDF pages in a browser.
Convert XHTML to PDF
This code sample shows how to add a note to a PDF document C#. Read this code sample or search our code sample base.
Add hyperlink to PDF
This code samples draws a hyperlink on an existing PDF page. Read this code sample or search our code sample base.
Rotate a PDF page
This code sample creates a copy of a PDF document with each page rotated 90 degrees. Read or search our code sample base.
Change the formatting of a numeric field
This code sample changes the format by changing the JavaScript of the action. Read or search our code sample base.
How to mirror PDF pages and other shapes
In this code sample we will mirror the pages in an existing PDF document. Read this code sample or search our code sample base.
Fill in a template PDF document
This code sample shows you how you can import a template document and fill it in with data from a database.
How to add autosized text to PDF
This code sample shows you how you can add a piece of auto-sized text to your PDF document. Read or search our code sample base.
Create formfields in PDF documents
This codesample shows how you can create different types of formfields in PDF. Read this code sample or search our code sample base.
Export FDF from PDF form
This code sample helps to exports FDF from PDF. Read this Tall Components code sample or search our code sample base.
Add a link with an internal destination to PDF
This code sample helps with internal links in a PDF. Read this Tall Components code sample or search our code sample base.
Remove PDF security settings
This code sample shows how you can remove the security setting of a PDF quite easily; just set the security attribute to null.
Add a link to PDF with an external destination
This code sample helps adding an external link to your PDF. Read this code sample or search our code sample base.
How to sign and verify updates to a PDF document
This code sample shows how you can sign PDF documents and how to handle updates to form data. Read or search our code sample base.
Convert PDF to PNG using WPF
In this code sample we take a look how you can create PNG images from a PDF using the Windows Presentation Foundation.
Embed TrueType font
This code sample shows how to draw text on a page using a TrueType font and embed this font in the PDF. Read or search our code sample base.
Override MouseWheel event
This code sample helps to override MouseWheel event. Read this Tall Components code sample or search our code sample base.
Convert PDF to an image using a dither matrix
This code sample shows how to convert a PDF page to a bitmap image, while applying a dither matrix to the generated image.
Font mapping
If you have a PDF document which uses non-embedded fonts, you can specify your font substitution map to specify which fonts need to be used.
Convert PDF with layers to image
In the code sample below you see how you can incorporate multiple layers into your rendering process. Read or search our code sample base.
C# Print PDF Document
C# Print PDF? With this sample you can get an impression of how to print a PDF in C#. Read this code sample or search our code sample base!
Render PDF with ResolveFont event handler
When you try to render a PDF which uses non-system fonts, you can add your own specified fonts to make sure it is rendered correctly.
Render PDF to EMF
This code sample helps render PDF to EMF. Read this Tall Components code sample or search our code sample base.
Convert PDF to XPS
In this sample you can see how you convert your PDF document to an XPS format (which is Microsoft Windows' version of PDF).
How to create a thumbnail viewer
This sample shows how you can create a thumbnail viewer for your PDF application and it builds on the SimpleViewer code sample.
How to create a tiling for shapes in PDF
In this code sample we will show you how you can create a rectangle and fill it using a TilingBrush containing dots.
Add footer with left and right aligned text on same line
Add a footer to a PDF document that has left aligned text with a page number and right aligned text on the same line.
Convert PDF to JPG in C#
This code sample shows how to convert PDF to JPG or JPEG in C#. Read this Tall Components code sample or search our code sample base.
EMF to PDF as vector image
EMF is the Windows Meta file file format for images. Read this Tall Components code sample or search our code sample base.
EMF to PDF as raster image
This code sample helps to create a Bitmap (PDF) from an EMF file in C#. Read this Tall Components code sample or search our code sample base.
Replace field with image
This code sample opens a PDF with a textfield and replaces this textfield with an image. Read or search our code sample base.
Add a rubber stamp annotation with a custom icon
This article shows how to create a customized rubber stamp annotation. Read this code sample or search our code sample base.
Create a text annotation in PDF with rich text
This sample shows how to create annotations in PDF that use a rich text for their appearance. Read or search our code sample base.
XhtmlParagraph and TrueType fonts
The following code converts XHTML to PDF using the XhtmlParagraph. Read this code sample or search our code sample base.
What is the resulting fontsize in PDF for rich text used in a SimpleXhtmlShape
TallPDF supports the SimpleXhtmlShape. This shape accepts PDF rich text as its Text attribute. Read or search our code sample base.
Read and write meta data from PDF
This article shows a sample for reading and writing meta data from PDF using C#. Read this code sample or search our code sample base.
Create a custom signature handler to sign and verify PDF documents
This code sample shows how to create your own signature handler. Read this code sample or search our code sample base.
Merge PDF
In this code sample we will create a new PDF by stitching two existing PDF documents. Read or search our code sample base.
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.
Download and convert image to PDF
This article shows how to download an image on a web page as a PDF document. Read this code sample or search our code sample base.
Convert TXT to PDF
This code sample helpt converting TXT to PDF. Read this Tall Components code sample or search our code sample base.
Add barcodes to PDF
This article demonstrates how to add barcodes to a PDF document. Read this code sample or search our code sample base.
Convert PDF to multipage TIFF in C# .NET
This article shows how to convert PDF to multipage TIFF in C# using PDFRasterizer.NET 3.0. Read or search our code sample base.
Convert multiple PDF pages to bitmap
In this article, we will convert multple pages of a PDF to a single bitmap. Read this code sample or search our code sample base.
Render a PDF to bitmap
This article explains the most basic way to convert PDF to bitmap. Read this code sample or search our code sample base.
Bulleted list from XML and XSL
This code sample helps getting a bulleted list from XML and XSL. Read this code sample or search our code sample base.
Tagged PDF
This code sample helps create and consume tagged PDF documents. Read this code sample or search our code sample base.
PDFKit.NET 5.0 – detailed changes to the API
This article compares the builds that 4.0 and 5.0 have in common: net20, net40, net40-client and net40-wpf.
Create tagged PDF
This code sample demonstrate how to create a new tagged PDF. Read this Tall Components code sample or search our code sample base.
PDFKit.NET 5.0 and .NET Core
PDFKit.NET 5.0 includes a build targeting .NET Standard 1.5. According to the following table, it supports .NET Core 1.0 and higher.
PDFKit.NET 5.0 and Xamarin
This code samples helps with PDFKit.NET 5.0 and Xamarin. Read this Tall Components code sample or search our code sample base.
Dynamic XFA
The new dynamic XFA API of PDFKit.NET 5.0 allows populating and consuming dynamic XFA documents. Read or search our code sample base.
PDFKit.NET 5.0 .NET Standard API
This code sample helps with PDFKit.NET 5.0 .NET Standard API. Read this Tall Components code sample or search our code sample base.
.NET Core console app on MacOS
In this article we create step by step a simple .NET Core console application on MacOS. Read or search our code sample base.
Add tags to existing PDF
This article demonstrates how to open existing PDF document, read visual content and tag the visual content based on its type and content.
Read PDF tags
This code sample enumerates the tags in an existing PDF document. Read this code sample or search our code sample base.
Merge XDP data with dynamic XFA form
The following code imports XDP data into a dynamic XFA form. Read this Tall Components code sample or search our code sample base.
Fill XFA form and export XDP data
The following code opens an XFA form and programmatically fills text field and selects items from drop-down lists and exports data as XDP.
Fill and save dynamic XFA form
The following code opens a XFA form and programmatically fills text fields, selects an item from a drop-down list and 'clicks' a button.
Use PDFKit.NET 5.0 with a Xamarin.Forms app
This article demonstrates a simple Xamrin.Forms app that runs on Android, iOS and UWP. Read or search our code sample base.
Use multiple licenses
This code sample explains how to register multiple license keys with a single application. Read or search our code sample base.
Licensing and .NET Standard
This code sample helps with licensing and .NET Standard. Read this Tall Components code sample or search our code sample base.
Reduce PDF size
PDFKit5 includes support for non-desctructive PDF compresssion. Read this code sample or search our code sample base.
Generate PDF form from XML
The following code sample shows how to generate a PDF form from XML. Read this code sample or search our code sample base.
Generate PDF with local images from XML with Xamarin.iOS
This code sample generates a PDF from XML with an image that is included as resource. Read or search our code sample base.
Disable submit button after submitting
The following code adds a JavaScript action to a submit button that will disable the button after submitting.
Write Document to HttpResponse
In PDFKit.NET 5.0 we decided to remove the Document.Write(HttpResponse) because it required the client to add a reference to System.