Centrar texto VERTICALMENTE

Centrar texto VERTICALMENTE

Postby FiveWiDi » Mon Apr 08, 2024 10:45 pm

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
Un Saludo
Carlos G.

FiveWin 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1202
Joined: Mon Oct 10, 2005 2:38 pm

Re: Centrar texto VERTICALMENTE

Postby nageswaragunupudi » Tue Apr 09, 2024 3:49 am

Please try this sample program
Code: Select all  Expand view  RUN
#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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Centrar texto VERTICALMENTE

Postby FiveWiDi » Tue Apr 09, 2024 2:10 pm

[quote="nageswaragunupudi"]Please try this sample program
Code: Select all  Expand view  RUN
#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.
Un Saludo
Carlos G.

FiveWin 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1202
Joined: Mon Oct 10, 2005 2:38 pm

Re: Centrar texto VERTICALMENTE

Postby FiveWiDi » Tue Apr 09, 2024 3:28 pm

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,
Un Saludo
Carlos G.

FiveWin 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1202
Joined: Mon Oct 10, 2005 2:38 pm

Re: Centrar texto VERTICALMENTE

Postby nageswaragunupudi » Tue Apr 09, 2024 4:05 pm

Please try this way
Code: Select all  Expand view  RUN
#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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Centrar texto VERTICALMENTE

Postby karinha » Tue Apr 09, 2024 4:06 pm

Mira se ayuda:

Code: Select all  Expand view  RUN

// 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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Centrar texto VERTICALMENTE

Postby nageswaragunupudi » Tue Apr 09, 2024 4:49 pm

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  RUN
@ 0, 0 PRINT TO oPrn TEXT "Single/MultiLine Text" ALIGN "" FONT oFont

It's that simple.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Centrar texto VERTICALMENTE

Postby nageswaragunupudi » Tue Apr 09, 2024 4:58 pm

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Centrar texto VERTICALMENTE

Postby karinha » Tue Apr 09, 2024 5:17 pm

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Centrar texto VERTICALMENTE

Postby nageswaragunupudi » Tue Apr 09, 2024 6:08 pm

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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Centrar texto VERTICALMENTE

Postby FiveWiDi » Tue Apr 09, 2024 7:07 pm

nageswaragunupudi wrote:Please try this way
Code: Select all  Expand view  RUN
#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
Un Saludo
Carlos G.

FiveWin 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1202
Joined: Mon Oct 10, 2005 2:38 pm

Re: Centrar texto VERTICALMENTE

Postby nageswaragunupudi » Wed Apr 10, 2024 12:49 am

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Centrar texto VERTICALMENTE

Postby nageswaragunupudi » Wed Apr 10, 2024 1:18 am

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 94 guests