//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingGrapeCity.Documents.Pdf;usingGrapeCity.Documents.Pdf.Annotations; namespaceDsPdfWeb.Demos{// This sample shows how to merge two existing PDFs into a single document.// The method GcPdfDocument.MergeWithDocument() provides this feature,// and allows inserting all or some pages from another PDF into the current// document. The simplest form of this method is demonstrated in this sample,// appending a whole PDF to the current document.publicclassMergePDFs {publicintCreatePDF(Stream stream) {usingvar fs0 = File.OpenRead(Path.Combine("Resources", "PDFs", "The-Rich-History-of-JavaScript.pdf"));usingvar fs1 = File.OpenRead(Path.Combine("Resources", "PDFs", "CompleteJavaScriptBook.pdf")); var doc = newGcPdfDocument(); doc.Load(fs0);// Save page count for the navigation link added below:var pgNo = doc.Pages.Count;var doc1 = newGcPdfDocument(); doc1.Load(fs1); doc.MergeWithDocument(doc1, newMergeDocumentOptions()); // Insert a note at the beginning of the document:var page = doc.Pages.Insert(0);var rc = Common.Util.AddNote("GcPdfDocument.MergeWithDocument() method allows adding to the current document all or some pages " +"from another document.\n" +"In this sample we load one PDF, append another whole PDF to it, and save the result.\n" +"Click this note to jump directly to the first page of the 2nd document.", page); // Link the note to the first page of the second document: page.Annotations.Add(newLinkAnnotation(rc, newDestinationFit(pgNo + 1)));// Done (target document must be saved BEFORE the source is disposed): doc.Save(stream);return doc.Pages.Count; } }}