![]() |
|
|||||||
| SDK ( DLL or ActiveX) Integrate PDF functions into your application easily. The SDK shares the same technology that powers Foxit Reader. |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi everyone,
I have just started exploring foxit sdk for my needs(read, display, zoom, rotate, magnify, SAVE etc.) I am using foxit dll from vb.net 2003 as well as 2005. i have successfully managed to display the image in a picturebox with the help of code posted by Williams. it is very very fast & simple, Furthur i want to be able to save pdf page as a image into some location on the machine and use it later. following is the code i tried to save a page '-------------code 'code to load Dim pdf_doc As Integer = Foxit.FPDFView.FPDF_LoadDocument("c:\test.pdf", "") pdf_page = Foxit.FPDFView.FPDF_LoadPage(pdf_doc, 0) Dim page_width As Integer = Foxit.FPDFView.FPDF_GetPageWidth(pdf_page) Dim page_height As Integer = Foxit.FPDFView.FPDF_GetPageHeight(pdf_page) '---> successful till here Dim hdc2, hMemDC, hbitmap As IntPtr hMemDC = Foxit.FPDFView.CreateCompatibleDC(hdc2) hbitmap = Foxit.FPDFView.CreateCompatibleBitmap(hdc2, page_width, page_height) '-----> this line is always returning 0 for hbitmap hbitmap = Foxit.FPDFView.SelectObject(hMemDC, hbitmap) Foxit.FPDFView.FPDF_RenderPage(hMemDC, pdf_page, 0, 0, page_width, page_height, 0, 0) hbitmap = Foxit.FPDFView.SelectObject(hMemDC, hbitmap) Dim img As Image = Image.FromHbitmap(hbitmap) img.Save("C:\\tryFoxit2.bmp", ImageFormat.Bmp) MessageBox.Show("Image Successfully saved") '--------------- end code the code fails at Dim img As Image = Image.FromHbitmap(hbitmap) saying System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.FromHbitmap(IntPtr hbitmap, IntPtr hpalette) at System.Drawing.Image.FromHbitmap(IntPtr hbitmap) at tryThumbNails.frmFoxit.button1_Click(Object sender, EventArgs e) in ...................... Thanks in advance loks |
|
#2
|
|||
|
|||
|
Did you have any success finding a fix for this error?
|
|
#3
|
|||
|
|||
|
Dim hdc2, hMemDC, hbitmap As IntPtr
//here you need creat the DC first hMemDC = Foxit.FPDFView.CreateCompatibleDC(hdc2) hbitmap = Foxit.FPDFView.CreateCompatibleBitmap(hdc2, page_width, page_height) '-----> this line is always returning 0 for hbitmap hbitmap = Foxit.FPDFView.SelectObject(hMemDC, hbitmap) |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|