Add a tiled watermark to PDF pages
This sample shows how to add a semi-transparent, rotated text watermark to every page of an existing PDF file. It demonstrates copying each source page's content into a new PDF with PdfReader, PdfWriter, and GraphicsContainer, then using TilingBrush to repeat rotated PlainText across the page as a watermark pattern.
Add and remove pages in an existing PDF
This sample shows how to insert and delete pages of an existing PDF document. Since PDF pages can't be edited in place, it reopens the source file with PdfReader and rebuilds it page by page with PdfWriter: copying each page's content with GetContent and Graphics.DrawContainer, skipping the page to remove, and adding a brand-new page where one should be inserted.
Combine multiple PDF files into one document
This sample shows how to combine the pages of several existing PDF files into a single multi-page PDF document. It opens each source file with PdfReader, copies every page's vector content into a new document with PdfWriter and Graphics.DrawContainer, preserving each source page's own size and resolution.
Create a die-cut outline around artwork
This sample shows how to build the cut line of a sticker from the transparency of its artwork and write it to a print-ready PDF. Path.GetContour traces the outline of the opaque part of the image with sub-pixel accuracy, Path.Inflate grows it by the bleed and closes the narrow gaps between separate parts, Path.GetOuterContours drops the holes the cutter should not follow, and Path.FitCurves turns the traced polyline into smooth Bezier curves. The outline is stroked with a "CutContour" spot colour, the name cutting plotters and RIPs look for.
Create a PDF/VT file with personalized business cards
This sample shows how to generate a print-ready PDF/VT (variable-data/transactional) file containing a batch of personalized business cards. It reuses a single shared page layout loaded from a PDF template for every card, and adds document- and record-level PDF/VT metadata (job, sender, and production details) using PdfVtDictionary and the CIP4 dictionary keys. The sample uses PdfWriter with an OutputIntent and PdfVtOptions to embed a CMYK ICC profile and document metadata, and a CustomFontRegistry to draw each recipient's name, position, and contact details with custom TrueType fonts.
Create a PDF/X-4 file with CMYK output intent
This sample shows how to create a PDF/X-4 document with a CMYK output intent using GraphicsMill. It demonstrates how to load a CMYK print profile, configure an OutputIntent, initialize a PdfWriter with that intent, convert an RGB image to CMYK using color management, and draw it onto a PDF page together with a solid CMYK-filled shape.
Create Business Card
Creates business card in PDF format.
Create Multipage PDF
Creates multipage PDF with personalized wedding invitations.
Draw On PDF With Spot Color
Fills a rectangle with a PANTONE color.
Draw Spot On CMYK
Draws a text and an image on the spot channel, using the existing CMYK image as a background.
Enum Container Elements
Enumerates the elements of a graphics container.
Fade and shape images with soft masks
This sample shows how to make parts of an item gradually transparent with a soft mask, the PDF way of masking that keeps both the item and the mask vector. A soft mask is a GraphicsContainer assigned to an item through its SoftMask property. With SoftMaskMethod.Luminosity the brightness of the mask sets the opacity: here a white-to-black gradient fades a photo out to the right. With SoftMaskMethod.Alpha only the transparency of the mask counts and its colours are ignored: here the alpha channel of a PNG gives a second photo the shape of a postage stamp.
Lay out paragraphs, lists, and tab-aligned columns in a PDF
This sample shows how to lay out a page of formatted text directly in a PDF using BoundedText's XML-based markup: regular paragraphs with first-line indentation and paragraph spacing, a bulleted list with custom line leading, and a two-column schedule where each session's title flows from the left and its time is pushed to a right-aligned tab stop by a dot leader, the classic layout of a printed program or table of contents.
Overlay one PDF's graphics onto another
This sample shows how to overlay the vector content of one PDF file, such as a seal or logo, onto every page of another PDF file. It reads the stamp from "Seal.pdf" and the page content from "GraphicsContainer.pdf" with PdfReader, shrinks the stamp's GraphicsContainer to a fixed size with Scale, then draws the page content and the stamp together onto each output page with PdfWriter and Graphics.DrawContainer.
PDF Layers
Creates a PDF with layered content.
PDF To SVG
Reads vector content from a PDF file and saves it to an SVG format.
Place JPEG photos into a PDF without recompression
This sample shows how to put JPEG photos into a PDF quickly and with little memory by storing their original compressed data in the file as is. An image loaded with CompressedImage.CreateFromFile keeps its encoded bytes, and Graphics.DrawImage writes them to the PDF without decoding and compressing them again: the photos are never held in memory as pixels, no time is spent on JPEG decoding and encoding, and there is no second JPEG quality loss. RGB and CMYK JPEG files are both kept as is. For comparison, the sample writes the same photos to a JPEG-compressed PDF once more from decoded Bitmap objects and prints how long each way takes.
Rasterize a PDF page two ways: quick vs. full control
This sample compares the two ways to turn a PDF page into a bitmap. PdfFrame.GetBitmap is the quickest option, but it always returns a 24-bit RGB bitmap at the page's own resolution. Getting the page's vector content with GetContent and rasterizing it separately with GraphicsContainerRasterizer is slower, since rendering goes through the vector content rather than a ready-made bitmap, but it allows any target pixel format and resolution, such as an alpha-capable format at a higher DPI than the source page.
Read and write PDF page boxes
This sample shows how to define print production page boundaries (MediaBox, CropBox, BleedBox, TrimBox, and ArtBox) when writing a 300 DPI PDF, and how to read them back afterwards. It builds a bleed-aware business card layout with PdfWriter and PdfPage, converting real-world sizes to pixels with UnitConverter, then reopens the file with PdfReader to show that CropBox, BleedBox, TrimBox, and ArtBox always come back in points regardless of the page's DPI.
Recolor Red Strokes
Demonstrates how to modify the stroke colors of shapes within a graphics container by detecting red strokes and recoloring them.
Replace Process Color
Converts the specified process color into a spot color saving graphics container to the PDF format.
Save Spot Image To PDF
Saves an image with a spot color to PDF.
Save Vector Content To JPEG
Reads vector content from the specified PDF file, rasterizes it, and saves it in JPEG format.
Supply linked images when reading SVG
This sample shows how to read an SVG whose images are not next to it, for example a design from an online editor that refers to its pictures by URL. The SvgReaderSettings.ResolveImage callback is called for every image element; it gets the reference through ResolveImageArgs.Href and supplies the content itself: a raster image through ResolveImageArgs.Image or vector graphics through ResolveImageArgs.GraphicsContainer. Here a photo comes from a local cache as a CompressedImage, so its JPEG data reaches the output PDF unchanged, and a seal comes from a PDF file and stays vector.
SVG To PDF
Converts SVG file to PDF format.
Write Bitmap To PDF Memory Friendly
Saved bitmap to PDF format using memory-friendly Pipeline API.
Write Raster And Vector Graphics To PDF
Saves raster and vector graphics to PDF format.
Write Text To PDF
Demonstrates writing text as PDF text.