Page 1 of 1

Centrar texto VERTICALMENTE

PostPosted: Mon Apr 08, 2024 10:45 pm
by FiveWiDi
Hola a todos,

Tengo que centrar un texto verticalmente. Está escrito en el eje de las 'y', en vertical, el FONT que utilizo está definido así:

DEFINE FONT oFnt_Arial6V NAME "Arial" SIZE 0,-6 OF ::oPrn NESCAPEMENT 900

PRINTER contempla centrar horizontalmente respecto del eje 'x', pero en vertical respecto del eje 'y' no lo veo.

¿Cómo lo harían Ustedes?
A ver que se les ocurre.

Muchas gracias

Re: Centrar texto VERTICALMENTE

PostPosted: Tue Apr 09, 2024 3:49 am
by nageswaragunupudi
Please try this sample program
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oPrn, oFont

   PRINT oPrn PREVIEW

   DEFINE FONT oFont NAME "Arial" SIZE 0,-60 NESCAPEMENT 900 OF oPrn

   PAGE
      oPrn:Box( 1, 1, 9, 4, 1, nil, nil, "INCHES" )
      @ 1,1 PRINT TO oPrn TEXT "VTEXT" SIZE 3,8 INCHES ALIGN "" FONT oFont
   ENDPAGE
   ENDPRINT
   RELEASE FONT oFont

return nil


Image

Re: Centrar texto VERTICALMENTE

PostPosted: Tue Apr 09, 2024 2:10 pm
by FiveWiDi
[quote="nageswaragunupudi"]Please try this sample program
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oPrn, oFont

   PRINT oPrn PREVIEW

   DEFINE FONT oFont NAME "Arial" SIZE 0,-60 NESCAPEMENT 900 OF oPrn

   PAGE
      oPrn:Box( 1, 1, 9, 4, 1, nil, nil, "INCHES" )
      @ 1,1 PRINT TO oPrn TEXT "VTEXT" SIZE 3,8 INCHES ALIGN "" FONT oFont
   ENDPAGE
   ENDPRINT
   RELEASE FONT oFont

return nil


Thank you very much mr. Nages

But that's not how it works:

PRINT oPrn FILE "C:\Temp\lerele.pdf"

I don't use HaruPDF.

Thank you very much anyway.

Re: Centrar texto VERTICALMENTE

PostPosted: Tue Apr 09, 2024 3:28 pm
by FiveWiDi
Mr. Nages,

I use the class TImprime and TUtilprn (provided years ago by Rafa Carmona ).

At the moment this is how it works for me (more or less):

ndummyaltura := ( ::oPrn:CmVertPhySize() / 2 ) + ( ::oPrn:CmtrGetTextWidth( AllTrim( ::oTDbfDatAmp:REGMER ), ::oFnt_Arial6V ) / 2 )

UTILPRN ::oUtil ndummyaltura, 0.5 ;
SAY AllTrim(::oTDbfDatAmp:REGMER) FONT ::oFnt_Arial6V COLOR CLR_BLACK

I want to center the text at half height of the page.


Note: New Method for de Printer.PRG

METHOD CmtrTextToVCenter( cText, oFont ) INLINE ;
( ::CmVertPhySize() / 2 ) + ::CmtrGetTextWidth( cText, oFont ) / 2


Thank you again,

Re: Centrar texto VERTICALMENTE

PostPosted: Tue Apr 09, 2024 4:05 pm
by nageswaragunupudi
Please try this way
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oPrn, oFont
   local cPdf  := "lerele.pdf" // your pdf file name

   TPrinter():lUseFWPDF := .t.
   
   PRINT oPrn FILE cPdf PREVIEW  // PREVIEW is optional. You can ommit PREVIEW

   DEFINE FONT oFont NAME "Arial" SIZE 0,-60 NESCAPEMENT 900 OF oPrn

   PAGE
      oPrn:Box( 1, 1, 9, 4, 1, nil, nil, "INCHES" )
      @ 1,1 PRINT TO oPrn TEXT "VTEXT" SIZE 3,8 INCHES ALIGN "" FONT oFont
   ENDPAGE
   ENDPRINT
   RELEASE FONT oFont

   TPrinter():lUseFWPDF := .f.

return nil


and let us know

Re: Centrar texto VERTICALMENTE

PostPosted: Tue Apr 09, 2024 4:06 pm
by karinha
Mira se ayuda:

Code: Select all  Expand view

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

#Include "FiveWin.ch"

FUNCTION Main()

   LOCAL WNOMBREARQPDF

   IF FILE( "C:\TEMP\ARCHIVO.PDF" )

      ERASE( "C:\TEMP\ARCHIVO.PDF" )

   ENDIF

   MsgRun( "GENERANDO ARCHIVO *.PDF...", ;
           "Por Favor, Aguarde...     ", ;
           { || WinExec( Generar_PDF() ), 3 } )

   // Perfect, mister Nages, Thank You
   IF FILE( "C:\TEMP\ARCHIVO.PDF" )

      WNOMBREARQPDF := "C:\TEMP\archivo.pdf"

      // ShellExecute( 0, "Print", WNOMBREARQPDF,,, 3 )  // Impresora

      ShellExecute( 0, "OPEN", WNOMBREARQPDF )           // Acrobat

   ENDIF

RETURN NIL

FUNCTION Generar_PDF()

   LOCAL cText := MEMOREAD( "C:\TEMP\arq.txt" )
   LOCAL oPrn, oFont, oFontV, nLinha, nPage := 1

   nLinha := 0

   PRINT oPrn FILE "C:\TEMP\archivo.pdf"  // em silencio sem preview

      DEFINE FONT oFont  NAME "COURIER NEW" SIZE 0,-10                 OF oPrn
      DEFINE FONT oFontV NAME "COURIER NEW" SIZE 0,-80 NESCAPEMENT 900 OF oPrn

      WHILE .NOT. EMPTY( cText )

         SYSREFRESH()

         CURSORWAIT()

         PAGE

            @ nLinha-10, 00 PRINT TO oPrn TEXT "FIVEWIN" SIZE 3,8 INCHES ALIGN "" FONT oFontV

            @ nLinha, 1 PRINT TO oPrn TEXT @cText SIZE 7,10 INCHES FONT oFont

            IF nLinha >= 23

               ENDPAGE

               nPage := nPage + 1 // Number pages

               PAGE

            ENDIF
   
         ENDPAGE

         nLinha := nLinha + 1

      ENDDO

   ENDPRINT

   RELEASE FONT oFont
   RELEASE FONT oFontV

   CURSORARROW()

RETURN NIL

// FIN / END
 


Regards, saludos.

Re: Centrar texto VERTICALMENTE

PostPosted: Tue Apr 09, 2024 4:49 pm
by nageswaragunupudi
FiveWiDi wrote:Mr. Nages,

I use the class TImprime and TUtilprn (provided years ago by Rafa Carmona ).

At the moment this is how it works for me (more or less):

ndummyaltura := ( ::oPrn:CmVertPhySize() / 2 ) + ( ::oPrn:CmtrGetTextWidth( AllTrim( ::oTDbfDatAmp:REGMER ), ::oFnt_Arial6V ) / 2 )

UTILPRN ::oUtil ndummyaltura, 0.5 ;
SAY AllTrim(::oTDbfDatAmp:REGMER) FONT ::oFnt_Arial6V COLOR CLR_BLACK

I want to center the text at half height of the page.


Note: New Method for de Printer.PRG

METHOD CmtrTextToVCenter( cText, oFont ) INLINE ;
( ::CmVertPhySize() / 2 ) + ::CmtrGetTextWidth( cText, oFont ) / 2


Thank you again,


I can only comment on FWH classes.
What all you want to do, I am sure we can do with FWH classes in a far simpler way.

To print text vertically and horizontally centered on the page. No calculations required. The command is very simple:
Code: Select all  Expand view
@ 0, 0 PRINT TO oPrn TEXT "Single/MultiLine Text" ALIGN "" FONT oFont

It's that simple.

Re: Centrar texto VERTICALMENTE

PostPosted: Tue Apr 09, 2024 4:58 pm
by nageswaragunupudi
Mr. Karinha

Mira se ayuda:


Your example is longer but the same as my original sample as far as vertical oriented text is concerned,

You are missing the real point.

If you execute the program on a computer where MSWord is installed, you can not see the vertical text in the PDF.

You see the vertical text in PDF if (1) MS Word is not installed or (2) we set TPrinter():lUseFWPDF := .t.

Re: Centrar texto VERTICALMENTE

PostPosted: Tue Apr 09, 2024 5:17 pm
by karinha
nageswaragunupudi wrote:Mr. Karinha

Mira se ayuda:


Your example is longer but the same as my original sample as far as vertical oriented text is concerned,

You are missing the real point.

If you execute the program on a computer where MSWord is installed, you can not see the vertical text in the PDF.

You see the vertical text in PDF if (1) MS Word is not installed or (2) we set TPrinter():lUseFWPDF := .t.


Ok. Thanks for the information Master Nages. I did not know that.

Ok, gracias por la información Maestro Nages. No sabia de eso.

Regards, saludos.

Re: Centrar texto VERTICALMENTE

PostPosted: Tue Apr 09, 2024 6:08 pm
by nageswaragunupudi
Please try these samples in the samples folder:
print01.prg
print02.prg
pdfharu1.prg
pdfharu2.prg

You can see how to generate pdfs using Word, FWH own pdf, HaruPDF, Image2pdf
Please see how simplest and one line code to print complex outputs.

And advise us what more you want us to provide

Re: Centrar texto VERTICALMENTE

PostPosted: Tue Apr 09, 2024 7:07 pm
by FiveWiDi
nageswaragunupudi wrote:Please try this way
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oPrn, oFont
   local cPdf  := "lerele.pdf" // your pdf file name

   TPrinter():lUseFWPDF := .t.
   
   PRINT oPrn FILE cPdf PREVIEW  // PREVIEW is optional. You can ommit PREVIEW

   DEFINE FONT oFont NAME "Arial" SIZE 0,-60 NESCAPEMENT 900 OF oPrn

   PAGE
      oPrn:Box( 1, 1, 9, 4, 1, nil, nil, "INCHES" )
      @ 1,1 PRINT TO oPrn TEXT "VTEXT" SIZE 3,8 INCHES ALIGN "" FONT oFont
   ENDPAGE
   ENDPRINT
   RELEASE FONT oFont

   TPrinter():lUseFWPDF := .f.

return nil


and let us know


Yes mr. Nages, now it works.

But de quality of the typography in the PDF is not good.

I guess the best solution must be to use HaruPDF.

For now i have what i wanted, i will leave this matter for later.

Thank you so much

Re: Centrar texto VERTICALMENTE

PostPosted: Wed Apr 10, 2024 12:49 am
by nageswaragunupudi
But de quality of the typography in the PDF is not good.

Yes. Also PDF file size is large.

I guess the best solution must be to use HaruPDF.

Yes. Simple and smaller pdf file sizes.

Re: Centrar texto VERTICALMENTE

PostPosted: Wed Apr 10, 2024 1:18 am
by nageswaragunupudi
Using PRINT oPrn FILE <pdffile>, there are 3 ways to generate PDFs.

1. Using Microsoft Word, if installed on the PC.
This is the default.
Printer class generates emf files and embeds them into Word document and saves as PDF.
pros: Good quality and medium size pdfs
cons: (1) Does not support rotated text and (2) pdf document is an image and not editable.

2. Using FWH's own PDF generator.(written many years ago)
If MSWord is not installed, this is the default.
We can also force this by setting TPrinter():lUseFWPDF := .t.
cons: (1) Lesser quality (2) Large size and (3) pdf is not editable.

3. Using HaruPDF, by setting TPrinter():lUseHaruPDF := .t.
pros: (1) Smaller size. (2) Good Quality (3) pdfs are editable.
cons: (1) Does not support Unicode fonts. (Concern only for East/Middle Asian languages)
(2) Does not support Hallow Text with image brush.