logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Bazi  
#1 Posted : Sunday, December 22, 2019 4:08:14 PM(UTC)
Bazi

Rank: Member

Groups: Registered
Joined: 9/19/2019(UTC)
Posts: 21
Germany
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
Paul Rayman  
#2 Posted : Thursday, December 26, 2019 3:11:33 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 855

Thanks: 2 times
Was thanked: 103 time(s) in 101 post(s)
Bazi  
#3 Posted : Saturday, January 4, 2020 12:19:51 PM(UTC)
Bazi

Rank: Member

Groups: Registered
Joined: 9/19/2019(UTC)
Posts: 21
Germany
Location: Landshut

Thanks: 1 times
Yes, i see. From there is my code.
But the result is very bad.
Paul Rayman  
#4 Posted : Sunday, January 5, 2020 5:16:41 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 855

Thanks: 2 times
Was thanked: 103 time(s) in 101 post(s)
PDF is a vector format, so there is usually no problem scaling part of a page. In your case, I guess you have a scanned image (bitmap) in your document, so scaling it leads to a loss of quality.
Users browsing this topic
Similar Topics
Does pdf viewer have the take snapshot functionality as Acrobat? (FAQ)
by Paul Rayman 1/8/2017 11:44:45 AM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.