// Instantiate Document Object
Document doc = new Document();
foreach (var fileData in FileData)
{
// Load the source image file to Stream object
using (FileStream fs = new FileStream(fileData.LocalFileName, FileMode.Open, FileAccess.Read))
{
byte[] tmpBytes = new byte[fs.Length];
fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length));
MemoryStream mystream = new MemoryStream(tmpBytes);
// Instantiate BitMap object with loaded image stream
Bitmap b = new Bitmap(mystream);
// Add a page to pages collection of document
Page page = doc.Pages.Add();
//Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo();
//margin.Top = 0;
//margin.Bottom = 0;
//margin.Left = 0;
//margin.Right = 0;
//page.PageInfo.Margin = margin;
//page.CropBox = new Aspose.Pdf.Rectangle(0, 0, b.Width, b.Height);
// Create an image object
Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();
// Add the image into paragraphs collection of the section
page.Paragraphs.Add(image1);
// Set the image file stream
image1.ImageStream = mystream;
// Close memoryStream object
//mystream.Close();
}
}
// Save resultant PDF file
doc.Save(@saveTo);
}