static void Main(string[] args) { string strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APDocConverter.DocConverter docConverter = new APDocConverter.DocConverter(); // Enable extra logging (logging should only be used while // troubleshooting) C:\ProgramData\activePDF\Logs\ docConverter.Debug = true; // Set the basic metadata in the created PDF docConverter.SetMetadata( "John Doe", "examples, samples, metadata", "Examples", "ActivePDF Metadata Example"); // Convert the file to PDF // If the output parameter is not used the created PDF will use // the input string substituting the filename extension to 'pdf' DCDK.Results.DocConverterResult result = docConverter.ConvertToPDF( $"{strPath}DocConverter.Word.Input.doc", $"{strPath}DocConverter.SetMetadata.Output.pdf"); WriteResult(result); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
static void Main(string[] args) { string strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APDocConverter.DocConverter docConverter = new APDocConverter.DocConverter(); // Enable extra logging (logging should only be used while // troubleshooting) C:\ProgramData\activePDF\Logs\ docConverter.Debug = true; // Compresses eligible objects in the output PDF, which include // page objects and fonts. Streams (including content, text, // images, and data) are not affected. SetPDFCompression is only // supported in PDF versions 1.5 and above. It is enabled by // default. docConverter.SetPDFCompression(true); // Convert the file to PDF // If the output parameter is not used the created PDF will use // the input string substituting the filename extension to 'pdf' DCDK.Results.DocConverterResult result = docConverter.ConvertToPDF( inputPath: $"{strPath}DocConverter.Word.Input.doc", outputPDF: $"{strPath}DocConverter.SetPDFCompression.pdf"); WriteResult(result); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
public static void Example() { string strPath; DCDK.Results.DocConverterResult results; strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APDocConverter.DocConverter oDC = new APDocConverter.DocConverter(); results = oDC.ConvertToPDF(strPath + "word.doc", strPath + "word.pdf"); if (results.DocConverterStatus != DCDK.Results.DocConverterStatus.Success) { ErrorHandler("ConvertToPDF", results, results.DocConverterStatus.ToString()); } results = oDC.ConvertFromPDF(strPath + "word.pdf", strPath + "word.pdf", oDC.FromPDFFormat = APDocConverter.FromPDFFunction.ToWord); if (results.DocConverterStatus != DCDK.Results.DocConverterStatus.Success) { ErrorHandler("ConvertFromPDF", results, results.DocConverterStatus.ToString()); } // Release Object oDC = null; // Process Complete WriteResults("Done!"); }
static void Main(string[] args) { string strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APDocConverter.DocConverter docConverter = new APDocConverter.DocConverter(); // Enable extra logging (logging should only be used while // troubleshooting) C:\ProgramData\activePDF\Logs\ docConverter.Debug = true; // Set the amount of time before a request will time out. // DocConverter also has a TimeoutSpan property that accepts a // TimeSpan object. docConverter.Timeout = 40; // Convert the file to PDF // If the output parameter is not used the created PDF will use // the input string substituting the filename extension to 'pdf' DCDK.Results.DocConverterResult results = docConverter.ConvertToPDF( $"{strPath}DocConverter.Word.Input.doc", $"{strPath}DocConverter.Timeout.Output.pdf"); WriteResult(result); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
static void Main(string[] args) { string strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APDocConverter.DocConverter docConverter = new APDocConverter.DocConverter(); // Enable extra logging (logging should only be used while // troubleshooting) C:\ProgramData\activePDF\Logs\ docConverter.Debug = true; // Start a remote conversion by opening a connection // Specify the IP address of the machine with the DocConverter // installation If 0 is used as the port number DocConverter will // use the default port docConverter.OpenRemoteConnection("#.#.#.#", 62625); // Convert the file to PDF // If the output parameter is not used the created PDF will use // the input string substituting the filename extension to 'pdf' DCDK.Results.DocConverterResult result = docConverter.ConvertToPDF( $"{strPath}DocConverter.Word.Input.doc", $"{strPath}DocConverter.RemoteConversion.pdf"); // Close the remote connection when finished docConverter.CloseRemoteConnection(); WriteResult(result); // Process Complete Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
public static void Example() { string cadXML; string strPath; DCDK.Results.DocConverterResult results; strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APDocConverter.DocConverter oDC = new APDocConverter.DocConverter(); // Settings specific to CAD conversions APDocConverter.CADConverter.CADConverter oCAD = new APDocConverter.CADConverter.CADConverter(); // Options available for CAD conversions // Options that are 'NotSet' use the setting from the configuation manager oCAD.ASCIIHexEncoding = false; oCAD.Color = APDocConverter.CADConverter.ColorMode.NotSet; oCAD.EmbedFonts = APDocConverter.CADConverter.EmbedFontsOptions.NotSet; oCAD.ExportLayers = APDocConverter.CADConverter.LayersOptions.NotSet; oCAD.ExportLayouts = APDocConverter.CADConverter.LayoutsOptions.NotSet; oCAD.FlateCompression = false; oCAD.HatchToBitmapDPI = 150; oCAD.HiddenLineRemoval = false; oCAD.Lineweight = APDocConverter.CADConverter.LineweightOptions.NotSet; oCAD.OtherHatchesSettings = APDocConverter.CADConverter.OtherHatchOptions.NotSet; oCAD.PlotStyleTableName = ""; oCAD.SHXTextAsGeometry = false; oCAD.SimpleGeometryOptimization = false; oCAD.SolidHatchesSettings = APDocConverter.CADConverter.SolidHatchOptions.NotSet; oCAD.TrueTypeAsGeometry = false; oCAD.ZoomToExtents = true; // Page size is only set if ZoomToExtents is true oCAD.SetExtentsPageSize(210, 297); // Convert the settings to XML and send it to DocConverter cadXML = oCAD.Serialize(); oDC.SetAddonOptions(cadXML); // Release Object oCAD = null; // Convert the file to PDF // If the output parameter is not used the created PDF will use // the input string substituting the filename extension to 'pdf' results = oDC.ConvertToPDF(strPath + "sample.dwg", strPath + "new.pdf"); if (results.DocConverterStatus != DCDK.Results.DocConverterStatus.Success) { ErrorHandler("ConvertToPDF", results, results.DocConverterStatus.ToString()); } // Release Object oDC = null; // Process Complete WriteResults("Done!"); }
static void Main(string[] args) { string strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APDocConverter.DocConverter docConverter = new APDocConverter.DocConverter(); // Enable extra logging (logging should only be used while // troubleshooting) C:\ProgramData\activePDF\Logs\ docConverter.Debug = true; // Add stamp text onto the output PDF docConverter.AddStampCollection(collectionName: "TXTinternal"); docConverter.StampFont = "Helvetica"; docConverter.StampFontSize = 108; docConverter.StampFontTransparency = 0.3f; docConverter.StampRotation = 45.0f; docConverter.StampFillMode = ADK.PDF.FontFillMode.FillThenStroke; docConverter.StampColorNET = new ADK.PDF.Color() { Red = 255, Green = 0, Blue = 0, Gray = 0 }; docConverter.StampStrokeColorNET = new ADK.PDF.Color() { Red = 100, Green = 0, Blue = 0, Gray = 0 }; docConverter.AddStampText( x: 116.0f, y: 156.0f, stampText: "Internal Only"); // Set whether the stamp collection(s) appears in the background or // foreground docConverter.StampBackground = 0; // Convert the file to PDF // If the output parameter is not used the created PDF will use // the input string substituting the filename extension to 'pdf' DCDK.Results.DocConverterResult result = docConverter.ConvertToPDF( inputPath: $"{strPath}DocConverter.Word.Input.doc", outputPDF: $"{strPath}DocConverter.AddStampText.pdf"); WriteResult(result); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
static void Main(string[] args) { string strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate DocConverter object APDocConverter.DocConverter docConverter = new APDocConverter.DocConverter(); // Enable extra logging (logging should only be used while // troubleshooting) C:\ProgramData\activePDF\Logs\ docConverter.Debug = true; // Instantiate the CAD settings object APDocConverter.CADConverter.CADConverter cadConverterSettings = new APDocConverter.CADConverter.CADConverter(); // Options available for CAD conversions // Options that are 'NotSet' use the setting from the configuation // manager cadConverterSettings.ASCIIHexEncoding = false; cadConverterSettings.Color = APDocConverter.CADConverter.ColorMode.NotSet; cadConverterSettings.EmbedFonts = APDocConverter.CADConverter.EmbedFontsOptions.NotSet; cadConverterSettings.ExportLayers = APDocConverter.CADConverter.LayersOptions.NotSet; cadConverterSettings.ExportLayouts = APDocConverter.CADConverter.LayoutsOptions.NotSet; cadConverterSettings.FlateCompression = false; cadConverterSettings.HatchToBitmapDPI = 150; cadConverterSettings.HiddenLineRemoval = false; cadConverterSettings.Lineweight = APDocConverter.CADConverter.LineweightOptions.NotSet; cadConverterSettings.OtherHatchesSettings = APDocConverter.CADConverter.OtherHatchOptions.NotSet; cadConverterSettings.PlotStyleTableName = ""; cadConverterSettings.SHXTextAsGeometry = false; cadConverterSettings.SimpleGeometryOptimization = false; cadConverterSettings.SolidHatchesSettings = APDocConverter.CADConverter.SolidHatchOptions.NotSet; cadConverterSettings.TrueTypeAsGeometry = false; cadConverterSettings.ZoomToExtents = true; // Convert the file to PDF // If the output parameter is not used the created PDF will use // the input string substituting the filename extension to 'pdf' DCDK.Results.DocConverterResult result = docConverter.ConvertToPDF( $"{strPath}DocConverter.CAD.Input.dwg", $"{strPath}DocConverter.ConvertCADToPDF.Options.pdf"); WriteResult(result); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
static void Main(string[] args) { string strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APDocConverter.DocConverter docConverter = new APDocConverter.DocConverter(); // Enable extra logging (logging should only be used while // troubleshooting) C:\ProgramData\activePDF\Logs\ docConverter.Debug = true; // Add stamp image onto the output PDF docConverter.AddStampCollection(collectionName: "IMGimage"); docConverter.AddStampImage( ImageFile: $"{strPath}DocConverter.Input.jpg", x: 508.0f, y: 16.0f, Width: 32.0f, Height: 32.0f, PersistRatio: true); // Set whether the stamp collection(s) appears in the background or // foreground docConverter.StampBackground = 0; // Convert the file to PDF // If the output parameter is not used the created PDF will use // the input string substituting the filename extension to 'pdf' DCDK.Results.DocConverterResult result = docConverter.ConvertToPDF( inputPath: $"{strPath}DocConverter.Word.Input.doc", outputPDF: $"{strPath}DocConverter.AddStampImage.pdf"); WriteResult(result); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
static void Main(string[] args) { string strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APDocConverter.DocConverter docConverter = new APDocConverter.DocConverter(); // Enable extra logging (logging should only be used while // troubleshooting) C:\ProgramData\activePDF\Logs\ docConverter.Debug = true; // ActivePDF Service runs under the 'Local System' account, as such // it will only see certificates located in HKEY_LOCAL_MACHINE. To // use certificates located under a specific user set the // impersonate user options in the GUI or API docConverter.InvisiblySignFile( CommonName: "localhost", CertificateStore: "My", UseLocalMachine: true, Location: "Mission Viejo, CA", Reason: "Approval", ContactInfo: "949-555-1212", SignatureType: 1); // Convert the file to PDF // If the output parameter is not used the created PDF will use // the input string substituting the filename extension to 'pdf' DCDK.Results.DocConverterResult result = docConverter.ConvertToPDF( inputPath: $"{strPath}DocConverter.Word.Input.doc", outputPDF: $"{strPath}DocConverter.DigitallySignPDF.pdf"); WriteResult(result); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
static void Main(string[] args) { string strPath = System.AppDomain.CurrentDomain.BaseDirectory; string inputFile = $"{strPath}DocConverter.Word.Input.doc"; byte[] inputFileBytes = System.IO.File.ReadAllBytes(inputFile); using (System.IO.MemoryStream inputStream = new System.IO.MemoryStream(inputFileBytes, 0, inputFileBytes.Length)) { System.IO.MemoryStream outputStream = new System.IO.MemoryStream(); // Instantiate Object APDocConverter.DocConverter docConverter = new APDocConverter.DocConverter(); // Enable extra logging (logging should only be used while // troubleshooting) C:\ProgramData\activePDF\Logs\ docConverter.Debug = true; // Convert the file to a PDF MemoryStream DCDK.Results.DocConverterResult result = docConverter.ConvertToPDF( inputMemoryStream: inputStream, APDocConverter.ToPDFFunction.FromDOC, out outputStream); // Save the output to a local file. byte[] outputFile = outputStream.ToArray(); outputStream.Close(); System.IO.File.WriteAllBytes($"{strPath}output.pdf", outputFile); WriteResult(result); } Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
static void Main(string[] args) { string strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APDocConverter.DocConverter docConverter = new APDocConverter.DocConverter(); // Enable extra logging (logging should only be used while // troubleshooting) C:\ProgramData\activePDF\Logs\ docConverter.Debug = true; // Set 40-bit encryption on PDF output // 40-bit encryption supported in Acrobat 3+ // A blank user password will allow the PDF to open without a // password. // (DocConverter also supports 128-bit and AES 128/256-bit // encryption.) docConverter.SetPDFSecurity( "userpass", "ownerpass", true, true, true, true); // Convert the file to PDF // If the output parameter is not used the created PDF will use // the input string substituting the filename extension to 'pdf' DCDK.Results.DocConverterResult result = docConverter.ConvertToPDF( $"{strPath}DocConverter.Word.Input.doc", $"{strPath}DocConverter.SetPDFSecurity.Output.pdf"); WriteResult(result); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }