SELECT PRINTER DIALOG

HMG en Español

Moderator: Rathinagiri

User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

SELECT PRINTER DIALOG

Post by SALINETAS24 »

Hola a todos

Una pregunta., si utilizo el código

Code: Select all

		SELECT PRINTER DIALOG  ;
			TO lSuccess ;
			PREVIEW

como puedo saber el tipo de papel, tamaño y orientación ???

Muchas gracias
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: SELECT PRINTER DIALOG

Post by AUGE_OHR »

hi,

some weeks ago we had a Problem that Image of PDF are not Print.

Sample have

Code: Select all

SELECT PRINTER DIALOG TO lSuccess PREVIEW
and there you can select Landscape / Portrait.

so i´m not sure what you mean. did you have a Snapshot or some Code :?:
have fun
Jimmy
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: SELECT PRINTER DIALOG

Post by SALINETAS24 »

AUGE_OHR wrote: Mon May 10, 2021 10:42 am hi,

some weeks ago we had a Problem that Image of PDF are not Print.

Sample have

Code: Select all

SELECT PRINTER DIALOG TO lSuccess PREVIEW
and there you can select Landscape / Portrait.

so i´m not sure what you mean. did you have a Snapshot or some Code :?:
Hola AUGE, gracias por contestar.

¿como puedo saber la selección del usuario.., si es Landscape / Portrait ?
¿como puedo saber el tipo de papel seleccionado por el usuario...., A4, A3, A4... ETC..?

Gracias
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: SELECT PRINTER DIALOG

Post by AUGE_OHR »

hi,

i got this
PrintDialog.jpg
PrintDialog.jpg (48.25 KiB) Viewed 1794 times
have fun
Jimmy
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: SELECT PRINTER DIALOG

Post by franco »

Maybe this,

Code: Select all

SELECT PRINTER DIALOG TO lSuccess PREVIEW ;
ORIENTATION   PRINTER_ORIENT_PORTRAIT ;
PAPERSIZE       PRINTER_PAPER_LETTER ;      //I have never used  PAPERSIZE A4 or A5 etc:
QUALITY         PRINTER_REZ_MEDIUM
All The Best,
Franco
Canada
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: SELECT PRINTER DIALOG

Post by dragancesu »

Look file:///C:/hmg344/DOC/data/index.htm

at end you can see

New Functions:
OpenPrinterGetDC() --> hDC of the current Open Printer
OpenPrinterGetPageDC() --> hDC of the current Page being printed
IsPrintPageMetaFile() --> lBoolean
OpenPrinterGetPageWidth() --> Width (in millimeters) of the current Page being printed
OpenPrinterGetPageHeight() --> Height (in millimeters) of the current Page being printed

maybe this help
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: SELECT PRINTER DIALOG

Post by SALINETAS24 »

dragancesu wrote: Mon May 10, 2021 5:15 pm Look file:///C:/hmg344/DOC/data/index.htm

at end you can see

New Functions:
OpenPrinterGetDC() --> hDC of the current Open Printer
OpenPrinterGetPageDC() --> hDC of the current Page being printed
IsPrintPageMetaFile() --> lBoolean
OpenPrinterGetPageWidth() --> Width (in millimeters) of the current Page being printed
OpenPrinterGetPageHeight() --> Height (in millimeters) of the current Page being printed

maybe this help
Efectivamente, con OpenPrinterGetPageWidth() y OpenPrinterGetPageHeight() obtengo el ancho y largo en milimetros.., pero esto es una cuestion para los de la vieja escuela....

¿cuantos caracteres puedo imprimir a lo ancho, (columnas)...?
¿cuantas líneas (filas) puedo imprimir a lo largo..?

Un papel normal, por ejemplo A4, tiene aproximadamente 80 columnas por 66 filas..., entonces en un LISTADO o INFORME con un contador, cuando llego a 60 lineas fuerzo el salto de página ....

¿pero que pasa si el usuario cambia en la Opcion que dice "AUGE" cambia de A4 por A5 o por LEGAL, EXECUTIVE... ETC.?

Como puedo saber yo las lineas que puedo imprimir en el INFORME..?

Imaginemos el siguiente codigo... tengo que hacer un listado

Code: Select all

LOCAL nCabecera:=0
START PRINTDOC
   
   FOR nPagina := 1 TO nPaginas
         
      START PRINTPAGE
        
         
         FOR nLinea :=01 TO nLinsPag
         
               	IF nCabera:=0
      		        nCabecera:=1
      	         	PoneCabecera() 
      	         	nRowLin :=10
         	ENDIF

            @ nRowLin,nMargen PRINT aLineas[ nLinNew ] ;
            FONT "Courier New" SIZE 09 
               
               // --- COMPROBAMOS SALTO DE PAGINA
               nRowLin ++
               IF nRowLin > 60    // ¿QUE LINEAS ..A4, A5, LEGAL, EXECUTIVE, APLISADO, NORMAL...?  <<-------- aqui
                           IF( nLinNew ==nLineas, nLinea :=nLinsPag,)
                          END PRINTPAGE
	                  START PRINTPAGE
               ENDIF

         NEXT
         
      END PRINTPAGE
      
   NEXT
   
END PRINTDOC

FUNC PoneCabecera()
         @ nRowIni,nMargen PRINT "Pagina N° " +;
         STRZERO(nPagina ,03) + " De "           +;
         STRZERO(nPaginas,03) FONT "Courier New" SIZE 10
RETURN

Esta condición

Code: Select all

 IF nRowLin > 60 
 
debería de cambiar su valor dependiendo del tipo de papel para hacer correctamente el salto de página...

No se si me explico correctamente.
Gracias a todos por vuestra colaboración.
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: SELECT PRINTER DIALOG

Post by CalScot »

For characters per line, that's much easier to do if you are using a fixed-width font (Courier or Times Roman, for example. That you say "80 across" suggests that you might be using one of these). If you are using a variable width (kerned) font, it becomes more a complicated calculation to get accurate widths,
For both "lines per page" and "characters per line", I would do a "case" (or an elseif) that has the widths and line counts for each paper option that the user could select or use.
Sorry if these answers are too simplistic and I'm missing exactly what your problem is, but I hope it helps.
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: SELECT PRINTER DIALOG

Post by franco »

I have trouble with your variables. When I do this, at start very simple.

Code: Select all

Local nLine  := 10, nPage := 1    // in code

IF nLine > 60
    @ nLine+1 ,nMargen PRINT "Pagina N° " + Str(nPage,3,0)
    nPage := nPage+1
    Nline := 10
    END PRINTPAGE
    START PRINTPAGE
    NEXT
ENDIF
      // Continue
All The Best,
Franco
Canada
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: SELECT PRINTER DIALOG

Post by AUGE_OHR »

hi,
SALINETAS24 wrote: Mon May 10, 2021 7:19 pm

Code: Select all

            @ nRowLin,nMargen PRINT aLineas[ nLinNew ] ;
            FONT "Courier New" SIZE 09 
you can calculate Width of each line, depend on Font, this Way which i found in PDFVIEW ( Sumatra )

Code: Select all

FUNCTION GetWindowTextWidth( nHWnd, cText, lNoPrefix )
LOCAL nW     := 0
LOCAL nHDC   := GetDC( nHWnd )
LOCAL nHFont := GetWindowFont( nHWnd )
LOCAL aText
LOCAL n
   DEFAULT lNoPrefix TO .F.
   IF !HB_IsString( cText )
      cText := GetWindowText( nHWnd )
   ENDIF
   IF lNoPrefix == .T.
      cText := HB_UTF8StrTran( cText, "&", "", 1, 1 )
   ENDIF
   aText := HB_aTokens( cText, .T. /*lEOL*/ )
   FOR n := 1 TO LEN( aText )
      nW := MAX( nW, GetTextWidth( nHDC, aText[ n ], nHFont ) )
   NEXT
   ReleaseDC( nHWnd, nHDC )
RETURN nW
---

Code: Select all

IF > 60
you have to check Printer with HB_FUNC (GETDEFAULTPRINTER)
if it is not "your" Printer you have to ask for Printer Property

use GetTextHeight(), depend on Font, to "calculate" Vertical used Space (also from PDFVIEW )

Code: Select all

FUNCTION GetWindowTextHeight(nHWnd, cText)
  LOCAL nHDC := GetDC(nHWnd)
  LOCAL nH

  IF ! HB_IsString(cText)
    cText := GetWindowText(nHWnd)
  ENDIF

  nH := GetTextHeight(nHDC, cText, GetWindowFont(nHWnd)) * HB_TokenCount(cText, .T. /*lEOL*/)
  ReleaseDC(nHWnd, nHDC)

RETURN nH
---

i prefer to have a Setup in my App which Printer will be used
HB_FUNC (APRINTERS) will give you that Array of Printer Name which can be used on that PC

i do NOT let User "change" Printer in App as all Report are "fixed" on used Paperform.

even if you have set "A4" as Paperform you still have limitation most on Bottom where Footerline is "cut off"
i do all this in my App Setup so i can change it quick when "my" Printer output look different as Customer Printer Output

p.s. how do you specify the Printer Paper Slot when i use different forms ( have 2 x Slot for Paper ) :idea:
have fun
Jimmy
Post Reply