create a pdf

Post Reply
User avatar
Silvio.Falconi
Posts: 7133
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

create a pdf

Post by Silvio.Falconi »

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 November 2023 - January 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
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: create a pdf

Post by nageswaragunupudi »

Code: Select all | Expand

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
User avatar
Silvio.Falconi
Posts: 7133
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: create a pdf

Post by Silvio.Falconi »

nageswaragunupudi wrote:

Code: Select all | Expand

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

Image

any solution ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: create a pdf

Post by nageswaragunupudi »

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

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 7133
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: create a pdf

Post by Silvio.Falconi »

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 November 2023 - January 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
User avatar
Silvio.Falconi
Posts: 7133
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: create a pdf

Post by Silvio.Falconi »

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 November 2023 - January 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
User avatar
Silvio.Falconi
Posts: 7133
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: create a pdf

Post by Silvio.Falconi »

Nages,
the function create a jpg but when it create a pdf insert a blurred image in the pdf sheet

Code: Select all | Expand

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
Image

the image on pdf
Image
How I can resolve it ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
AntoninoP
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: create a pdf

Post by AntoninoP »

On Fivewin there is a function FWJPGTOPDF that write basic PDF with the jpg, can you try

Code: Select all | Expand

procedure WndToPdf( oWnd, cPdf )

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

   oWnd:SaveAsImage( cJpg, 100 )

   FwJpgToPdf(cJpg, cPdf)

return


edit: it comes stretched.
Last edited by AntoninoP on Fri Apr 30, 2021 4:56 am, edited 1 time in total.
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: create a pdf

Post by nageswaragunupudi »

Code: Select all | Expand

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
AntoninoP
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: create a pdf

Post by AntoninoP »

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
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: create a pdf

Post by nageswaragunupudi »

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: Select all | Expand


REQUEST FWHARU
 

and anywhere in the program

Code: Select all | Expand


TPrinter():lUseHaruPDF := .t.
 


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

G. N. Rao.
Hyderabad, India
Post Reply