Hello everyone.
I need to convert some .pdfs into .tifs. Can we do this using fwh?
Reinaldo.
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 nilHB_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 );
}Mastintín; Muchas gracias por esta respuesta.
Saludos.
Reinaldo.
Reinaldo,
I've used Ghostsccript to do this at a few client sites. You just have to make sure to use the EXE and not the Ghostscript source code in order not to step into the GPL licensing requirements. Using the EXE and performing a ShellExecute will give you great results.
For example:
http://drakedwornik.com/2013/02/05/simp ... f-to-tiff/
You can automate the whole process by creating a windows service that monitors PDF files as they are dropped in a folder where the service invokes Ghostscript via a batch file with the proper commands where the resulting TIFF/JPGs can then be output to another folder that you application can watch for files as they are created.
Rene.
Rene;
That's exactly what I was looking for.
Thank you very much for sharing this solution.
Reinaldo.
No worries - here's another example - better at that: