VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Processing Namespace / PdfDocumentCopyCommand Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    PdfDocumentCopyCommand Class
    In This Topic
    A processing command that copies target PDF document to the source PDF document.
    Object Model
    PdfDocument PdfBookmarkCollection PdfInteractiveFormFieldList PdfDocumentCopyCommand
    Syntax
    'Declaration
    
    Public Class PdfDocumentCopyCommand
       Inherits Vintasoft.Imaging.Processing.ProcessingCommand(Of TTarget)
    
    
    public class PdfDocumentCopyCommand : Vintasoft.Imaging.Processing.ProcessingCommand<TTarget>
    
    
    public __gc class PdfDocumentCopyCommand : public Vintasoft.Imaging.Processing.ProcessingCommand<TTarget*>*
    
    
    public ref class PdfDocumentCopyCommand : public Vintasoft.Imaging.Processing.ProcessingCommand<TTarget^>^
    
    
    Example

    Here is an example that shows how to add PDF document to another PDF document with interactive form and bookmarks:

    
    ''' <summary>
    ''' Adds PDF document to another PDF document.
    ''' </summary>
    ''' <param name="sourcePdfFilename">The name of PDF file, which should be used as source PDF document.</param>
    ''' <param name="addingPdfFilename">The name of PDF file, which must be added to the initial PDF document.</param>
    ''' <param name="outputPdfFilename">The name of PDF file, where result PDF document must be saved.</param>
    Public Shared Sub AddDocument(sourcePdfFilename As String, addingPdfFilename As String, outputPdfFilename As String)
        ' open source PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(sourcePdfFilename)
            ' open adding PDF document
            Using addingDocument As New Vintasoft.Imaging.Pdf.PdfDocument(addingPdfFilename)
                ' create an instance of PdfDocumentCopyCommand class and specify the source PDF document for PdfDocumentCopyCommand
                Dim copyDocument As New Vintasoft.Imaging.Pdf.Processing.PdfDocumentCopyCommand(document)
    
                ' specify that PdfDocumentCopyCommand must copy bookmarks from adding PDF document to the source PDF document
                copyDocument.CopyBookmarks = True
                ' specify that PdfDocumentCopyCommand must copy document-level JavaScript code from adding PDF document to the source PDF document
                copyDocument.CopyDocumentLevelJavaScripts = True
                ' specify that PdfDocumentCopyCommand must copy interactive form from adding PDF document to the source PDF document
                copyDocument.CopyInteractiveForm = True
    
                ' copy adding PDF document to the input PDF document
                copyDocument.Execute(addingDocument)
    
                ' if output path is not specified
                If String.IsNullOrEmpty(outputPdfFilename) Then
                    ' save result PDF document to the source file
                    document.SaveChanges()
                Else
                    ' if output path is specified
                    ' save result PDF document to the output file
                    document.SaveChanges(outputPdfFilename)
                End If
            End Using
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Adds PDF document to another PDF document.
    /// </summary>
    /// <param name="sourcePdfFilename">The name of PDF file, which should be used as source PDF document.</param>
    /// <param name="addingPdfFilename">The name of PDF file, which must be added to the initial PDF document.</param>
    /// <param name="outputPdfFilename">The name of PDF file, where result PDF document must be saved.</param>
    public static void AddDocument(string sourcePdfFilename, string addingPdfFilename, string outputPdfFilename)
    {
        // open source PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(sourcePdfFilename))
        {
            // open adding PDF document
            using (Vintasoft.Imaging.Pdf.PdfDocument addingDocument = new Vintasoft.Imaging.Pdf.PdfDocument(addingPdfFilename))
            {
                // create an instance of PdfDocumentCopyCommand class and specify the source PDF document for PdfDocumentCopyCommand
                Vintasoft.Imaging.Pdf.Processing.PdfDocumentCopyCommand copyDocument =
                    new Vintasoft.Imaging.Pdf.Processing.PdfDocumentCopyCommand(document);
    
                // specify that PdfDocumentCopyCommand must copy bookmarks from adding PDF document to the source PDF document
                copyDocument.CopyBookmarks = true;
                // specify that PdfDocumentCopyCommand must copy document-level JavaScript code from adding PDF document to the source PDF document
                copyDocument.CopyDocumentLevelJavaScripts = true;
                // specify that PdfDocumentCopyCommand must copy interactive form from adding PDF document to the source PDF document
                copyDocument.CopyInteractiveForm = true;
    
                // copy adding PDF document to the input PDF document
                copyDocument.Execute(addingDocument);
    
                // if output path is not specified
                if (string.IsNullOrEmpty(outputPdfFilename))
                {
                    // save result PDF document to the source file
                    document.SaveChanges();
                }
                // if output path is specified
                else
                {
                    // save result PDF document to the output file
                    document.SaveChanges(outputPdfFilename);
                }
            }
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Processing.ProcessingCommand<Vintasoft.Imaging.Pdf.PdfDocument>
          Vintasoft.Imaging.Pdf.Processing.PdfDocumentCopyCommand

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also