Converts all images stored in ArrayList to PDF byte array

Namespace:  SautinSoft
Assembly:  SautinSoft.PdfVision (in SautinSoft.PdfVision.dll) Version: 5.1.2.13

Syntax

      
 C#  Visual Basic 
public byte[] ConvertImageStreamArrayToPDFStream(
	List<byte[]> imageBytesList
)
Public Function ConvertImageStreamArrayToPDFStream ( _
	imageBytesList As List(Of Byte()) _
) As Byte()

Parameters

imageBytesList
List<(Of <(array< Byte >[]()[]>)>)
List with image bytes.v.ImageStyle.Quality=100;

Return Value

PDF document as byte array - in case of converting successfully
null - in case of converting failed

Remarks



Examples

CopyASP.Net - Convert different images to PDF in C#
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Collections.Generic;

public partial class _Default : System.Web.UI.Page 
{

    protected void Page_Load(object sender, EventArgs e)
    {
        Result.Text = "";   
    }
    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!";
        }
    }    
}
CopyASP.Net - Convert different images to PDF in VB.Net
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.IO
Imports System.Drawing
Imports System.Collections

Partial Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Result.Text = ""
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim v As New SautinSoft.PdfVision()

        Dim imgInventory As New List(Of Byte())()

        If FileUpload1.FileBytes.Length > 0 Then
            imgInventory.Add(FileUpload1.FileBytes)
        End If

        If FileUpload2.FileBytes.Length > 0 Then
            imgInventory.Add(FileUpload2.FileBytes)
        End If

        If FileUpload3.FileBytes.Length > 0 Then
            imgInventory.Add(FileUpload3.FileBytes)
        End If

        If FileUpload4.FileBytes.Length > 0 Then
            imgInventory.Add(FileUpload4.FileBytes)
        End If

        'convert arraylist with image streams to pdf stream
        Dim pdfBytes() As Byte = v.ConvertImageStreamArrayToPDFStream(imgInventory)


        'show PDF
        If pdfBytes IsNot Nothing Then
            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!"
        End If
    End Sub
End Class

See Also