Add image

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Add image

gyanuz
can anybody tell me how can i add book cover image in description page.
Reply | Threaded
Open this post in threaded view
|

Re: Add image

gyanuz
Done
Reply | Threaded
Open this post in threaded view
|

Re: Add image

jimmyyy
In reply to this post by gyanuz
I have ever googled a tutorial for adding image to PDF document page. Below demo code is what I have used before. I used it to draw a bmp image on accurately specified location on my PDF document page. You may have a try and you can modify the sample code based on your needs.

Public Shared FolderName As String = "c:/"

Private Sub button1_Click(sender As Object, e As EventArgs)
    Dim fileName As String = FolderName & "Sample.pdf"

    Dim doc As REDocument = REFile.OpenDocumentFile(fileName, New PDFDecoder())
    'use PDFDecoder open a pdf file
    Dim rePage As REPage = DirectCast(doc.GetPage(0), REPage)
    Dim width As Integer = 100
    Dim height As Integer = 60

    ''' data[]: a byte array to contain color data (as same format as Image Data PixelArray in BMP file)
    ''' caller must provide correct color data; otherwise, unpredictable error may happen
    Dim data As Byte() = New Byte(width * height * 3 - 1) {}
    '  set bottom 20 lines to red
    For rowIdx As Integer = 0 To 19
        For i As Integer = 0 To width - 1
            data(width * rowIdx * 3 + i * 3 + 2) = &Hff
        Next
    Next
    '  set top 10 lines to blue
    For rowIdx As Integer = 0 To 9
        For i As Integer = 0 To width - 1
            data(width * (height - 1 - rowIdx) * 3 + i * 3) = &Hff
        Next
    Next

    Dim reImage As New REImage(width, height, ImageMode.RGB888, data)


    REFile.SaveDocumentFile(doc, "c:/reimage.pdf", New PDFEncoder())
End Sub