Page 1 of 1

TITLE OF print

Posted: Wed Jan 21, 2026 8:47 am
by MarcoBoschi

Hi,
in the file errore.pdf I find as title "Fivewin Report" and not "errore"

If I remove FILE cNomepdf when I run this little test program appears the dialog to assign the output name
and the title is correct.

Code: Select all | Expand

PRINT oPrn TITLE cNameReport TO "Microsoft Print to PDF"

how is it possible to correct this?

Many Thanks
Marco

Code: Select all | Expand

#include "Fivewin.ch"

FUNCTION MAIN()

LOCAL cNameReport, cNomePdf
LOCAL oPrn

cNameReport := "errore"
cNomePdf    := cNameReport + ".pdf"

PRINT oPrn TITLE cNameReport TO "Microsoft Print to PDF" FILE cNomePdf

  PAGE
    oPrn:Say( 100 , 100 , "TEST" )
  ENDPAGE

ENDPRINT

RETURN NIL

Re: TITLE OF print

Posted: Wed Jan 21, 2026 3:56 pm
by karinha

Code: Select all | Expand

// C:\FWH...\SAMPLES\DETLEF4.PRG

#Include "FiveWin.ch"

#Define PAD_LEFT            0
#Define PAD_RIGHT           1
#Define PAD_CENTER          2

FUNCTION Main()

   LOCAL oBrushRed, oBrushGrn
   LOCAL oPrn, nWidth, nHeight, nRow
   LOCAL oFont, oBold, cTxt
   LOCAL cBigText := MemoRead( "tutor02.prg" )

   DEFINE BRUSH oBrushRed COLOR CLR_RED
   DEFINE BRUSH oBrushGrn COLOR CLR_HGREEN

   // Before print command
   TPrinter():lUseHaruPdf := .T.
   TPreview():bButtonBar  := {| oPrv, oWnd | MyBar( oPrv, oWnd ) }

   // PRINT oPrn PREVIEW MODAL
   PRINT oPrn TITLE "PRINT TITLE: BOSCHI" PREVIEW MODAL  // NAME PREVIEW IN PRINTER, NO IN ADOBE.

  DEFINE FONT oFont NAME "CONSOLAS" SIZE 0, - 10      OF oPrn
  DEFINE FONT oBold NAME "VERDANA"  SIZE 0, - 26 BOLD OF oPrn

  oPrn:SetPage( 9 ) ; oPrn:SetPortrait()

  nWidth   := oPrn:PageWidth(  "CM" )
  nHeight  := oPrn:PageHeight( "CM" )

  PAGE

     oPrn:Say( 2, nWidth / 2, FWVERSION + " oPrn:Say()", oBold, NIL, NIL, NIL, 2, "CM" )

     oPrn:SayText( 1000, 400, "DETLEF: THE BIG TEXT IN FWH: ", 4200, 400, oBold, nil, CLR_MAGENTA, nil, "PIXEL" )

     oPrn:SayText( 1300, 400, cBigText, 4200, 4000, oFont, nil, CLR_YELLOW, oBrushRed, "PIXEL" )

     oPrn:SayText( 5700, 400, "Yellow, RedBrush DETLEF", 4200, 400, oBold, nil, CLR_YELLOW, oBrushRed, "PIXEL" )

     oPrn:SayText( 6200, 400, "Default: nil,nil DETLEF", 4200, 400, oBold, nil, nil,        oBrushGrn, "PIXEL" )

     cTxt := "[email protected]"

     oPrn:Say( 6700, 1800, cTxt, oBold, , CLR_HRED, , PAD_CENTER )

  ENDPAGE

   ENDPRINT

   TPreview():bButtonBar := nil

   RELEASE FONT oFont, oBold, oBrushRed, oBrushGrn

RETURN NIL

STATIC FUNCTION MyBar( Self, oWnd )

   LOCAL cFile   := "FIVEWIN REPORT.pdf", oFont, oBtn  // NAME IN ADOBE.
   LOCAL nAlpha  := 0x60
   LOCAL nBarClr := RGB( 0, 0x2E, 0x5C )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14

   DEFINE BUTTONBAR ::oBar OF oWnd SIZE 48, 48 2007

   ::oBar:SetColor( { |l,o| If( l, CLR_BLACK, CLR_WHITE ) }, oWnd:nClrPane )
   ::oBar:bClrGrad := { |lInvert| If( lInvert, nArgb( 96, CLR_WHITE ), nArgb( nAlpha % 256, nBarClr ) ) }

   ::oBar:GoTop()

   DEFINE BUTTON OF ::oBar RESOURCE FWBitmap( "PDF" )   CENTER ;
      ACTION ::SaveAs( .T., cFile, .T. )

   DEFINE BUTTON OF ::oBar RESOURCE FWBitmap( "email" ) CENTER ;
      ACTION ::SendEmail()

   // By master: UWE. ( Ukoenig )
   DEFINE BUTTON oBtn OF ::oBar PROMPT "Color"  FILE "..\bitmaps\colors.bmp"  ;
      ACTION ( nBarClr := ChooseColor( RGB( 0, 0x2E, 0x5C ) ), ::oBar:Refresh() )

   DEFINE BUTTON OF ::oBar RESOURCE FWBitmap( "Exit2" ) CENTER ;
      ACTION oWnd:End()

RETURN NIL

// FIN / END - [email protected]

Regards, saludos.


Re: TITLE OF print

Posted: Wed Jan 21, 2026 4:25 pm
by MarcoBoschi

Ah ok,
but how do I modify your source file so that, without preview, it creates the PDF document with the correct title? So directly create the PDF with the correct title?

Thanks again
Marco


Re: TITLE OF print

Posted: Wed Jan 21, 2026 6:10 pm
by Enrico Maria Giordano

The problem is here, inside printer.prg (look at the last line):

Code: Select all | Expand

function MSPrintToPDF( aMeta, cFile, lView )

   local hDC, cEmf, hMeta

   if AScan( aGetPrinters(), "Microsoft Print to PDF"  ) > 0

  if Empty( cFile ) .and. Empty( cFile := cGetFile( "( *.pdf ) |*.pdf|", FWString( "File to Save" ), 1, CurDir(), .t. ) )
     return .f.
  endif
  cFile    := cFileSetExt( cFile, "pdf" )
  cFile    := TrueName( cFile )
  if File( cFile ) .and. FErase( cFile ) != 0
     ? cFile + " is in use. Can not overwrite"
     return .f.
  endif

  hDC   := PrinterDcFromName( nil, "Microsoft Print to PDF", nil )
  if StartDoc( hDC, "FiveWin Report", cFile ) > 0

Since MSPrintToPDF() function does not receive the printer object, we have to change its signature. I propose to replace this
MSPrintToPDF( oPrinter:aMeta, cPdf, lOpen )
with
MSPrintToPDF( oPrinter, cPdf, lOpen )
Antonio, do you agree? Can I make this fix as proposed?


Re: TITLE OF print

Posted: Thu Jan 22, 2026 5:44 am
by Antonio Linares

Dear Enrico,

Antonio, do you agree? Can I make this fix as proposed?

May it break existing FWH users code ?

If not, then please proceed :)

many thanks


Re: TITLE OF print

Posted: Thu Jan 22, 2026 8:38 am
by Enrico Maria Giordano

Only if they've used the function MSPrintToPDF() directly. The function signature will change from
MSPrintToPDF( aMeta, cFile, lView )
to
MSPrintToPDF( oPrn, cFile, lView )
Please confirm.


Re: TITLE OF print

Posted: Thu Jan 22, 2026 2:51 pm
by Antonio Linares

Dear Enrico,

ok, then please proceed :wink:

many thanks!


Re: TITLE OF print

Posted: Thu Jan 22, 2026 3:31 pm
by Enrico Maria Giordano

Done.


Re: TITLE OF print

Posted: Tue Jan 27, 2026 3:16 pm
by MarcoBoschi

Many thanks to all