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

Notification

Icon
Error

Options
Go to last post Go to first unread
BBuech  
#1 Posted : Wednesday, June 23, 2021 4:52:46 AM(UTC)
BBuech

Rank: Newbie

Groups: Registered
Joined: 9/19/2018(UTC)
Posts: 4
Germany

Thanks: 1 times
Hello,

we're using your Patagames.PDF SDK for years.

We have a problem with an PDFDocument,

where certain area's doesn't appear on the image,

but they apprear in your PDFViewer or e.g. Adobe Reader.

I attached a simplfied sample named "5006_Selection.pdf" 5006_Selection.tiff (10kb) downloaded 3 time(s). Adobe.png (232kb) downloaded 1 time(s). 5006_Selection.pdf (338kb) downloaded 1 time(s). 5006_Selection.pdf (338kb) downloaded 1 time(s)..

In the secound attachment, you see rendered PDF in Adobe.
Adobe.png (232kb) downloaded 1 time(s).

The third attachment is the generated PDF for your newest SDK,
5006_Selection.tiff (10kb) downloaded 3 time(s).

Version 8.58.31.45.

Can you provide a solution, that the generated Image shows all

parts from the PDF?


I copied the generation Code for your forum and translated it to VB.net.

Code:

 Private Sub PDF2Tiff(ByVal qPfad As String, ByVal zpfad As String)
        Dim tiff As Image = Nothing

        Using doc = Patagames.Pdf.Net.PdfDocument.Load(qPfad)
            Dim dpi As Integer = 96
            Dim i As Integer = 1

            For Each page In doc.Pages
                Dim width As Integer = CInt((page.Width / 72.0 * dpi))
                Dim height As Integer = CInt((page.Height / 72.0 * dpi))

                Using bitmap = New Patagames.Pdf.Net.PdfBitmap(width, height, True)
                    bitmap.FillRect(0, 0, width, height, Patagames.Pdf.FS_COLOR.White)
                    page.Render(bitmap, 0, 0, width, height, Patagames.Pdf.Enums.PageRotate.Normal, Patagames.Pdf.Enums.RenderFlags.FPDF_LCD_TEXT)

                    If tiff Is Nothing Then
                        tiff = CreateTiffFromBitmap(bitmap.Image, zpfad)
                    Else
                        AddFrameToTiff(tiff, bitmap.Image)
                    End If
                End Using

                page.Dispose()
                Console.WriteLine(String.Format("Process page {0}", Math.Min(System.Threading.Interlocked.Increment(i), i - 1)))
            Next

            If tiff IsNot Nothing Then FlushTiff(tiff)
        End Using
    End Sub

    Public Function CreateTiffFromBitmap(ByVal bitmap As Image, ByVal pathToTiff As String) As Image
        Using byteStream As MemoryStream = New MemoryStream()
            bitmap.Save(byteStream, ImageFormat.Tiff)
            Dim tiff As Image = Image.FromStream(byteStream)
            Dim encoderInfo As ImageCodecInfo = ImageCodecInfo.GetImageEncoders().First(Function(i) i.MimeType = "image/tiff")
            Dim encoderParams As EncoderParameters = New EncoderParameters(2)
            Dim parameter As EncoderParameter = New EncoderParameter(Encoder.Compression, CLng(EncoderValue.CompressionLZW))
            encoderParams.Param(0) = parameter
            parameter = New EncoderParameter(Encoder.SaveFlag, CLng(EncoderValue.MultiFrame))
            encoderParams.Param(1) = parameter
            Dim ret = New MemoryStream()
            tiff.Save(pathToTiff, encoderInfo, encoderParams)
            Return tiff
        End Using
    End Function

    Public Sub AddFrameToTiff(ByVal tiff As Image, ByVal bitmap As Image)
        Dim EncoderParams As EncoderParameters = New EncoderParameters(3)
        Dim SaveEncodeParam As EncoderParameter = New EncoderParameter(Encoder.SaveFlag, CLng(EncoderValue.FrameDimensionPage))
        Dim CompressionEncodeParam As EncoderParameter = New EncoderParameter(Encoder.Compression, CLng(EncoderValue.CompressionLZW))
        Dim QualityEncodeParam As EncoderParameter = New EncoderParameter(Encoder.Quality, 100L)
        EncoderParams.Param(0) = CompressionEncodeParam
        EncoderParams.Param(1) = SaveEncodeParam
        EncoderParams.Param(2) = QualityEncodeParam
        tiff.SaveAdd(bitmap, EncoderParams)
    End Sub

    Public Sub FlushTiff(ByVal tiff As Image)
        Dim SaveEncodeParam As EncoderParameter = New EncoderParameter(Encoder.SaveFlag, CLng(EncoderValue.Flush))
        Dim EncoderParams = New EncoderParameters(1)
        EncoderParams.Param(0) = SaveEncodeParam
        tiff.SaveAdd(EncoderParams)
    End Sub


Regards, Barnabas Bücher

Paul Rayman  
#2 Posted : Wednesday, June 23, 2021 5:43:20 AM(UTC)
Paul Rayman

Rank: Administration

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

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Tty render with FPDF_ANNOT flag
Code:
page.Render(bitmap, 0, 0, width, height, Patagames.Pdf.Enums.PageRotate.Normal, Patagames.Pdf.Enums.RenderFlags.FPDF_ANNOT)
thanks 1 user thanked Paul Rayman for this useful post.
BBuech on 7/1/2021(UTC)
BBuech  
#3 Posted : Thursday, July 1, 2021 2:02:42 AM(UTC)
BBuech

Rank: Newbie

Groups: Registered
Joined: 9/19/2018(UTC)
Posts: 4
Germany

Thanks: 1 times
Hello,

I didn't receive an email, that you've replied to my question.

Your Solution worked perfectly.

Thank you for your help.

Regards, B.Bücher


Users browsing this topic
Guest
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.