'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Pdf.Annotations '' 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.PublicClassMergePDFsFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument()Using fs0 = NewFileStream(Path.Combine("Resources", "PDFs", "The-Rich-History-of-JavaScript.pdf"), FileMode.Open, FileAccess.Read)Using fs1 = NewFileStream(Path.Combine("Resources", "PDFs", "CompleteJavaScriptBook.pdf"), FileMode.Open, FileAccess.Read) doc.Load(fs0)'' Save page count for the navigation link added below:Dim pgNo = doc.Pages.CountDim doc1 = NewGcPdfDocument() doc1.Load(fs1) doc.MergeWithDocument(doc1, NewMergeDocumentOptions())'' Insert a note at the beginning of the document:Dim page = doc.Pages.Insert(0)Dim rc = Util.AddNote("GcPdfDocument.MergeWithDocument() method allows adding to the current document all or some pages " +"from another document." + vbLf +"In this sample we load one PDF, append another whole PDF to it, and save the result." + vbLf +"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)EndUsingReturn doc.Pages.CountEndUsingReturn doc.Pages.CountEndFunctionEndClass