Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

ImageInfo of multi-page TIFF only applies on the first page

$
0
0
I have this code convert a tiff image to a PDF where the tiff pages are supposed to fill the whole page

public static void Convert(string[] args)
        {
            //Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            pdf1.Conformance = Aspose.Pdf.Generator.PdfConformance.PdfA1A;
            //Add a section into the pdf document
            Aspose.Pdf.Generator.Section sec = pdf1.Sections.Add();
            sec.PageInfo.Margin.Top = 18;
            sec.PageInfo.Margin.Bottom = 18;
            sec.PageInfo.Margin.Inner = 18;
            sec.PageInfo.Margin.Outer = 18;
            sec.PageInfo.Margin.Left = 18;
            sec.PageInfo.Margin.Right = 18;

            byte[] data = new byte[0];
            // Create a FileStream object to read the imag file
            using (FileStream fs = File.OpenRead(args[0]))
            {
                // Read the image into Byte array
                data = new byte[fs.Length];
                fs.Read(data, 0, data.Length);
            }

            // Create a MemoryStream object from image Byte array
            using (MemoryStream ms = new MemoryStream(data))
            {
                //Create an image object in the section 
                Aspose.Pdf.Generator.Image imageht = new Aspose.Pdf.Generator.Image(sec);
                //Set the type of image using ImageFileType enumeration
                imageht.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;
                imageht.ImageInfo.TiffFrame = -1;
                imageht.ImageInfo.Alignment = AlignmentType.Center;
                // Specify the image source as MemoryStream
                imageht.ImageInfo.ImageStream = ms;
                imageht.ImageInfo.IsAllFramesInNewPage = true;
                //Add image object into the Paragraphs collection of the section
                sec.Paragraphs.Add(imageht);
                // specify the image heigh information eqaul to Section height minus Top and Bottom margin of page
                imageht.ImageInfo.FixHeight = sec.PageInfo.PageHeight - sec.PageInfo.Margin.Top - sec.PageInfo.Margin.Bottom;
                // specify the image Width information eqaul to Section Width minus Left and Right margin of page
                imageht.ImageInfo.FixWidth = sec.PageInfo.PageWidth - sec.PageInfo.Margin.Left - sec.PageInfo.Margin.Right;

                //Save the Pdf
                pdf1.Save(args[0] + ".pdf");
                // Close the MemoryStream Object
            }
        }


However, the ImageInfo.FIxHeight, ImageInfo.FixWidth and ImageInfo.Alignement seem to only affect the first TIFF frame. Is this normal? How can modifiy the images on the other pages?

Thanks!

Viewing all articles
Browse latest Browse all 3131

Trending Articles