Hello everyone.
I need to convert some .pdfs into .tifs. Can we do this using fwh?
Reinaldo.
#include "FiveWin.ch"
function Main()
local oWnd, oBtn
lShow := .f.
DEFINE WINDOW oWnd TITLE "FiveWin ActiveX Support" ;
FROM 5,5 TO 800, 550 PIXEL
@ 2, 2 BUTTON oBtn PROMPT "Show PDF" SIZE 80, 20 ACTION ShowPDF( oWnd, oBtn )
ACTIVATE WINDOW oWnd
return nil
function ShowPDF( oWnd, oBtn )
local oActiveX
oActiveX = TActiveX():New( oWnd, "AcroPDF.PDF.1" ) // Use "AcroPDF.PDF.1" for Acrobat Reader 7
oWnd:oClient = oActiveX // To fill the entire window surface
oActiveX:Do( "LoadFile", "normal.pdf" )
oActiveX:Do( "SetCurrentPage", 1 )
oActiveX:Do( "setShowToolbar", 0 )
oBtn:Hide()
oWnd:ReSize()
if msgYesNo( "capturar?")
captureWnd( oWnd, "yo.tif", 45,90, oWnd:nWidth-82, ownd:nHeight-142 )
endif
return nil
function captureWnd( oWnd, cFile, ntop,nleft,nWidth, nHeight )
local oImage:= GDIBmp():new()
oImage:hbmp:=GDIPLUSCAPTURERECTWND(ownd:hWnd, nTop,nLeft,nWidth,nHeight )
oImage:save( cFile )
return nil
HB_FUNC( GDIPLUSCAPTURERECTWND )
{
HWND hWnd = ( HWND ) hb_parnl( 1 ) ;
int nTop = hb_parni( 2 );
int nLeft = hb_parni( 3 );
int nWidth = hb_parni( 4 );
int nHeight = hb_parni( 5 );
HDC hWndDC = GetDC( hWnd );
HDC hCaptureDC = CreateCompatibleDC( hWndDC );
RECT rcClient;
GetClientRect(hWnd, &rcClient);
HBITMAP hCaptureBitmap = CreateCompatibleBitmap( hWndDC, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top );
SelectObject( hCaptureDC, hCaptureBitmap );
BitBlt( hCaptureDC, 0, 0, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top,
hWndDC,0, 0, SRCCOPY | CAPTUREBLT );
Bitmap * original = new Bitmap( hCaptureBitmap, NULL );
ReleaseDC( hWnd, hWndDC );
DeleteDC( hCaptureDC );
DeleteObject( hCaptureBitmap );
Bitmap* newImage = new Bitmap( nWidth, nHeight);
Graphics * graphics = new Graphics( newImage );
Rect destino ( 0 , 0 , nWidth, nHeight );
graphics->DrawImage( original, destino , nTop , nLeft , nWidth, nHeight, UnitPixel );
delete graphics ;
delete original ;
hb_retnl( ( HB_LONG ) newImage );
}
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 56 guests