I have a new problem. I am converting multi-page TIFF images to PDFs. The first page comes out really tiny, but the rest of the pages are fine. I’ve tried several TIFF images and get the same results. Hoping you can tell me what I need to do to get the size correct on the first page.
Here’s the conversion code I’m using:
Blockquote
public Document ConvertTiffToPdf(byte[] byteStream, string url)
{
//Instantiate a Pdf object by calling its empty constructor
Document pdf1 = new Document();
// Add a page to pages collection of document
Page page = pdf1.Pages.Add();
MemoryStream mystream = new MemoryStream(byteStream);
// Instantiate BitMap object with loaded image stream
Bitmap b = new Bitmap(mystream);
// Set margins so image will fit, etc.
page.PageInfo.Margin.Bottom = 0;
page.PageInfo.Margin.Top = 0;
page.PageInfo.Margin.Left = 0;
page.PageInfo.Margin.Right = 0;
page.CropBox = new Aspose.Pdf.Rectangle(0, 0, b.Width, b.Height);
// Create an image object
Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();
//Set the type of image using ImageFileType enumeration
//image1.FileType = ImageFileType.;
// Add the image into paragraphs collection of the section
page.Paragraphs.Add(image1);
// Set the image file stream
image1.ImageStream = mystream;
if (url != null && url.Contains("/"))
{
var strings = url.Split('/');
var baseFileName = strings[strings.Length - 1].Split('.')[0];
string fileName = String.Format("c:\\temp\\{0}.pdf", baseFileName);
//Save the Pdf
pdf1.Save(fileName);
}
// Close the MemoryStream Object
//ms.Close();
return pdf1;
}