protected void Button1_Click(object sender, EventArgs e) { SautinSoft.PdfVision v = new SautinSoft.PdfVision(); List <byte[]> imgInventory = new List <byte[]>(); if (FileUpload1.FileBytes.Length > 0) { imgInventory.Add(FileUpload1.FileBytes); } if (FileUpload2.FileBytes.Length > 0) { imgInventory.Add(FileUpload2.FileBytes); } if (FileUpload3.FileBytes.Length > 0) { imgInventory.Add(FileUpload3.FileBytes); } if (FileUpload4.FileBytes.Length > 0) { imgInventory.Add(FileUpload4.FileBytes); } //convert arraylist with image streams to pdf stream byte[] pdfBytes = v.ConvertImageStreamArrayToPDFStream(imgInventory); // show PDF if (pdfBytes != null) { Response.Buffer = true; Response.Clear(); Response.ContentType = "application/PDF"; // Response.AddHeader("content-disposition", "attachment; filename=Result.pdf"); Response.AddHeader("content-disposition", "inline; filename=Result.pdf"); Response.BinaryWrite(pdfBytes); Response.Flush(); Response.End(); } else { Result.Text = "Converting failed!"; } }
static void Main(string[] args) { // Convert images to PDF in memory 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 array containing paths to different images string[] imgFiles = new string[4] { @"..\..\image-jpeg.jpg", @"..\..\image-png.png", @"..\..\image-tiff.tiff", @"..\..\multipage.tiff" }; List <byte[]> imgBytesList = new List <byte[]>(); foreach (string imgFile in imgFiles) { imgBytesList.Add(File.ReadAllBytes(imgFile)); } // Convert the List with image bytes to PDF bytes in memory. byte[] pdfBytes = v.ConvertImageStreamArrayToPDFStream(imgBytesList); if (pdfBytes != null) { // Save the PDF document (pdfBytes) to a file for demonstration purposes. FileInfo outFile = new FileInfo(@"Result.pdf"); File.WriteAllBytes(outFile.FullName, pdfBytes); // Open the resulting PDF document in a default PDF Viewer. System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile.FullName) { UseShellExecute = true }); } }
private void ConvertImagesToPdf() { SautinSoft.PdfVision v = new SautinSoft.PdfVision(); v.PageStyle.PageSize.Auto(); ArrayList arImageBytes = new ArrayList(); foreach (var filePath in m_filesPath) { byte[] imageBytes = null; imageBytes = ReadByteArrayFromFile(filePath); if (imageBytes != null) { arImageBytes.Add(imageBytes); } } string pdfFile = null; //Now the arImageBytes contains byte streams of each image //Lets convert it to PDF stream in memory byte[] pdf = v.ConvertImageStreamArrayToPDFStream(arImageBytes); if (pdf != null) { //Save PDF stream to a file pdfFile = Path.Combine(m_FolderName, "hardcopy.pdf"); File.Delete(pdfFile); FileStream fs = File.OpenWrite(pdfFile); fs.Write(pdf, 0, pdf.Length); fs.Close(); } // Open lesson name form LessonNameForm lessonNameForm = new LessonNameForm(pdfFile, m_userName, m_courseId); this.Hide(); lessonNameForm.ShowDialog(); this.Close(); }
private void ConvertImagesToPdf() { SautinSoft.PdfVision v = new SautinSoft.PdfVision(); v.PageStyle.PageSize.Auto(); ArrayList arImageBytes = new ArrayList(); foreach (var filePath in m_filesPath) { byte[] imageBytes = null; imageBytes = ReadByteArrayFromFile(filePath); if (imageBytes != null) arImageBytes.Add(imageBytes); } string pdfFile = null; //Now the arImageBytes contains byte streams of each image //Lets convert it to PDF stream in memory byte[] pdf = v.ConvertImageStreamArrayToPDFStream(arImageBytes); if (pdf != null) { //Save PDF stream to a file pdfFile = Path.Combine(m_FolderName, "hardcopy.pdf"); File.Delete(pdfFile); FileStream fs = File.OpenWrite(pdfFile); fs.Write(pdf, 0, pdf.Length); fs.Close(); } // Open lesson name form LessonNameForm lessonNameForm = new LessonNameForm(pdfFile, m_userName, m_courseId); this.Hide(); lessonNameForm.ShowDialog(); this.Close(); }