Maintain similar image size in PDF using itextsharp

后端 未结 1 1442
甜味超标
甜味超标 2021-01-24 01:25

i\'m using itextsharp to bring my picture over to the pdf file. I uses chunk. However when i uses the chunk new line, my image changes it size despite me putting the same scale

1条回答
  •  醉梦人生
    2021-01-24 01:44

    I completely forgot about this question, but I'll answer it now for further reference. iTextSharp resizes images automatically (which is what you'd want in most cases), but you can avoid this by setting ScaleToFitHeight = false to each image.

    phrase2.Add(new Chunk("1.", normalFont));
    Byte[] bytes1 = (Byte[])dr[10];
    iTextSharp.text.Image image1 = iTextSharp.text.Image.GetInstance(bytes1);
    image1.ScaleToFit(750f, 750f);
    //set scale to fit height = false
    image1.ScaleToFitHeight = false;
    Chunk imageChunk1 = new Chunk(image1, 0, -30);
    phrase2.Add(imageChunk1);
    

    0 讨论(0)
提交回复
热议问题