Foxit Corporation Forums  

Go Back   Foxit Corporation Forums > Portable Document Format (PDF) Tools > SDK ( DLL or ActiveX)

SDK ( DLL or ActiveX) Integrate PDF functions into your application easily. The SDK shares the same technology that powers Foxit Reader.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 4th, 2006, 05:42 AM
kodapala kodapala is offline
Junior Member
 
Join Date: Oct 2006
Posts: 1
kodapala is an unknown quantity at this point
Default need help in saving Page as Image

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
Reply With Quote
  #2  
Old January 4th, 2007, 07:34 PM
jcreynol jcreynol is offline
Junior Member
 
Join Date: Jan 2007
Posts: 1
jcreynol is an unknown quantity at this point
Default Any Luck??

Did you have any success finding a fix for this error?
Reply With Quote
  #3  
Old January 8th, 2007, 11:14 PM
wanli_zi wanli_zi is offline
Junior Member
 
Join Date: Jan 2007
Posts: 4
wanli_zi is an unknown quantity at this point
Default Create dc first

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)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 11:28 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2005-2008 Foxit Corporation. All rights reserved.