Exemplo n.º 1
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Starting with Toolkit version 10 native DLLs are no longer
            // copied to the system folder. The Toolkit constructor must
            // be called with the path to the native DLLs or place them
            // in your applications working directory. This example
            // assumes they are located in the default installation folder.
            // (Use x86 in the path for 32b applications)
            string toolkitPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)}\ActivePDF\Toolkit\bin\x64";

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit(toolkitPath))
            {
                // Here you can place any code that will alter the output file
                // such as adding security, setting page dimensions, etc.

                // Create the new PDF file
                int result = toolkit.OpenOutputFile(FileName: $"{strPath}Toolkit.ResetPDFView.pdf");
                if (result != 0)
                {
                    WriteResult($"Error opening output file: {result.ToString()}", toolkit);
                    return;
                }

                // Open the template PDF
                result = toolkit.OpenInputFile(InputFileName: $"{strPath}Toolkit.Input.pdf");
                if (result != 0)
                {
                    WriteResult($"Error opening input file: {result.ToString()}", toolkit);
                    return;
                }

                // Get the reference to the InitialViewInfo object
                APToolkitNET.InitialViewInfo viewInfo = toolkit.GetInitialViewInfo();

                // Reset the initial view settings for the PDF to default
                viewInfo.Reset();

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(FirstPage: 0, LastPage: 0);
                if (result != 1)
                {
                    WriteResult($"Error copying file: {result.ToString()}", toolkit);
                    return;
                }

                // Close the new file to complete PDF creation
                toolkit.CloseOutputFile();
            }

            // Process Complete
            WriteResult("Success!");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit())
            {
                // Here you can place any code that will alter the output file
                // such as adding security, setting page dimensions, etc.

                // Create the new PDF file
                int result = toolkit.OpenOutputFile(FileName: $"{strPath}Toolkit.PDFViewData.pdf");
                if (result != 0)
                {
                    WriteResult($"Error opening output file: {result.ToString()}", toolkit);
                    return;
                }

                // Open the template PDF
                result = toolkit.OpenInputFile(InputFileName: $"{strPath}Toolkit.Input.pdf");
                if (result != 0)
                {
                    WriteResult($"Error opening input file: {result.ToString()}", toolkit);
                    return;
                }

                // Get the reference to the InitialViewInfo object
                APToolkitNET.InitialViewInfo viewInfo = toolkit.GetInitialViewInfo();

                // Options for viewer window
                Console.WriteLine($"Center Window: {viewInfo.CenterWindow}");
                Console.WriteLine($"Full Screen: {viewInfo.FullScreen}");
                Console.WriteLine($"Resize Window: {viewInfo.ResizeWindow}");
                Console.WriteLine($"Show: {viewInfo.Show}");

                // Show or hide UI elements of the viewer
                Console.WriteLine($"Hide Menu Bar: {viewInfo.HideMenuBar}");
                Console.WriteLine($"Hide Tool Bars: {viewInfo.HideToolBars}");
                Console.WriteLine($"Hide Window Controls: {viewInfo.HideWindowControls}");
                Console.WriteLine($"Navigation Tab: {viewInfo.NavigationTab}");

                // Page settings
                Console.WriteLine($"Magnification: {viewInfo.Magnification}");
                Console.WriteLine($"Open To Page: {viewInfo.OpenToPage}");
                Console.WriteLine($"Page Layout: {viewInfo.PageLayout}");

                // Close the input file
                toolkit.CloseInputFile();
            }

            // Process Complete
            WriteResult("Success!");
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Starting with Toolkit version 10 native DLLs are no longer
            // copied to the system folder. The Toolkit constructor must
            // be called with the path to the native DLLs or place them
            // in your applications working directory. This example
            // assumes they are located in the default installation folder.
            // (Use x86 in the path for 32b applications)
            string toolkitPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)}\ActivePDF\Toolkit\bin\x64";

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit(CoreLibPath: toolkitPath))
            {
                // Open the template PDF
                int result = toolkit.OpenInputFile(InputFileName: $"{strPath}Toolkit.Input.pdf");
                if (result == 0)
                {
                    // Get the reference to the InitialViewInfo object
                    APToolkitNET.InitialViewInfo viewInfo = toolkit.GetInitialViewInfo();

                    // Options for viewer window
                    Console.WriteLine($"Center Window: {viewInfo.CenterWindow}");
                    Console.WriteLine($"Full Screen: {viewInfo.FullScreen}");
                    Console.WriteLine($"Resize Window: {viewInfo.ResizeWindow}");
                    Console.WriteLine($"Show: {viewInfo.Show}");

                    // Show or hide UI elements of the viewer
                    Console.WriteLine($"Hide Menu Bar: {viewInfo.HideMenuBar}");
                    Console.WriteLine($"Hide Tool Bars: {viewInfo.HideToolBars}");
                    Console.WriteLine($"Hide Window Controls: {viewInfo.HideWindowControls}");
                    Console.WriteLine($"Navigation Tab: {viewInfo.NavigationTab}");

                    // Page settings
                    Console.WriteLine($"Magnification: {viewInfo.Magnification}");
                    Console.WriteLine($"Open To Page: {viewInfo.OpenToPage}");
                    Console.WriteLine($"Page Layout: {viewInfo.PageLayout}");

                    // Close the input file
                    toolkit.CloseInputFile();
                }
                else
                {
                    WriteResult($"Error opening input file: {result.ToString()}", toolkit);
                    return;
                }
            }

            // Process Complete
            WriteResult("Success!");
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit())
            {
                // Here you can place any code that will alter the output file
                // such as adding security, setting page dimensions, etc.

                // Create the new PDF file
                int result = toolkit.OpenOutputFile(FileName: $"{strPath}Toolkit.ResetPDFView.pdf");
                if (result != 0)
                {
                    WriteResult($"Error opening output file: {result.ToString()}", toolkit);
                    return;
                }

                // Open the template PDF
                result = toolkit.OpenInputFile(InputFileName: $"{strPath}Toolkit.Input.pdf");
                if (result != 0)
                {
                    WriteResult($"Error opening input file: {result.ToString()}", toolkit);
                    return;
                }

                // Get the reference to the InitialViewInfo object
                APToolkitNET.InitialViewInfo viewInfo = toolkit.GetInitialViewInfo();

                // Reset the initial view settings for the PDF to default
                viewInfo.Reset();

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(FirstPage: 0, LastPage: 0);
                if (result != 1)
                {
                    WriteResult($"Error copying file: {result.ToString()}", toolkit);
                    return;
                }

                // Close the new file to complete PDF creation
                toolkit.CloseOutputFile();
            }

            // Process Complete
            WriteResult("Success!");
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit())
            {
                // Here you can place any code that will alter the output file
                // such as adding security, setting page dimensions, etc.

                // Create the new PDF file
                int result = toolkit.OpenOutputFile(FileName: $"{strPath}Toolkit.SetPDFView.pdf");
                if (result != 0)
                {
                    WriteResult($"Error opening output file: {result.ToString()}", toolkit);
                    return;
                }

                // Open the template PDF
                result = toolkit.OpenInputFile(InputFileName: $"{strPath}Toolkit.Input.pdf");
                if (result != 0)
                {
                    WriteResult($"Error opening input file: {result.ToString()}", toolkit);
                    return;
                }

                // Get the reference to the InitialViewInfo object
                APToolkitNET.InitialViewInfo viewInfo = toolkit.GetInitialViewInfo();

                // Options for viewer window
                viewInfo.CenterWindow = true;
                viewInfo.FullScreen   = false;
                viewInfo.ResizeWindow = true;
                viewInfo.Show         = APToolkitNET.IVShow.IVShow_DocumentTitle;

                // Show or hide UI elements of the viewer
                viewInfo.HideMenuBar        = true;
                viewInfo.HideToolBars       = true;
                viewInfo.HideWindowControls = true;
                viewInfo.NavigationTab      = APToolkitNET.IVNavigationTab.IVNavigationTab_PageOnly;

                // Page settings
                viewInfo.Magnification = APToolkitNET.IVMagnification.IVMagnification_150;
                viewInfo.OpenToPage    = 2;
                viewInfo.PageLayout    = APToolkitNET.IVPageLayout.IVPageLayout_SinglePageContinuous;

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(FirstPage: 0, LastPage: 0);
                if (result != 1)
                {
                    WriteResult($"Error copying file: {result.ToString()}", toolkit);
                    return;
                }

                // Close the new file to complete PDF creation
                toolkit.CloseOutputFile();
            }

            // Process Complete
            WriteResult("Success!");
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Starting with Toolkit version 10 native DLLs are no longer
            // copied to the system folder. The Toolkit constructor must
            // be called with the path to the native DLLs or place them
            // in your applications working directory. This example
            // assumes they are located in the default installation folder.
            // (Use x86 in the path for 32b applications)
            string toolkitPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)}\ActivePDF\Toolkit\bin\x64";

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit(CoreLibPath: toolkitPath))
            {
                // Here you can place any code that will alter the output file
                // such as adding security, setting page dimensions, etc.

                // Create the new PDF file
                int result = toolkit.OpenOutputFile(FileName: $"{strPath}Toolkit.SetPDFView.pdf");
                if (result == 0)
                {
                    // Open the template PDF
                    result = toolkit.OpenInputFile(InputFileName: $"{strPath}Toolkit.Input.pdf");
                    if (result == 0)
                    {
                        // Here you can call any Toolkit functions that will manipulate
                        // the input file such as text and image stamping, form filling, etc.

                        // Get the reference to the InitialViewInfo object
                        APToolkitNET.InitialViewInfo viewInfo = toolkit.GetInitialViewInfo();

                        // Options for viewer window
                        viewInfo.CenterWindow = true;
                        viewInfo.FullScreen   = false;
                        viewInfo.ResizeWindow = true;
                        viewInfo.Show         = APToolkitNET.IVShow.IVShow_DocumentTitle;

                        // Show or hide UI elements of the viewer
                        viewInfo.HideMenuBar        = true;
                        viewInfo.HideToolBars       = true;
                        viewInfo.HideWindowControls = true;
                        viewInfo.NavigationTab      = APToolkitNET.IVNavigationTab.IVNavigationTab_PageOnly;

                        // Page settings
                        viewInfo.Magnification = APToolkitNET.IVMagnification.IVMagnification_150;
                        viewInfo.OpenToPage    = 2;
                        viewInfo.PageLayout    = APToolkitNET.IVPageLayout.IVPageLayout_SinglePageContinuous;

                        // Copy the template (with any changes) to the new file
                        // Start page and end page, 0 = all pages
                        result = toolkit.CopyForm(FirstPage: 0, LastPage: 0);
                        if (result != 1)
                        {
                            WriteResult($"Error copying file: {result.ToString()}", toolkit);
                            return;
                        }

                        // Close the new file to complete PDF creation
                        toolkit.CloseOutputFile();
                    }
                    else
                    {
                        WriteResult($"Error opening input file: {result.ToString()}", toolkit);
                        return;
                    }
                }
                else
                {
                    WriteResult($"Error opening output file: {result.ToString()}", toolkit);
                    return;
                }
            }

            // Process Complete
            WriteResult("Success!");
        }
Exemplo n.º 7
0
    public static void Example()
    {
        string strPath;
        int    intOpenOutputFile;
        int    intOpenInputFile;
        long   longSetDocumentProperty;
        long   longSetCustomProperty;
        long   longSetUserProperty;
        int    intCopyForm;

        strPath = System.AppDomain.CurrentDomain.BaseDirectory;

        // Instantiate Object
        APToolkitNET.Toolkit oTK = new APToolkitNET.Toolkit();

        // Create the new PDF file
        intOpenOutputFile = oTK.OpenOutputFile(strPath + "new.pdf");
        if (intOpenOutputFile != 0)
        {
            ErrorHandler("OpenOutputFile", intOpenOutputFile);
        }

        // Open the template PDF
        intOpenInputFile = oTK.OpenInputFile(strPath + "form.pdf");
        if (intOpenInputFile != 0)
        {
            ErrorHandler("OpenInputFile", intOpenInputFile);
        }

        // Get the reference to the XMP object
        APToolkitNET.XMPManager oXMP = oTK.GetXMPManager();

        // Set a document property
        longSetDocumentProperty = oXMP.SetDocumentProperty(APToolkitNET.XMPProperty.Author, "John Doe");
        if (longSetDocumentProperty != 0)
        {
            ErrorHandler("SetDocumentProperty", longSetDocumentProperty);
        }

        // Set a custom property
        longSetCustomProperty = oXMP.SetCustomProperty("example", "http://examples.activepdf.com");
        if (longSetCustomProperty != 0)
        {
            ErrorHandler("SetCustomProperty", longSetCustomProperty);
        }

        // Set the namespace for the user property
        oXMP.SetNamespace("dc", "http://purl.org/dc/elements/1.1/");

        // Set a user property
        longSetUserProperty = oXMP.SetUserProperty("contributor", "ActivePDF");
        if (longSetUserProperty != 0)
        {
            ErrorHandler("SetUserProperty", longSetUserProperty);
        }

        // Remove a property
        oXMP.RemoveDocumentProperty(APToolkitNET.XMPProperty.Author);

        // Get the reference to the InitialViewInfo object
        APToolkitNET.InitialViewInfo oIVI = oTK.GetInitialViewInfo();

        // Options for viewer window
        oIVI.CenterWindow = true;
        oIVI.FullScreen   = false;
        oIVI.ResizeWindow = true;
        oIVI.Show         = APToolkitNET.IVShow.IVShow_DocumentTitle;

        // Show or hide UI elements of the viewer
        oIVI.HideMenuBar        = true;
        oIVI.HideToolBars       = true;
        oIVI.HideWindowControls = true;
        oIVI.NavigationTab      = APToolkitNET.IVNavigationTab.IVNavigationTab_PageOnly;

        // Page settings
        oIVI.Magnification = APToolkitNET.IVMagnification.IVMagnification_150;
        oIVI.OpenToPage    = 2;
        oIVI.PageLayout    = APToolkitNET.IVPageLayout.IVPageLayout_SinglePageContinuous;

        // Populate and flatten the fields, the data will remain in the place
        // of the field and the field data will be added to the XMP data
        oTK.SetFormFieldData("name", "John Doe", -997);
        oTK.SetFormFieldData("date", "1/1/2000", -997);
        oTK.SetFormFieldData("amount", "15.00", -997);

        // Copy the template (with any changes) to the new file
        intCopyForm = oTK.CopyForm(0, 0);
        if (intCopyForm != 1)
        {
            ErrorHandler("CopyForm", intCopyForm);
        }

        // Close the new file to complete PDF creation
        oTK.CloseOutputFile();

        // Release Object
        oTK.Dispose();

        // Process Complete
        WriteResults("Done!");
    }