FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour create a pdf
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

create a pdf

Posted: Wed Apr 21, 2021 09:07 AM

I want to print the contents of a window in a pdf

how should i do?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: create a pdf

Posted: Wed Apr 21, 2021 05:05 PM
Code (fw): Select all Collapse
function WndToPdf( oWnd, cPdf )

   local cJpg  := cFileSetExt( cPdf, "jpg" )
   local oPrn

   oWnd:SaveAsImage( cJpg, 100 )

   PRINT oPrn PREVIEW FILE cPdf
   PAGE
   @ 1,1 PRINT TO oPrn IMAGE cJpg
   ENDPAGE
   ENDPRINT

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: create a pdf

Posted: Fri Apr 23, 2021 10:25 AM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
function WndToPdf( oWnd, cPdf )

   local cJpg  := cFileSetExt( cPdf, "jpg" )
   local oPrn

   oWnd:SaveAsImage( cJpg, 100 )

   PRINT oPrn PREVIEW FILE cPdf
   PAGE
   @ 1,1 PRINT TO oPrn IMAGE cJpg
   ENDPAGE
   ENDPRINT

return nil


Nages,


Now I made a test WndToPdf( oApp():oSpiaggia, "test.pdf" )

and I have a pdf with the image is blurred that is not clear



any solution ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: create a pdf

Posted: Fri Apr 23, 2021 10:59 AM

The function must have saved test.jpg before creating test.pdf. Check the quality of test.jpg

Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: create a pdf

Posted: Fri Apr 23, 2021 11:29 AM
nageswaragunupudi wrote:The function must have saved test.jpg before creating test.pdf. Check the quality of test.jpg

good quality I sent you now
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: create a pdf

Posted: Sat Apr 24, 2021 11:52 AM

Nages,
the function give me a white page pdf today!!!! ( while test.jpg is created)

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: create a pdf

Posted: Thu Apr 29, 2021 10:07 AM
Nages,
the function create a jpg but when it create a pdf insert a blurred image in the pdf sheet

Code (fw): Select all Collapse
function WndToPdf( oWnd, cPdf )

   local cJpg  := cFileSetExt( cPdf, "jpg" )
   local oPrn

   oWnd:SaveAsImage( cJpg, 100 )

   PRINT oPrn PREVIEW FILE cPdf
   PAGE
   @ 1,1 PRINT TO oPrn IMAGE cJpg
   ENDPAGE
   ENDPRINT

return nil

the image created


the image on pdf

How I can resolve it ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM

Re: create a pdf

Posted: Fri Apr 30, 2021 04:47 AM
On Fivewin there is a function FWJPGTOPDF that write basic PDF with the jpg, can you try
Code (fw): Select all Collapse
procedure WndToPdf( oWnd, cPdf )

   local cJpg  := cFileSetExt( cPdf, "jpg" )
   local oPrn

   oWnd:SaveAsImage( cJpg, 100 )

   FwJpgToPdf(cJpg, cPdf)

return


edit: it comes stretched.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: create a pdf

Posted: Fri Apr 30, 2021 04:51 AM
Code (fw): Select all Collapse
 FwJpgToPdf(cJpg, cPdf)

I did not propose this because of the problems in resizing the image.
This works well if the proportions of the image fit into the paper size.
Regards



G. N. Rao.

Hyderabad, India
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM

Re: create a pdf

Posted: Fri Apr 30, 2021 04:57 AM

I see, the problem is that calls PGJPEG1 with the size of the page, instead of with the size of image... it is should be quick fix... maybe with the new lib haru interface, is possible create a pdf without change the quality of jpg

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: create a pdf

Posted: Fri Apr 30, 2021 05:06 AM
AntoninoP wrote:I see, the problem is that calls PGJPEG1 with the size of the page, instead of with the size of image... it is should be quick fix... maybe with the new lib haru interface, is possible create a pdf without change the quality of jpg


The proposed function, if used with haru, will produce better results.

Add this at the beginning the program
Code (fw): Select all Collapse
REQUEST FWHARU

and anywhere in the program
Code (fw): Select all Collapse
TPrinter():lUseHaruPDF := .t.


With these two changes, the same function I posted will give better results.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion