Rank: Member
Groups: Registered
Joined: 9/19/2019(UTC) Posts: 21  Location: Landshut Thanks: 1 times
|
Hi there, I am trying to create an image section from a PDF. This is my code used on VB.Net: Code:Friend Function TakeShapshot(ByVal Page As Patagames.Pdf.Net.PdfPage, ByVal Rect As RectangleF) As Image
Dim leftTop As PointF = Rect.Location
Dim rightBottom As PointF = New PointF(Rect.Location.X + Rect.Width, Rect.Top - Rect.Height)
Dim k As Double = width / (rightBottom.X - leftTop.X)
Dim height As Integer = CInt(((leftTop.Y - rightBottom.Y) * k))
Using bmp = New Patagames.Pdf.Net.PdfBitmap(width, height, True)
bmp.FillRect(0, 0, bmp.Width, bmp.Height, Patagames.Pdf.FS_COLOR.White)
Dim devX, devY As Integer
Page.PageToDevice(0, 0, CInt((Page.Width * k)), CInt((Page.Height * k)), Patagames.Pdf.Enums.PageRotate.Normal, leftTop.X, leftTop.Y, devX, devY)
Page.Render(bmp, -devX, -devY, CInt((Page.Width * k)), CInt((Page.Height * k)), Patagames.Pdf.Enums.PageRotate.Normal, Patagames.Pdf.Enums.RenderFlags.FPDF_LCD_TEXT)
Return New Bitmap(bmp.Image)
End Using
End Function
However, the result is disappointing, the image quality is very poor. What can I optimize for a better result? Best regards Christian
|