简体   繁体   中英

Unable to resize image inserted into pdf from SQL server ASP.Net via iTextSharp

The code exactly shows how i retrieve my image from the database and insert into the pdf. However my picture isn't sized as the way i wanted it to be. How do i resize them? I tried using ScaleToFit and scaleabsolute but it doesn't work :/

I got the method scale absolute from here

            phrase.Add(new Chunk("Image1 :\u00a0", normalFont));
            Byte[] bytes1 = (Byte[])dr[8];
            iTextSharp.text.Image image1 = iTextSharp.text.Image.GetInstance(bytes1);
            Chunk imageChunk1 = new Chunk(image1, 0, 0);
            image1.ScaleToFit(50f, 50f);
            //image1.ScaleAbsolute(159f, 159f);
            phrase.Add(imageChunk1);

            phrase.Add(new Chunk("Image2 :\u00a0", normalFont));
            Byte[] bytes2 = (Byte[])dr[9];
            iTextSharp.text.Image image2 = iTextSharp.text.Image.GetInstance(bytes2);
            Chunk imageChunk2 = new Chunk(image2, 0, 0);
            image2.ScaleToFit(50f, 50f);
            //image2.ScaleAbsolute(159f, 159f);
            phrase.Add(imageChunk2);

在将其添加到“块”之前,您是否尝试过缩小比例?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM