Issue using StartPage and an image

  • VS2005, .Net 2
    Using the following code, i just get a blank pdf with the WP demo logo (using the Demo download to see if this app will be usable) on it, the image is aquired from a twain device, converted from a Dibhandle to a Image (using the MS GDI+ library) . The image renders correctly when applied to any control. (or saved to a file)

    Code
    dim currentDisplayedImage As System.Drawing.Image    dim pics As ArrayList = Nothing        pics = twain.TransferPictures() '(not exactly done here, but shown to make code more understandable)        pdfOutput.SetLicense("LicenseName", "LicenseCode", 0)        pdfOutput.FileName = "c:\test.pdf"        pdfOutput.BeginDoc()        For i As Integer = 0 To pics.Count - 1            Dim img As IntPtr = CType(pics(i), IntPtr)            currentDisplayedImage = Plumbing.DibToBmp.DibHandToBmp(img)            pdfOutput.StartPage(currentDisplayedImage, 100)            pdfOutput.EndPage()            PictureEdit1.Image = currentDisplayedImage        Next        pdfOutput.EndDoc()

    However, using this in the loop, does correctly add the bmp to the pdf

    Code
    currentDisplayedImage.Save("c:\test" & i & ".bmp")
                pdfOutput.StartPage()
                pdfOutput.DrawImage("c:\test" & i & ".bmp") 
                pdfOutput.EndPage()
    • Offizieller Beitrag

    Hi,

    StartPage will not work with just an image handle, only metafile handles. Reason is that the engine does not know the size of the image otherewise (depens on resolution)

    You will need StartPage to set the page size.

    Jiulian