Page 1 of 1

create a pdf

Posted: Wed Apr 21, 2021 9:07 am
by Silvio.Falconi
I want to print the contents of a window in a pdf

how should i do?

Re: create a pdf

Posted: Wed Apr 21, 2021 5:05 pm
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
 

Re: create a pdf

Posted: Fri Apr 23, 2021 10:25 am
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 ?

Re: create a pdf

Posted: Fri Apr 23, 2021 10:59 am
by nageswaragunupudi
The function must have saved test.jpg before creating test.pdf. Check the quality of test.jpg

Re: create a pdf

Posted: Fri Apr 23, 2021 11:29 am
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

Re: create a pdf

Posted: Sat Apr 24, 2021 11:52 am
by Silvio.Falconi
Nages,
the function give me a white page pdf today!!!! ( while test.jpg is created)

Re: create a pdf

Posted: Thu Apr 29, 2021 10:07 am
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 ?

Re: create a pdf

Posted: Fri Apr 30, 2021 4:47 am
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.

Re: create a pdf

Posted: Fri Apr 30, 2021 4:51 am
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.

Re: create a pdf

Posted: Fri Apr 30, 2021 4:57 am
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

Re: create a pdf

Posted: Fri Apr 30, 2021 5:06 am
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.