FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Tiff to PDF
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Tiff to PDF
Posted: Sat Jan 03, 2015 06:54 PM

Hi all,
I'm using the FWJPGTOPDF function to convert several jpg files in a single PDF file and it runs well.
I would like to know if there is a way to generate a PDF importing Tiff files.

Thank you in advance.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 05:45 AM

Marco,

You could convert the TIFF files to JPG files using the new FWH function GDIPlusConvertImage( cImageIni, cImageEnd ) and then use function FWJPGTOPDF()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 10:36 AM
Antonio, Marco ...
New function for fwh ...
Code (fw): Select all Collapse
function FWIMAGESTOPDF( aJpg, cPDF )
   local i
   local oPdf  := FWPdf():New( cPDF )
   local aFilesDelete:= {}
   local cJpg
   
   if ValType( aJpg ) != 'A'
      aJpg     := { aJpg }
   endif
   for i = 1 to len( aJpg )
      cJpg := aJpg[i]
     
      if Upper( cFileExt( cJpg ) ) != "JPG" 
         cJpg:= cFileSetExt( cJpg, "jpg" )
         aadd( aFileDelete, cJpg )
         GDIPlusConvertImage( aJpg[i], cJpg )                    
      endif
        
      oPdf:nPage++
      oPdf:WritePage( MemoRead( cJpg ) )  
      
   next 
  
   oPdf:Close()

   if len(aFilesDelete) > 0   
      AEval( aFilesDelete, { |cJpg| FErase( cJpg )  } )         
   endif

return cPDF


And proposed change for fwh code : ( Bye Bye freeImage) :-)

Code (fw): Select all Collapse
static function Emf2Jpeg( cEMF )

   local cJpeg    := cFileSetExt( cEMF, "jpg" )
   local cBuf, lRet := .f.
      
     GDIPlusConvertImage( cEMF, cJpeg )
     cBuf   := If( File( cJpeg ), MemoRead( cJpeg ), "" )
     FErase( cJpeg )

return cBuf
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 11:01 AM

Very Good Idea !!!

You might have worked with this change.
Any feedback about the quality and size ?

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 11:56 AM

Manuel,

Great! :D

:shock:

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 02:05 PM
mastintin wrote:And proposed change for fwh code : ( Bye Bye freeImage) :-)


Great! But... what about IMAGE control?

EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 02:36 PM
Enrico Maria Giordano wrote:
mastintin wrote:And proposed change for fwh code : ( Bye Bye freeImage) :-)


Great! But... what about IMAGE control?

EMG

We still need freeimage.dll in some cases like this.

It is better to reduce dependence on this dll in as many modules as we can.
Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 02:51 PM
Rao,

nageswaragunupudi wrote:We still need freeimage.dll in some cases like this.

It is better to reduce dependence on this dll in as many modules as we can.


Any chance to drop freeimage for loading an image too?

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 04:27 PM

Enrico,

I just emailed Manuel Alvarez (Mastintin) to know if GDI+ provides us a function to load images from resources and we will be much closer to finally drop FreeImage.dll use :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 05:20 PM
nageswaragunupudi wrote:Very Good Idea !!!

You might have worked with this change.
Any feedback about the quality and size ?


Size -> some as original
quality -> default 7 ...about 70% as original . :-) . Quality control not implemented yet (TODO LIST ). :-)
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 05:25 PM

Manuel,

Cual es tu email por favor?.

Gracias

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 06:00 PM
Antonio,

Antonio Linares wrote:I just emailed Manuel Alvarez (Mastintin) to know if GDI+ provides us a function to load images from resources and we will be much closer to finally drop FreeImage.dll use :-)


Very good!

EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 07:45 PM

We should be able to read not only from resources, but directly from any image file and memory and save to file also.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Tiff to PDF
Posted: Sun Jan 04, 2015 07:49 PM
Marco Turco wrote:Hi all,
I'm using the FWJPGTOPDF function to convert several jpg files in a single PDF file and it runs well.
I would like to know if there is a way to generate a PDF importing Tiff files.

Thank you in advance.

You can also consider using pdf libraries (contrib) of (x)Harbour. Using those libraries you can embed tiff, jpeg, png and bmp files into pdf.

We are not using these libraries for FWH because we like to restrict dependence on 3rd party libs.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Tiff to PDF
Posted: Thu Aug 05, 2021 01:58 PM
Antonio Linares wrote:Marco,

You could convert the TIFF files to JPG files using the new FWH function GDIPlusConvertImage( cImageIni, cImageEnd ) and then use function FWJPGTOPDF()


Hi Antonio,

What about multipage tif files? It only converts first page to jpg file. Is there any workaround?

Thanks.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06

Continue the discussion