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.MergeFiles.pdf"); if (result != 0) { WriteResult($"Error opening output file: {result.ToString()}", toolkit); return; } string[] pdfFiles = System.IO.Directory.GetFiles(strPath, "*.pdf"); result = toolkit.MergeFiles(Files: pdfFiles); if (result != 1) { WriteResult($"MergeFiles failed: {result}", 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; // 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)) { // Any supported image file can be converted to PDF with ImageToPDF int result = toolkit.ImageToPDF( ImageFileName: strPath + "Toolkit.Input.jpg", PDFFileName: strPath + "Toolkit.ImageToPDF.pdf"); if (result != 1) { WriteResult($"Error converting image to PDF: {result.ToString()}", toolkit); } // 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; // 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.MergeMultipleFiles.pdf"); if (result != 0) { WriteResult($"Error opening output file: {result.ToString()}", toolkit); return; } // Set whether the fields should be read only in the output PDF // 0 leave fields as they are, 1 mark all fields as read-only // Fields set with SetFormFieldData will not be effected toolkit.ReadOnlyOnMerge = 1; // MergeFile is the equivalent of OpenInputFile and CopyForm // Merge the cover page (0 for all pages) result = toolkit.MergeFile($"{strPath}Toolkit.Input.pdf", 0, 0); if (result != 1) { WriteResult($"Error merging first file: {result}", toolkit); } // Merge the second PDF result = toolkit.MergeFile($"{strPath}Toolkit.FormsInput.pdf", 0, 0); if (result != 1) { WriteResult($"Error merging second file: {result}", toolkit); } // Merge the third PDF result = toolkit.MergeFile($"{strPath}Toolkit.DBTemplate.pdf", 0, 0); if (result != 1) { WriteResult($"Error merging third file: {result}", toolkit); } // 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; // 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!"); }
protected void btnGeneratePdf_Click(object sender, EventArgs e) { APToolkitNET.Toolkit a = new APToolkitNET.Toolkit(); string imagePath = System.AppDomain.CurrentDomain.BaseDirectory; int outputFile = a.OpenOutputFile(imagePath + "Test.pdf"); a.OutputPageHeight = 792.0f; a.OutputPageWidth = 612.0f; var images = Directory.EnumerateFiles(imagePath + "image", "*.*", SearchOption.AllDirectories) .Where(s => s.EndsWith(".jpg") || s.EndsWith(".png") || s.EndsWith(".gif") || s.EndsWith(".tiff")); int pageNumber = 1; foreach (string image in images) { a.NewPage(); a.PrintImage(image, 200, 400, 200, 200, true, 0); a.SetFont("Helvetica", 16); a.PrintText(500, 50, "Page " + pageNumber.ToString()); a.PrintText(40, 30, "Signature:"); pageNumber++; } a.CloseOutputFile(); a.Dispose(); Response.Redirect("load.aspx", true); }
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!"); }
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!"); }
public ActionResult <Response> Merge([FromBody] Request request) { try { using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit()) { //Set page dimensions toolkit.OutputPageHeight = 792.0f; toolkit.OutputPageWidth = 612.0f; //Create new file int result = toolkit.OpenOutputFile(FileName: $"{ serverDirectory}{request.filename}.pdf"); if (result != 0) { throw new Exception($"Could not create file: {request.filename}"); } string[] files = System.IO.Directory.GetFiles(serverDirectory); foreach (string file in files) { if (file.ToLower().Contains(request.filename.ToLower())) { continue; } if (!System.IO.Path.GetExtension(file).Equals(".pdf")) { continue; } result = toolkit.MergeFile(file, 0, 0); if (result != 1) { throw new Exception($"Could not Merge file: {file}"); } } // Close the new file to complete PDF creation toolkit.CloseOutputFile(); return(new Response() { FileContent = string.Empty, FileName = string.IsNullOrEmpty(request.filename) ? Guid.NewGuid().ToString() + ".pdf" : request.filename + ".pdf", Message = "Files Merged successfully", Success = true }); } } catch (Exception ex) { return(new Response() { FileContent = string.Empty, FileName = "", Message = "Could not Merge files " + ex.Message, Success = false }); } }
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!"); }
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!"); }
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)) { // 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); // 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; // 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!"); }
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!"); }
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!"); }
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!"); }
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.MergeFile.pdf"); if (result == 0) { // Merge the input file result = toolkit.MergeFile( FileName: $"{strPath}Toolkit.Input.pdf", StartPage: 0, EndPage: 0); if (result != 1) { WriteResult($"Error merging first input file: {result.ToString()}", toolkit); } // Merge the input file result = toolkit.MergeFile( FileName: $"{strPath}Toolkit.Input.pdf", StartPage: 0, EndPage: 0); if (result != 1) { WriteResult($"Error merging second input file: {result.ToString()}", toolkit); } // Close the new file to complete PDF creation toolkit.CloseOutputFile(); } else { WriteResult($"Error opening output file: {result.ToString()}", toolkit); return; } } // Process Complete WriteResult("Success!"); }
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($"{strPath}Toolkit.BasicBarcode.pdf"); if (result == 0) { // Add a page to the new PDF for the barcode toolkit.NewPage(); APToolkitNET.BarCode barcode = new APToolkitNET.BarCode(toolkitPath); // Set the encoded value for the barcode. barcode.Value = "*AB-A001-001*"; // Specifies the symbology or barcode format to generate. // Supported Formats: // http://documentation.activepdf.com/Toolkit/Toolkit_API/Content/4_b_barcode_appendix/barcode_format_codes.html barcode.Symbology = 0; // Use PrintImage() to add the barcode to the new PDF toolkit.PrintImage( ImageFileName: barcode.AsString(), X: 72, Y: 576, Width: 360, Height: 144, PersistRatio: true, PageNumber: 0); // Close the new file to complete PDF creation toolkit.CloseOutputFile(); } else { WriteResult($"Error opening output file: {result.ToString()}", toolkit); return; } } // Process Complete WriteResult("Success!"); }
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!"); }
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!"); }
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.MergeMultipleFiles.pdf"); if (result != 0) { WriteResult($"Error opening output file: {result.ToString()}", toolkit); return; } // Set whether the fields should be read only in the output PDF // 0 leave fields as they are, 1 mark all fields as read-only // Fields set with SetFormFieldData will not be effected toolkit.ReadOnlyOnMerge = 1; // MergeFile is the equivalent of OpenInputFile and CopyForm // Merge the cover page (0 for all pages) result = toolkit.MergeFile($"{strPath}Toolkit.Input.pdf", 0, 0); if (result != 1) { WriteResult($"Error merging first file: {result}", toolkit); } // Merge the second PDF result = toolkit.MergeFile($"{strPath}Toolkit.FormsInput.pdf", 0, 0); if (result != 1) { WriteResult($"Error merging second file: {result}", toolkit); } // Merge the third PDF result = toolkit.MergeFile($"{strPath}Toolkit.DBTemplate.pdf", 0, 0); if (result != 1) { WriteResult($"Error merging third file: {result}", toolkit); } // 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; // 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!"); }
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!"); }
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!"); }
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!"); }
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!"); }
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!"); }
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!"); }
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!"); }
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!"); }