don lowenstein wrote:Correction - I use a different library for 32-bit PDF files.
therefore, my question is, how can I create FWH pdf file that allows the text to be copy/paste as text and not an image?
don lowenstein wrote:Correction - I use a different library for 32-bit PDF files.
therefore, my question is, how can I create FWH pdf file that allows the text to be copy/paste as text and not an image?
don lowenstein wrote:HB_FUNC( GDIPLUSEMFTOJPG )
this function is used by FWSavePreviewToPDF to create a jpeg file.
for some reason the file created by DDIPLUSEMFTOJPG contains a file extension of JPEG followed by Chinese-looking characters.
LPWSTR filefin = ( LPWSTR ) hb_parc( 3 );
CLSID cClsid ;
CLSIDFromString( L"{557CF401-1A04-11D3-9A73-0000F81EF32E}" , &cClsid ) ;
newImage->Save( filefin , &cClsid, &encoderParameters );
the FErase commmand does not work on these files with the "unusual" extension.
where does the unusual extension come from?
these odd files accumulate and don't get deleted by FErase.
don lowenstein wrote:HB_FUNC( GDIPLUSEMFTOJPG )
this function is used by FWSavePreviewToPDF to create a jpeg file.
for some reason the file created by DDIPLUSEMFTOJPG contains a file extension of JPEG followed by Chinese-looking characters.
LPWSTR filefin = ( LPWSTR ) hb_parc( 3 );
CLSID cClsid ;
CLSIDFromString( L"{557CF401-1A04-11D3-9A73-0000F81EF32E}" , &cClsid ) ;
newImage->Save( filefin , &cClsid, &encoderParameters );
the FErase commmand does not work on these files with the "unusual" extension.
where does the unusual extension come from?
these odd files accumulate and don't get deleted by FErase.
don lowenstein wrote:I used Image2pdf.dll from utility warrior.
it is a 32-bit library and I can't seem to find this vendor anymore.
HB_FUNC( GDIP_EMFTOJPG )
{
FILE * fil = fopen ( hb_parc(1) , "rb" ) ;
fseek ( fil , 0 , SEEK_END ) ;
int filesize = ftell ( fil ) ;
fseek ( fil , 0 , SEEK_SET ) ;
HGLOBAL hglobal = GlobalAlloc ( GMEM_MOVEABLE , filesize ) ;
char * adr = (char *)GlobalLock ( hglobal ) ;
int nbytes = fread ( adr , 1 , filesize , fil ) ;
fclose ( fil ) ;
if ( nbytes != filesize )
{
MessageBox( GetActiveWindow(), "fallo", "No carga la imagen", 0x30 );
} ;
LPSTREAM pstm = NULL ;
GlobalUnlock ( hglobal ) ;
CreateStreamOnHGlobal ( hglobal, TRUE, &pstm ) ;
Metafile * original = new Metafile( pstm ) ;
LPWSTR filefin = AnsiToWide( ( char * ) hb_parc( 2 ) );
long quality = hb_parnl(3) ;
double nDensity = hb_parnl(4) ;
int nWidth = original->GetWidth() ;
int nHeight = original->GetHeight() ;
CLSID EncoderQuality ;
double nAlto ;
double nAncho ;
if ( nWidth > nHeight )
{
nAlto = ( 210 * nDensity ) / 25.4 ;
nAncho = ( 297 * nDensity ) / 25.4 ;
}
else
{
nAncho = ( 210 * nDensity) / 25.4 ;
nAlto = ( 297 * nDensity ) / 25.4 ;
}
nHeight = (int) nAlto ;
nWidth = (int) nAncho ;
Bitmap * newImage = new Bitmap(nWidth, nHeight );
newImage->SetResolution( nDensity, nDensity );
Graphics * g = new Graphics( newImage );
g->Clear( Color::White ) ;
g->SetSmoothingMode( SmoothingModeAntiAlias );
g->DrawImage( original,0, 0, nWidth, nHeight);
CLSIDFromString( L"{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}", &EncoderQuality ) ;
EncoderParameters encoderParameters;
encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderQuality ;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1;
encoderParameters.Parameter[0].Value = &quality ;
CLSID cClsid ;
CLSIDFromString( L"{557CF401-1A04-11D3-9A73-0000F81EF32E}" , &cClsid ) ;
newImage->Save( filefin , &cClsid, &encoderParameters );
delete newImage ;
delete g ;
delete original ;
pstm->Release();
}
static function Emf2Jpeg( cEMF , nQuality, nDensity )
local cJpeg := cFileSetExt( cEMF, "jpg" )
local hDC1, hDC, hDib, hDib2, hMem, hBmp, hOldBmp, hEMF
local cBuf, oRect, lRet := .f.
local nFormat
DEFAULT nQuality := 100
DEFAULT nDensity := 300
#ifdef USEGDI
if upper(right(cEMF,3)) == "EMF"
GDIP_EMFTOJPG( cEMF , cJpeg , nQuality, nDensity )
endif
cBuf := MemoRead( cJpeg )
#else
cBuf := MemoRead( cEMF )
oRect := TRect():New( 0, 0, Bin2L( SubStr( cBuf, 21, 4 ) ) / 2, ;
Bin2L( SubStr( cBuf, 17, 4 ) ) / 2 )
hEMF := GetEnhMetaFile( cEMF )
hDC1 := GetDC( GetDesktopWindow() )
hDC := CreateCompatibleDC( hDC1 )
hBmp := CreateCompatibleBitmap( hDC1, oRect:nWidth, oRect:nHeight )
hOldBmp := SelectObject( hDC, hBmp )
FillRect( hDC, oRect:aRect, GetStockObject( 0 ) )
PlayEMF( hDC, hEMF, oRect:cRect )
hDib := DibFromBitmap( hBmp )
cBuf := DibToStr( hDib )
GlobalFree( hDib )
// CloseEnhMetafile( hEMF ) // commented out 2014-02-13
DeleteEnhMetafile( hEMF ) // inserted 2014-02-13
SelectObject( hDC, hOldBmp )
DeleteDC( hDC )
DeleteDC( hDC1 )
DeleteObject( hBmp )
hMem := FI_OpenMemory( cBuf, Len( cBuf ) )
nFormat := FI_GetFileTypeFromMemory( hMem, 0 )
hDib := FI_LoadFromMemory( nFormat, hMem, 0 )
cBuf := nil // to release memory
FI_CloseMemory( hMem )
hDib2 := FICnv24( hDib )
FIUnload( hDib )
lRet := FISave( 2, hDib2, cJpeg, JPEG_DEFAULT )
FIUnload( hDib2 )
cBuf := If( lRet, MemoRead( cJpeg ), "" )
#endif
FErase( cJpeg )
return cBuf
DATA nQuality, nDensity
METHOD New( cFile, cOrient ,nQuality, nDensity ) CLASS FWPDF
DEFAULT cOrient := "P"
DEFAULT nQuality := 50
DEFAULT nDensity := 300
::nQuality := nQuality
::nDensity := nDensity
if cOrient == "P"
::nPageWidth := a4_width
::nPageHeight := a4_height
else
::nPageWidth := a4_height
::nPageHeight := a4_width
endif
::aRefs := { 0, 0 }
::nDocLen := PdfBegin( cFile )
return Self
METHOD AddMeta( cMeta ) CLASS FWPDF
local nAt
::nPage++
::WritePage( Emf2Jpeg( cMeta, ::nQuality, ::nDensity ) )
return Self
function FWSavePreviewToPDF( oDevice, cPDF, lOpen, nQuality, nDensity ) // oDevice can be oPrinter or oPreview
local cOrient, oPDF
local hWnd
LOCAL aDatos:= {}
DEFAULT nQuality := 50
DEFAULT nDensity := 300
.........
oPdf = fwPdf():New( cPdf, cOrient, nQuality, nDensity )
.......
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 77 guests