以下是生成的PDF图片。如何强制图像占据pdf文件的整个宽度? alt text http://img52.imageshack.us/img52/3324/fullscreencapture121420u.png
答案 0 :(得分:4)
ScalePercent方法适用于此。
Dim pgSize As New iTextSharp.text.Rectangle(595, 792) //A4 width, Letter height
Dim leftMargin as integer = 20
Dim rightMargin as integer = 20
Dim doc As New iTextSharp.text.Document(pgSize, leftMargin, rightMargin, 48, 24)
//Create PDF and write other stuff.
Dim img As System.Drawing.Image = My.Resources.My_Image
Dim png As System.Drawing.Imaging.ImageFormat = System.Drawing.Imaging.ImageFormat.Png
Dim pic1 As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(img, png)
Dim scaleFactor As Single = (pgSize.Width - leftMargin - rightMargin) / img.Width * 100
pic1.ScalePercent(scaleFactor)
pic1.SetAbsolutePosition(my_X, my_Y)
doc.Add(pic1)