TITLE OF print

Post Reply
User avatar
MarcoBoschi
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

TITLE OF print

Post 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
Marco Boschi
[email protected]
User avatar
karinha
Posts: 8720
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: TITLE OF print

Post 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.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
MarcoBoschi
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: TITLE OF print

Post 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

Marco Boschi
[email protected]
User avatar
Enrico Maria Giordano
Posts: 9054
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: TITLE OF print

Post 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?

User avatar
Antonio Linares
Site Admin
Posts: 44515
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TITLE OF print

Post 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

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 9054
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: TITLE OF print

Post 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.

User avatar
Antonio Linares
Site Admin
Posts: 44515
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TITLE OF print

Post by Antonio Linares »

Dear Enrico,

ok, then please proceed :wink:

many thanks!

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
MarcoBoschi
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: TITLE OF print

Post by MarcoBoschi »

Many thanks to all

Marco Boschi
[email protected]
Post Reply