static void Main(string[] args) { // Console - Convert HTML file to one-page PDF file. SautinSoft.PdfVision v = new SautinSoft.PdfVision(); // Set "Edge mode" to support all modern CSS. SautinSoft.PdfVision.TrySetBrowserModeEdgeInRegistry(); v.PageStyle.PageOrientation.Portrait(); string inpFile = @"https://nationalzoo.si.edu"; FileInfo outFile = new FileInfo("Result.pdf"); byte[] image = v.ConvertHtmlFileToImageStream(inpFile, SautinSoft.PdfVision.eImageFormat.Png); int ret = -1; if (image != null) { v.PageStyle.PageSize.Auto(); ret = v.ConvertImageStreamToPDFFile(image, outFile.FullName); } // 0 - converting successfully // 1 - can't open input file, check the input path // 2 - can't create output file, check the output path // 3 - converting failed if (ret == 0) { // Open the resulting PDF document in a default PDF Viewer. System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile.FullName) { UseShellExecute = true }); } }
static void Main(string[] args) { // Convert Image class to PDF file SautinSoft.PdfVision v = new SautinSoft.PdfVision(); //v.Serial = "XXXXXXXXXXXXXXX"; //specify converting options v.PageStyle.PageSize.Auto(); //v.PageStyle.PageMarginLeft.Inch(1); //v.ImageStyle.Heightmm(150); //v.ImageStyle.WidthInch(10); // Create object of Image class from file System.Drawing.Image image = Image.FromFile(@"..\..\image-jpeg.jpg"); FileInfo outFile = new FileInfo(@"Result.pdf"); byte[] imgBytes = null; using (MemoryStream ms = new System.IO.MemoryStream()) { image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); imgBytes = ms.ToArray(); } // Convert image stream to PDF file int ret = v.ConvertImageStreamToPDFFile(imgBytes, outFile.FullName); if (ret == 0) { // Open the resulting PDF document in a default PDF Viewer. System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile.FullName) { UseShellExecute = true }); } }