Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
This article is based on an older PDFOne Java article. The Java article has been the most popular article so far and I guessed .NET users would also be interested in a similar solution.
PDFOne .NET supports page overlays or page stitching where pages are placed side by side, one over another, or set against specified offsets.
PDFOne .NET uses the following overloaded methods of the PDFDocument
class to perform PDF overlays.
public void Stitch( int stitchToPageNo, int stitchFromPageNo ); public void Stitch( int stitchToPageNo, int stitchFromPageNo, float offsetX, float offsetY, PDFMeasurementUnit unit );
The first method takes the content of the page specified by stitchFromPageNo
and places it over the page specified by stitchToPageNo
. The second method does the same but supports offsets from the top-left corner.
For an illustration, we will use the user requirement quoted above. Here is the document that contains the letterhead.
And, here is the document that contains the letters.
Here is the code that provides solution. As Stitch()
method to lift the contents a page in the same document, the two documents are merged to form a single document. Next, the second page is lifted and placed on the first page.
using System; using System.Collections.Generic; using System.Text; using Gnostice.PDFOne; namespace PDF_Overlay { class Program { static void Main(string[] args) { // Load the document containing the letterhead PDFDocument doc = new PDFDocument(); doc.Load("LetterHead.pdf"); // Copy page from the other document containing the letter doc.AppendPagesFrom("Letters.pdf", "1"); // Save merged document to file doc.Save("MergedDoc.pdf"); // Free I/O resources doc.Close(); // Load the merged document doc.Load("MergedDoc.pdf"); // Overlay page 2 on page 1 doc.Stitch(1, 2); // Delete the unwanted page 2 doc.DeletePages("2"); // Save overlaid document to file doc.Save("OverlaidDoc.pdf"); // Free I/O resources doc.Close(); } } }
Ta da!
---o0O0o---
Our .NET Developer Tools | |
---|---|
Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved. |