1
以下是带有几张图像的生成PDF。我如何强制图像占用PDF文件的整个宽度? alt text http://img52.imageshack.us/img52/3324/fullscreencapture121420u.pngitextsharp:强制图像在vb.net中占用整个宽度
以下是带有几张图像的生成PDF。我如何强制图像占用PDF文件的整个宽度? alt text http://img52.imageshack.us/img52/3324/fullscreencapture121420u.pngitextsharp:强制图像在vb.net中占用整个宽度
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)