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 Ultimate\bin\x64";

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit(toolkitPath))
            {
                int result = toolkit.OpenOutputFile(FileName: $"{strPath}Toolkit.RedactAllImages.pdf");
                if (result == 0)
                {
                    // Get the Redactor object from Toolkit
                    APToolkitNET.Redactor redactor = toolkit.GetRedactor();

                    // Open the input PDF
                    result = toolkit.OpenInputFile(InputFileName: $"{strPath}Toolkit.Input.pdf");
                    if (result == 0)
                    {
                        // Redact all images from the input file.
                        redactor.RedactAll(mode: APToolkitNET.Redactor.RedactionMode.AllImages);

                        // Call the Redactor Apply method to execute the
                        // redaction process. All Toolkit methods normally
                        // called between OpenInputFile and CopyForm
                        // (PrintText, PrintImage etc.) must be after
                        // Redactor.Apply
                        redactor.Apply();

                        result = toolkit.CopyForm(FirstPage: 0, LastPage: 0);
                        if (result != 1)
                        {
                            WriteResult("CopyForm Failed", toolkit);
                        }

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

            // Process Complete
            WriteResult("Success!");
        }
예제 #2
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 in memory
                int result = toolkit.OpenOutputFile(FileName: "MEMORY");
                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.

                        // 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();

                        // To save a PDF in memory to a file directly call SaveMemoryToDisk
                        toolkit.SaveMemoryToDisk(FileName: $"{strPath}Toolkit.InMemory.pdf");
                    }
                    else
                    {
                        WriteResult($"Error opening input file: {result.ToString()}", toolkit);
                        return;
                    }
                }
                else
                {
                    WriteResult($"Error opening output file: {result.ToString()}", toolkit);
                    return;
                }
            }

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

            // Simulate the intput byte array by opening a file into memory.
            byte[] inputPDF = File.ReadAllBytes($"{strPath}Toolkit.Input.pdf");

            // 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))
            {
                // Create the new PDF file in memory
                int result = toolkit.OpenOutputFile("MEMORY");
                if (result != 0)
                {
                    WriteResult($"Error opening output file: {result.ToString()}", toolkit);
                    return;
                }

                // Set the input byte array
                toolkit.InputByteArray = inputPDF;

                // Open the input byte array
                result = toolkit.OpenInputFile("MEMORY");
                if (result != 0)
                {
                    WriteResult($"Error opening input file: {result.ToString()}", toolkit);
                    return;
                }

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

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

                // Here is the output byte stream.
                string outputPDF = toolkit.OutputByteStream;

                // Or save the output to disk
                toolkit.SaveMemoryToDisk($"{strPath}Toolkit.AllInMemory.pdf");
            }

            // Process Complete
            WriteResult("Success!");
        }
예제 #4
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))
            {
                // Instantiate the Compressor object
                APToolkitNET.Compressor compressor = toolkit.GetCompressor();

                // Change the resolution of images to 72 dpi.
                compressor.DownsampleImages = true;

                // Images of DPI greater or equal to the TriggerDPI will be
                // downsampled to the TargetDPI
                compressor.TargetDPI  = 72.0f;
                compressor.TriggerDPI = 150.0f;

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

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

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(0, 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!");
        }
예제 #5
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.

                // Add AES 256 bit encryption to the output PDF. Toolkit also
                // supports RC4 40 bit, RC4 128 bit and AES 128 bit.
                // 'DEMO' is appended to the start of the password with the evaluation version
                toolkit.SetPDFSecurity(5, "UserPassword", "OwnerPassword", true, false, true, false, true, false, true, false);

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

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

                // Here you can call any Toolkit functions that will manipulate
                // the input file such as text and image stamping, form filling, etc.

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(0, 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!");
        }
예제 #6
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit())
            {
                // Set the PDF page Height and Width (72 = 1")
                toolkit.OutputPageHeight = 792.0f;
                toolkit.OutputPageWidth  = 612.0f;

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

                // Each time a new page is required call NewPage
                toolkit.NewPage();

                // Get the current version of Toolkit and save it to print on
                // the PDF
                string toolkitVersion = toolkit.ToolkitVersion;

                // Text can be added onto the new page with
                // SetFont, PrintText and PrintMultilineText functions
                toolkit.SetFont(FontName: "Helvetica", FontSize: 24);
                toolkit.PrintText(X: 72.0f, Y: 720.0f, Text: toolkitVersion);

                // Images can be added onto the new page with PrintImage,
                // PrintJPEG and PrintTIFF
                toolkit.PrintJPEG(
                    FileName: strPath + "Toolkit.Input.jpg",
                    X: 72.0f,
                    Y: 300.0f,
                    Width: 468.0f,
                    Height: 400.0f,
                    PersistRatio: true,
                    PageNumber: 0);

                // 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!");
        }
예제 #7
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))
            {
                // Get the Toolkit Bookmark Manager
                APToolkitNET.BookmarkManager bookmarkManager = toolkit.GetBookmarkManager();

                // Set CopyBookmarks to true to create bookmarks in the output PDF.
                bookmarkManager.CopyBookmarks = true;

                // Create the new PDF file
                int result = toolkit.OpenOutputFile($"{strPath}Toolkit.CopyBookmarks.pdf");
                if (result == 0)
                {
                    // Open the template PDF
                    result = toolkit.OpenInputFile($"{strPath}Toolkit.Input.pdf");
                    if (result == 0)
                    {
                        // Copy the template (with any changes) to the new file
                        // Start page and end page, 0 = all pages
                        result = toolkit.CopyForm(0, 0);
                        if (result != 1)
                        {
                            WriteResult($"Error copying file: {result.ToString()}", toolkit);
                            return;
                        }
                    }
                    else
                    {
                        WriteResult($"Error opening input file: {result.ToString()}", toolkit);
                        return;
                    }

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

            // Process Complete
            WriteResult("Success!");
        }
예제 #8
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.DrawLines.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;
                }

                // Draw lines making a border around the content
                toolkit.LineWidth(Width: 1.0f, PageNumber: -1);

                toolkit.MoveTo(X: 62.0f, Y: 62.0f, PageNumber: -1);
                toolkit.DrawTo(X: 62.0f, Y: 730.0f, PageNumber: -1);

                toolkit.MoveTo(X: 62.0f, Y: 730.0f, PageNumber: -1);
                toolkit.DrawTo(X: 550.0f, Y: 730.0f, PageNumber: -1);

                toolkit.MoveTo(X: 550.0f, Y: 730.0f, PageNumber: -1);
                toolkit.DrawTo(X: 550.0f, Y: 62.0f, PageNumber: -1);

                toolkit.MoveTo(X: 550.0f, Y: 62.0f, PageNumber: -1);
                toolkit.DrawTo(X: 62.0f, Y: 62.0f, PageNumber: -1);

                // 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!");
        }
예제 #9
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 Ultimate\bin\x64";

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit(toolkitPath))
            {
                // Get the Redactor object from Toolkit
                APToolkitNET.Redactor redactor = toolkit.GetRedactor();

                int result = toolkit.OpenOutputFile(FileName: $"{strPath}Toolkit.RedactRegExPreset.pdf");
                if (result == 0)
                {
                    // Open the input PDF
                    result = toolkit.OpenInputFile(InputFileName: $"{strPath}Toolkit.Input.pdf");
                    if (result == 0)
                    {
                        // Redactor has several pre generated regular
                        // expressions for text redaction. (date, email,
                        // numbers, phone number, SSN, USD, websites, words)
                        // You may also redact individual pages setting the
                        // page function argument, the default is all pages.
                        redactor.RedactRegexPreset(regexpreset: APToolkitNET.RegexPresets.Preset.RegexPhoneNumber);

                        result = toolkit.CopyForm(FirstPage: 0, LastPage: 0);
                        if (result != 1)
                        {
                            WriteResult("CopyForm Failed", toolkit);
                        }

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

            // Process Complete
            WriteResult("Success!");
        }
예제 #10
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!");
        }
예제 #11
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.PageLabels.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;
                }

                // Create a cover page
                string strText = "ActivePDF Toolkit";
                toolkit.NewPage();
                toolkit.SetFont(FontName: "Helvetica", FontSize: 72);
                float textWidth  = toolkit.GetTextWidth(TextString: strText);
                float textHeight = toolkit.GetTextHeight(TextString: strText);
                toolkit.PrintText(X: (612 - textWidth) / 2, Y: (792 - textHeight) / 2, Text: strText);

                // Add a page label to the cover page
                toolkit.SetOutputPageLabels(StartPage: 1, EndPage: 1, Style: APToolkitNET.PageLabelStyle.None, Prefix: "Cover", StartValue: 1);

                // Add numbered page labels to remaining pages
                toolkit.SetOutputPageLabels(StartPage: 2, EndPage: 3, Style: APToolkitNET.PageLabelStyle.RomanUpper, Prefix: "", StartValue: 1);

                // 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!");
        }
예제 #12
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))
            {
                // Create the new PDF file
                int result = toolkit.OpenOutputFile(FileName: $"{strPath}Toolkit.TextStamp.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;
                }

                // Add a 'confidential' watermark
                string stampText = "Confidential";
                toolkit.SetFont("Helvetica", 72, -1);
                toolkit.SetTextColor(168, 0, 0, 0, -1);
                toolkit.PrintText((612 - toolkit.GetTextWidth(stampText)) / 2, (792 - toolkit.GetTextHeight(stampText)) / 2, stampText, -1);
                toolkit.ResetTextColor(-1);

                // 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!");
        }
예제 #13
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit())
            {
                // Instantiate the Compressor object
                APToolkitNET.Compressor compressor = toolkit.GetCompressor();

                // Compresses images in the output PDF.
                compressor.CompressImages = true;

                // Compress images to a particular quality, used only with
                // lossy image compression. Ranges from 1 to 100 indicate
                // the result image quality. A lower value creates an image of
                // lower PPI and smaller file size, while a greater value
                // creates images of better quality but larger file size. The
                // default is 20.
                compressor.CompressionQuality = 75;

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

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

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(0, 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!");
        }
예제 #14
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Simulate the intput byte array by opening a file into memory.
            byte[] inputPDF = File.ReadAllBytes($"{strPath}Toolkit.Input.pdf");

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit())
            {
                // Create the new PDF file in memory
                int result = toolkit.OpenOutputFile("MEMORY");
                if (result != 0)
                {
                    WriteResult($"Error opening output file: {result.ToString()}", toolkit);
                    return;
                }

                // Set the input byte array
                toolkit.InputByteArray = inputPDF;

                // Open the input byte array
                result = toolkit.OpenInputFile("MEMORY");
                if (result != 0)
                {
                    WriteResult($"Error opening input file: {result.ToString()}", toolkit);
                    return;
                }

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

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

                // Here is the output byte stream.
                string outputPDF = toolkit.OutputByteStream;

                // Or save the output to disk
                toolkit.SaveMemoryToDisk($"{strPath}Toolkit.AllInMemory.pdf");
            }

            // Process Complete
            WriteResult("Success!");
        }
예제 #15
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.

                // Add AES 256 bit encryption to the output PDF. Toolkit also
                // supports RC4 40 bit, RC4 128 bit and AES 128 bit.
                // 'DEMO' is appended to the start of the password with the evaluation version
                toolkit.SetPDFSecurity(5, "UserPassword", "OwnerPassword", true, false, true, false, true, false, true, false);

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

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

                // Here you can call any Toolkit functions that will manipulate
                // the input file such as text and image stamping, form filling, etc.

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(0, 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!");
        }
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit())
            {
                // Instantiate the Compressor object
                APToolkitNET.Compressor compressor = toolkit.GetCompressor();

                // Change the resolution of images to 72 dpi.
                compressor.DownsampleImages = true;

                // Images of DPI greater or equal to the TriggerDPI will be
                // downsampled to the TargetDPI
                compressor.TargetDPI  = 72.0f;
                compressor.TriggerDPI = 150.0f;

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

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

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(0, 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!");
        }
예제 #17
0
    public static void Example()
    {
        string strPath;
        int    intOpenOutputFile;
        int    intOpenInputFile;
        int    intCopyForm;

        strPath = System.AppDomain.CurrentDomain.BaseDirectory;

        // Instantiate Object
        APToolkitNET.Toolkit oTK = 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
        intOpenOutputFile = oTK.OpenOutputFile(strPath + "new.pdf");
        if (intOpenOutputFile != 0)
        {
            ErrorHandler("OpenOutputFile", intOpenOutputFile);
        }

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

        // Here you can call any Toolkit functions that will manipulate
        // the input file such as text and image stamping, form filling, etc.

        // Copy the template (with any changes) to the new file
        // Start page and end page, 0 = all pages
        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!");
    }
예제 #18
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!");
        }
예제 #19
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($"{strPath}Toolkit.SetInfo.pdf");
                if (result != 0)
                {
                    WriteResult($"Error opening output file: {result.ToString()}", toolkit);
                    return;
                }

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

                // Here you can call any Toolkit functions that will manipulate
                // the input file such as text and image stamping, form filling, etc.

                // Set the PDF metadata for the output PDF
                toolkit.SetInfo("Test PDF", "Testing", "John Doe", "test, pdf, sample");

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(0, 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!");
        }
예제 #20
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.HeaderLines.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;
                }

                // Add some lines to the footer and top right corner of the page
                toolkit.SetHeaderGreyBar(X: 72, Y: 52, Width: 468, Height: 1, GreyLevel: 0.8f);
                toolkit.SetHeaderHLine(X1: 340, X2: 544, Y: 724, Width: 1);
                toolkit.SetHeaderVLine(Y1: 724, Y2: 648, X: 544, Width: 1);

                // 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!");
        }
예제 #21
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.HeaderImages.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;
                }

                // Use the Header Image properties to add some images to the footer
                toolkit.SetHeaderImage(ImageFileName: $"{strPath}Toolkit.Input.bmp", X: 375.0f, Y: 53.0f, Width: 0.0f, Height: 0.0f, PersistRatio: true);
                toolkit.SetHeaderJPEG(FileName: $"{strPath}Toolkit.Input.jpg", X: 436.0f, Y: 49.0f, Width: 0.0f, Height: 0.0f, PersistRatio: true);
                toolkit.SetHeaderTIFF(FileName: $"{strPath}Toolkit.Input.tif", X: 500.0f, Y: 55.0f, Width: 0.0f, Height: 0.0f, PersistRatio: true);

                // 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!");
        }
예제 #22
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit())
            {
                // Instantiate the Compressor object
                APToolkitNET.Compressor compressor = toolkit.GetCompressor();

                // Compresses eligible objects in the output PDF, which include
                // page objects and fonts. Streams (including content, text,
                // images, and data) are not affected.
                compressor.CompressObjects = true;

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

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

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(0, 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!");
        }
예제 #23
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit())
            {
                // Create the new PDF file
                int result = toolkit.OpenOutputFile(FileName: $"{strPath}Toolkit.TextStamp.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;
                }

                // Add a 'confidential' watermark
                string stampText = "Confidential";
                toolkit.SetFont("Helvetica", 72, -1);
                toolkit.SetTextColor(168, 0, 0, 0, -1);
                toolkit.PrintText((612 - toolkit.GetTextWidth(stampText)) / 2, (792 - toolkit.GetTextHeight(stampText)) / 2, stampText, -1);
                toolkit.ResetTextColor(-1);

                // 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!");
        }
        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.XMLSetFormFieldData.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;
                }

                // Populate form fields from the xml file. The field for the input sample is
                // located on page two.
                toolkit.XMLSetFormFieldData($"{strPath}Toolkit.FieldInput.xml", 0, 1, String.Empty);

                // 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!");
        }
예제 #25
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit())
            {
                // Instantiate the Compressor object
                APToolkitNET.Compressor compressor = toolkit.GetCompressor();

                // Remove comments from the output PDF.
                compressor.DiscardComments = true;

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

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

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(0, 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!");
        }
예제 #26
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 in memory
                int result = toolkit.OpenOutputFile(FileName: "MEMORY");
                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;
                }

                // 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();

                // To save a PDF in memory to a file directly call SaveMemoryToDisk
                toolkit.SaveMemoryToDisk(FileName: $"{strPath}Toolkit.InMemory.pdf");
            }

            // Process Complete
            WriteResult("Success!");
        }
예제 #27
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.PageLabels.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;
                }

                // Create a cover page
                string strText = "ActivePDF Toolkit";
                toolkit.NewPage();
                toolkit.SetFont(FontName: "Helvetica", FontSize: 72);
                float textWidth  = toolkit.GetTextWidth(TextString: strText);
                float textHeight = toolkit.GetTextHeight(TextString: strText);
                toolkit.PrintText(X: (612 - textWidth) / 2, Y: (792 - textHeight) / 2, Text: strText);

                // Add a page label to the cover page
                toolkit.SetOutputPageLabels(StartPage: 1, EndPage: 1, Style: APToolkitNET.PageLabelStyle.None, Prefix: "Cover", StartValue: 1);

                // Add numbered page labels to remaining pages
                toolkit.SetOutputPageLabels(StartPage: 2, EndPage: 3, Style: APToolkitNET.PageLabelStyle.RomanUpper, Prefix: "", StartValue: 1);

                // 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!");
        }
예제 #28
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit())
            {
                // Instantiate the Compressor object
                APToolkitNET.Compressor compressor = toolkit.GetCompressor();

                // Compresses images in the output PDF.
                compressor.CompressImages = true;

                // Compresses eligible objects in the output PDF, which include
                // page objects and fonts. Streams (including content, text,
                // images, and data) are not affected.
                compressor.CompressObjects = true;

                // Compress images to a particular quality, used only with
                // lossy image compression. Ranges from 1 to 100 indicate
                // the result image quality. A lower value creates an image of
                // lower PPI and smaller file size, while a greater value
                // creates images of better quality but larger file size. The
                // default is 20.
                compressor.CompressionQuality = 20;

                // Remove all embedded files.
                compressor.DiscardAttachments = true;

                // Remove comments from the output PDF.
                compressor.DiscardComments = true;

                // Remove form fields from the output PDF.
                compressor.DiscardFormFields = true;

                // Remove metadata from the output PDF.
                compressor.DiscardMetadata = true;

                // Remove markup and reflow data from the resulting PDF.
                compressor.DiscardDocumentTags = true;

                // Change the resolution of images to 72 dpi.
                compressor.DownsampleImages = true;

                // Compress uncompressed PDF streams.
                compressor.EncodeStreams = true;

                // Subset fonts.
                compressor.SubsetFonts = true;

                // Images of DPI greater or equal to the TriggerDPI will be
                // downsampled to the TargetDPI
                compressor.TargetDPI  = 150.0f;
                compressor.TriggerDPI = 300.0f;

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

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

                // Copy the template (with any changes) to the new file
                // Start page and end page, 0 = all pages
                result = toolkit.CopyForm(0, 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!");
        }
예제 #29
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!");
        }
예제 #30
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))
            {
                // Instantiate the Compressor object
                APToolkitNET.Compressor compressor = toolkit.GetCompressor();

                // Compresses eligible objects in the output PDF, which include
                // page objects and fonts. Streams (including content, text,
                // images, and data) are not affected.
                compressor.CompressObjects = true;

                // 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.CompressObjects.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.

                        // Copy the template (with any changes) to the new file
                        // Start page and end page, 0 = all pages
                        result = toolkit.CopyForm(0, 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!");
        }