Problems with Preview

Problems with Preview

Postby dtussman » Tue Nov 08, 2022 11:07 pm

I'm having problems saving a Previewed document as a PDF file when running my application using a Remote Desktop Connection. No matter what I do it won't save the document as a PDF, even if I choose the Print option and pick a PDF writer as the printer. I suspect it has to do with where the meta file created by the Preview function is stored, although thats just a hunch. Is there any way to tell the Preview function where to store the meta files, or is there some other solution I'm missing?
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: Problems with Preview

Postby Silvio.Falconi » Wed Nov 09, 2022 9:51 am

you tried to delete the temp files because Rpreview saves the files starting with w and wmf or emf in a windows folder

you can set the folder change the function FWSavePreviewToPDF( oPreview, cPDF, lOpen ) you found on Prev2Pdf.prg

I use this

function FWSavePreviewToPDF( oPreview, cPDF, lOpen )
local cOrient, oPDF
local n

cPdf:= oApp:cPdfTemp

if LoadFreeImage() <= 32
MsgAlert( "Freeimage.dll non trovata" )
return nil
endif

DEFAULT cPDF := cGetFile( "PDF File (*.pdf)|*.pdf|", "Seleziona il File PDF da Save", ;
CurDir(), .t. )

....
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problems with Preview

Postby dtussman » Thu Nov 10, 2022 8:39 pm

Thanks Silvio. Tried that but it won't compile, doesn't recognize oApp
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: Problems with Preview

Postby Antonio Linares » Thu Nov 10, 2022 8:42 pm

Dear David,

I guess Silvio simply specifies a different path:

instead of cPdf:= oApp:cPdfTemp

use cPdf := "the_path"
regards, saludos

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

Re: Problems with Preview

Postby Silvio.Falconi » Thu Nov 10, 2022 8:55 pm

dtussman wrote:Thanks Silvio. Tried that but it won't compile, doesn't recognize oApp


oApp Is Mine....make as Antonio wrote but U must recompile with your application that function U found on fwh source/functions folder
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problems with Preview

Postby dtussman » Fri Nov 11, 2022 12:01 am

I'm not sure i've described the problem correctly. When connected to my application using windows Remote Desktop Connection, if I preview a document and then click the button to save as a PDF it saves the document but all the pages are blank. It works fine when not using Remote Desktop Connection.
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: Problems with Preview

Postby Antonio Linares » Fri Nov 11, 2022 9:56 am

Dear David,

I have built FWH\samples\testprn2.prg and then copied the EXE to a remote PC managed with remote desktop.

The preview is properly shown and if I export it to PDF, the PDF is properly seen. Could you please reproduce my test ?

Here you have a screenshot of my test: (click on the url to see the entire screenshot)
https://github.com/FiveTechSoft/screenshots/blob/master/testprn2.jpg?raw=true

thanks
regards, saludos

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

Re: Problems with Preview

Postby karinha » Fri Nov 11, 2022 1:47 pm

I do like this:

Code: Select all  Expand view

FUNCTION Main()

   PRIVATE cDirPleno := GETCURDIR()

RETURNÿNIL

function FWSavePreviewToPDF( oDevice, cPDF, lOpen )   // oDevice can be oPrinter or oPreview

   local cOrient, oPDF, cPRGPATH
   local hWnd

   if oDevice:IsKindOf( "TPREVIEW" )
      hWnd    := oDevice:oWnd:hWnd
      oDevice := oDevice:oDevice
   endif
#ifndef USEGDI
   if LoadFreeImage() <= 32
      MsgAlert( FWString( "freeimage.dll not found" ), FWString( "Alert" ) )
      return nil
   endif
#endif

   PRIVATE CDIRPLENO

   // AQUI
   cPRGPATH := cFILEPATH( "C:\NFEPDF\" )

   lCHDIR(cPRGPATH)    // AQUI

   // ? hb_CurDrive() + "
:\" + CurDir() + "\"

   DEFAULT cPDF   := cGetFile( FWString( "
PDF files | *.pdf |" ),;
                               FWString( "
Select PDF File to Save" ),, ;
                               CurDir(), .T.,,,;
                               hb_CurDrive() + "
:\" + CurDir() + "\" + ;
                               If( oDevice:IsKindOf( "
TPreview" ),;
                               oDevice:cName, oDevice:cDocument ) + "
.pdf"  )
   if ! Empty( cPDF )
      cPDF = cFileSetExt( cPDF, "
pdf" )
      CursorWait()
      cOrient = If( oDevice:nHorzSize() > oDevice:nVertSize(), 'L', 'P' )
      oPdf = fwPdf():New( cPdf, cOrient )
      AEval( oDevice:aMeta, { | cMeta | oPdf:AddMeta( cMeta ) } )
      oPdf:Close()
      CursorArrow()

      DEFAULT lOpen := MsgYesNo( If( FWLanguageID() == 2, FWString( "
¿" ) + " ", "" ) + ;
                       FWString( "
View" ) + ;
                       "
" + cPDF + " " + FWString( "(Y/N)" ) + " ?",;
                       FWString( "
Please select" ) )

      if lOpen
         ShellExecute( IfNil( hWnd, GetWndDefault() ), "
open", cPDF )
      endif
   else
      cPDF  := nil
   endif

   // RETURN TO MASTER -    // AQUI
   lCHDIR( cDirPleno )

   // ? hb_CurDrive() + "
:\" + CurDir() + "\"

return cPDF


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7826
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Problems with Preview

Postby Otto » Fri Nov 11, 2022 2:25 pm

Hello Silvio,
sure no rights on the RDP server where you save the preview.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Problems with Preview

Postby Otto » Fri Nov 11, 2022 2:35 pm

... you need read/write for RemoteDesktopUser
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Problems with Preview

Postby Silvio.Falconi » Fri Nov 11, 2022 3:25 pm

Otto wrote:Hello Silvio,
sure no rights on the RDP server where you save the preview.
Best regards,
Otto

I not must print from remote
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problems with Preview

Postby dtussman » Fri Nov 11, 2022 7:23 pm

Hello Antonio,

I compiled and ran your testprn2.prg i and the preview displays the nice pattern of plus signs but the pdf only displays 2 blank pages. As I said before I suspect it has something to do with the application not being able to access the preview temp files or images (I'm not sure exactly what form they are in) which I assume its trying to store on the remote server. I'm running the app on a remote server, not just on another computer.

Regards,

David
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: Problems with Preview

Postby Antonio Linares » Fri Nov 11, 2022 8:22 pm

Dear David,

Please check these values remotely:

MsgInfo( GetEnv( "TEMP" ) )
MsgInfo( GetEnv( "TMP" ) )
MsgInfo( GetWinDir() )
MsgInfo( oPrinter:cDir ) will tell you which one is in use

as this is the code where the preview sets the temporary folder:
Code: Select all  Expand view
     ::cDir   = GetEnv( "TEMP" )

      if Empty( ::cDir )
         ::cDir = GetEnv( "TMP" )
      endif

      if Right( ::cDir, 1 ) == "\"
         ::cDir = SubStr( ::cDir, 1, Len( ::cDir ) - 1 )
      endif

      if ! Empty( ::cDir )
         if ! lIsDir( ::cDir )
            ::cDir = GetWinDir()
         endif
      else
         ::cDir := GetWinDir()
      endif

Check what they return and if you have write access there
regards, saludos

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

Re: Problems with Preview

Postby Otto » Fri Nov 11, 2022 8:53 pm

Dear Antonio,
We found out, that on some WINDOWS version you have to create the TEMP DIR yourself.
Best regards,
Otto
Code: Select all  Expand view



    local cUmgebungTMP := GETENV("TMP")

   *----------------------------------------------------------


    if lIsDir( cUmgebungTMP ) = .f.
        ? "TEMP DIR erstellen " + cUmgebungTMP
        lMKDir( cUmgebungTMP )
    endif

 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Problems with Preview

Postby dtussman » Sat Nov 12, 2022 1:39 am

Hi Antonio,

Both the TEMP and TMP variables were a strange folder that doesn't even exist and that was also the oprinter:cdir folder. So I created my own temp folder and changed oprinter:cdir to that folder. When running your sample code 2 emf files appeared in that folder, but when converting to pdf I still get the same result, 2 blank pages.
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 99 guests