FWSavePreviewToPDF 32-bit vs. 64-bit

FWSavePreviewToPDF 32-bit vs. 64-bit

Postby don lowenstein » Thu Feb 02, 2017 2:05 am

I use FWSavePreviewToPDF to create .PDF files

using FWH 32-bit version I can copy/paste text from the output.

using FWH 64-bit version COMPILING SAME EXACT CODE, I can not copy/paste text from the output. I can only copy an image section of the .PDF.

what can I do so that the 64-bit FWH allows me to copy / paste the pdf information as text?
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby don lowenstein » Thu Feb 02, 2017 2:08 am

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
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby nageswaragunupudi » Thu Feb 02, 2017 2:35 am

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?


Not possible with FWSavePreviewToPDF .
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10663
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby don lowenstein » Thu Feb 02, 2017 2:44 am

If I choose to preview the file first using the FWH preview, then click the "Save to PDF" button, I can indeed copy / paste text.

I don't see why the button on the report-preview screen from FWH will allow the copy / paste of text.
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby Antonio Linares » Thu Feb 02, 2017 10:45 am

Don,

> Correction - I use a different library for 32-bit PDF files

Can't you get a 64 bits version of such library ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42127
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby Carlos Mora » Thu Feb 02, 2017 12:01 pm

Hi Don

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?

What are you iusing in 32 bits to generate regular (no images) pdfs?
The only one i know is PdfToImage.dll, but it has several issues related to fonts handling, and in some cases the conversion was far from accurate.


Carlos
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby don lowenstein » Thu Feb 02, 2017 3:28 pm

clicking on the Export to PDF from the FiveWin previewer produces on that can be copy/pasted as text.

how does that happen?
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby don lowenstein » Thu Feb 02, 2017 4:35 pm

I used Image2pdf.dll from utility warrior.

it is a 32-bit library and I can't seem to find this vendor anymore.
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby Antonio Linares » Fri Feb 03, 2017 10:21 am

Don,

> clicking on the Export to PDF from the FiveWin previewer produces on that can be copy/pasted as text

Not sure if we can call the button function directly

We are checking it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42127
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby don lowenstein » Fri Feb 03, 2017 5:02 pm

FWSavePreviewToPDF is called by that button using a TPreview object I believe.
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby don lowenstein » Fri Feb 03, 2017 5:57 pm

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
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby nageswaragunupudi » Fri Feb 03, 2017 6:49 pm

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.

We will look into this issue.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10663
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby mastintin » Sat Feb 04, 2017 10:14 am

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.


Change
LPWSTR filefin = ( LPWSTR ) hb_parc( 3 );

to this :

LPWSTR filefin = AnsiToWide( ( char * ) hb_parc( 3 ) );
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby Carlos Mora » Sat Feb 04, 2017 11:43 am

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.


I was working for a couple of weeks with the owner of the library to fix several problems related to font identification in EMF records, but with no luck. Several month later the author emailed me an offer to buy the source code, becouse he was closing his software business. That was the last contact I had. Anyway, I wasn't happy with the library results and quit from using it since then.

In the first message you wrote that you were interested in copying text from prds. AFAIK, that cannot be done if the pdf is made of JPGs, unless you use some kind of OCR or so to do the conversion. Am I wrong?
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: FWSavePreviewToPDF 32-bit vs. 64-bit

Postby mastintin » Sat Feb 04, 2017 12:44 pm

My GdiplusEMFtojpg function is something other than fwh has. Also some changes would have some functions like Emm2Jpeg ,etc .
In my function besides regulating the quality of the image you can regulate the density (important in an impression)
I Put the modified function here (with another name not to mess with us) .
Code: Select all  Expand view  RUN


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();

}

 


changes in Emf2Jpeg( cEMF )
Code: Select all  Expand view  RUN


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

 


changes in Tpdf

Code: Select all  Expand view  RUN


 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

 


and changes in FWSavePreviewToPDF

Code: Select all  Expand view  RUN


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 )
     
 .......

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 49 guests