Print System
Previous topic  First topic  Next topic


Marinas-GUI implements a printing system based entirely on Qt, which allows complete independence of the operating system that you use. The printing system is fully integrated with Marinas-GUI and does not require libraries to be added.
Marinas-GUI implementa un sistema para impresiones basado enteramente en Qt, lo que permite una total independencia del sistema operativo que se utilice. El sistema de impresión está totalmente integrado en Marinas-GUI y no se requiere de librerias agregadas.

The three components are

  • The logical printer that handles Marinas-GUI
  • The physical printers that are defined in the Operating System
  • The report that we will design and then print
  • .

    Los componentes son tres

  • La impresora lógica que maneja Marinas-GUI
  • La/las impresoras físicas que estan definidas en el Sistema Operativo
  • El reporte que diseñaremos para luego imprimir
  • .


    Management of the logical printer:
    Manejo de la impresora lógica:


    Before using or selecting a physical printer is advisable to perform the initialization of the logical printer using the following command:
    Antes de utilizar o seleccionar una impresora física es aconsejable realizar la inicialización de la impresora lógica mediante el siguiente comando:

    RESET PRINTER

    Note: mg_ResetPrinter() function performs the same action.
    Nota: la función mg_ResetPrinter() realiza la misma acción.

    Once initialized the logical printer, physical printer can be associated in different ways:
    Una vez inicializada la impresora lógica, podemos asociarle la impresora física de diferentes formas:

  • SELECT PRINTER TO DIALOG
  • .

    This command causes that it show the dialog printer selection of printers installed in the operating system where we work.
    Este comando provoca que se muestre el cuadro de dialogo de selección de impresoras físicas que posea el sistema operativo en donde estamos trabajando.

  • SELECT PRINTER <cPrinterName>
  • .

    This command allows us to assign the physical printer named <cPrinterName>. For a list of available physical printers the GET PRINTER LIST command can be used.
    Este comando nos permite asignar la impresora física llamada <cPrinterName>. Para obtener la lista de impresoras físicas disponibles se puede utilizar el comando GET PRINTER LIST

  • SELECT PRINTER TO DEFAULT
  • .

    This command allows us to allocate our logical printer to our physical printer assigned as default in the system.
    Este comando nos permite asignar a nuestra impresora lógica la impresora física asignada como Default en el sistema.

  • SELECT PRINTER TO PDF
  • .

    This command allows us to record our report in a PDF file instead of use a physical printer.
    Este comando nos permite grabar nuestro reporte en un archivo PDF en lugar utilizar una impresora física.

    You can activate a preview using the following command:
    Podemos activar una vista previa mediante el siguiente comando:

    SET PRINTER PREVIEW TO <.T.> | <.F.>

    Default: .F.

    Note: The mg_SetPrinterPreview ( .T. | .F. ) function performs the same action.
    Nota: la función mg_SetPrinterPreview( .T. | .F. ) realiza la misma acción.




    In addition, you can activate a rule to assist in report creation or for testing about correct coordinates setting

    Como agregado, usted puede activar una REGLA para que lo asista en la creacion del reporte o para chequear que las coordenadas codificadas son correctas

  • SET PRINTER RULE TO <.T.> | <.F.>
  • .




    Other settings for your logic printer are the following:
    Otras configuraciones para nuestra impresora lógica son las siguiente:

    Print Quality:
    Calidad de la impresión:

    SET PRINTER QUALITY TO <nQuality>

    where <nQuality> can be:
    donde <nQuality> puede ser:

  • QPrinter_ScreenResolution (Default)
  • QPrinter_PrinterResolution
  • QPrinter_HighResolution
  • .

    Note: The mg_SetPrinterQuality( nQuality ) function performs the same action.
    Nota: la función mg_SetPrinterQuality( nQuality ) realiza la misma acción.


    Paper orientation:
    Orientación del papel:

    SET PRINTER ORIENTATION TO <nOrientation>

    where <nOrientation> can be:
    donde <nOrientation> puede ser:

  • QPrinter_Portrait (Default)
  • QPrinter_Landscape
  • .

    Note: The mg_SetPrinterOrientation( nOrientation ) function performs the same action.
    Nota: la función mg_SetPrinterOrientation( nOrientation ) realiza la misma acción.


    Color printing:
    Color de la impresión:

    SET PRINTER COLORMODE TO <nColorMode>

    where <nColorMode> can be:
    donde <nColorMode> puede ser:

  • QPrinter_Color (Default)
  • QPrinter_GrayScale
  • .

    Note: The mg_SetPrinterColorMode( nColorMode ) function performs the same action.
    Nota: la función mg_SetPrinterColorMode( nColorMode ) realiza la misma acción.


    Collation checkbox Enable in the Print dialog:
    Habilitacion del checkbox de Colación en el dialogo de impresion:

    SET PRINTER COLLATE TO <nCollate>

    where <nCollate> can be:
    donde <nCollate> puede ser:

  • QPrinter_NoCollate (Default)
  • QPrinter_Collate
  • .

    Note: The mg_SetPrinterCollate( nCollate ) function performs the same action.
    Nota: la función mg_SetPrinterCollate( nCollate ) realiza la misma acción.


    Number of copies to print:
    Cantidad de copias a imprimir:

    SET PRINTER COPIES TO <nCopies>

    Note: The mg_SetPrinterCopies( nCopies ) function performs the same action.
    Nota: la función mg_SetPrinterCopies( nCopies ) realiza la misma acción.


    Printing on both sides of the sheet:
    Impresion de ambos lados de la hoja:

    SET PRINTER DUPLEX TO <nDuplex>

    where <nDuplex> can be:
    donde <nDuplex> puede ser:

  • QPrinter_DuplexAuto (Default)
  • QPrinter_DuplexLongSide
  • QPrinter_DuplexShortSide
  • .

    Note: The mg_SetPrinterDuplex( nDuplex ) function performs the same action.
    Nota: la función mg_SetPrinterDuplex( nDuplex ) realiza la misma acción.


    Paper Size:
    Tamaño del papel:

    SET PRINTER PAPERSIZE TO <nPaperSize>

    Note: The mg_SetPrinterPaperSize( nPaperSize ) function performs the same action.
    Nota: la función mg_SetPrinterPaperSize( nPaperSize ) realiza la misma acción.

    where <nPaperSize> can be (you can use the first column or the code):
    donde <nPaperSize> puede ser (se puede usar la primer columna o el código):

  • QPrinter_A0 Code: 5 Size: 841 x 1189 mm
  • QPrinter_A1 Code: 6 Size: 594 x 841 mm
  • QPrinter_A2 Code: 7 Size: 420 x 594 mm
  • QPrinter_A3 Code: 8 Size: 297 x 420 mm
  • QPrinter_A4 Code: 0 Size: 210 x 297 mm, 8.26 x 11.69 inches
  • QPrinter_A5 Code: 9 Size: 148 x 210 mm
  • QPrinter_A6 Code: 10 Size: 105 x 148 mm
  • QPrinter_A7 Code: 11 Size: 74 x 105 mm
  • QPrinter_A8 Code: 12 Size: 52 x 74 mm
  • QPrinter_A9 Code: 13 Size: 37 x 52 mm
  • QPrinter_B0 Code: 14 Size: 1030 x 1456 mm
  • QPrinter_B1 Code: 15 Size: 728 x 1030 mm
  • QPrinter_B2 Code: 17 Size: 515 x 728 mm
  • QPrinter_B3 Code: 18 Size: 364 x 515 mm
  • QPrinter_B4 Code: 19 Size: 257 x 364 mm
  • QPrinter_B5 Code: 1 Size: 182 x 257 mm, 7.17 x 10.13 inches
  • QPrinter_B6 Code: 20 Size: 128 x 182 mm
  • QPrinter_B7 Code: 21 Size: 91 x 128 mm
  • QPrinter_B8 Code: 22 Size: 64 x 91 mm
  • QPrinter_B9 Code: 23 Size: 45 x 64 mm
  • QPrinter_B10 Code: 16 Size: 32 x 45 mm
  • QPrinter_C5E Code: 24 Size: 163 x 229 mm
  • QPrinter_Comm10E Code: 25 Size: 105 x 241 mm, U.S. Common 10 Envelope
  • QPrinter_DLE Code: 26 Size: 110 x 220 mm
  • QPrinter_Executive Code: 4 Size: 191 x 254 mm, 7.5 x 10 inches
  • QPrinter_Folio Code: 27 Size: 210 x 330 mm
  • QPrinter_Ledger Code: 28 Size: 432 x 279 mm
  • QPrinter_Legal Code: 3 Size: 216 x 356 mm, 8.5 x 14 inches
  • QPrinter_Letter Code: 2 Size: 216 x 279 mm, 8.5 x 11 inches
  • QPrinter_Tabloid Code: 29 Size: 279 x 432 mm
  • QPrinter_Custom Code: 30 Size: Unknown, or a user defined size
  • .

    The command GET PRINTER PAPERSIZE LIST TO aList
    or
    the function
    mg_GetPrinterPaperSizeList()
    returns a 6-dimensional vector with the list above and the following structure:
    { "Name" , "Code" , "Width in Millimeters" , "Height in Millimeters" , "Width in Inchs" , "Height in Inchs" }

    El comando GET PRINTER PAPERSIZE LIST TO aList
    o
    la funcion
    mg_GetPrinterPaperSizeList()
    nos devuelve un vector de 6 dimensiones con el listado precedente y la siguiente estructura:
    { "Name" , "code" , "Width in Millimeters" , "Height in Millimeters" , "Width in Inchs" , "Height in Inchs" }


    Note: All values are of character type , even those that contain only numbers.
    Nota: todos los valores son de tipo caracter, aún los que contienen solo números.


    If you use set QPrinter_Custom as paper size you need set Width and Height page with:
    Si usted codifica un tamaño de papel QPrinter_Custom, tambien necesitará especificar el ancho y alto del papel mediante:

    SET PRINTER CUSTOMPAPERSIZE TO <nWidth> , <nHeight>
    or
    mg_SetPrinterCustomPaperSize( <nWidth> , <nHeight> )

    e.g.:

    SET PRINTER PAPERSIZE to QPrinter_Custom
    SET PRINTER CUSTOMPAPERSIZE to 50 , 80



    Set margins:
    Establecer margenes:

    SET PRINTER MARGIN LEFT TO <nMargen>

    SET PRINTER MARGIN TOP TO <nMargen>

    SET PRINTER MARGIN RIGHT TO <nMargen>

    SET PRINTER MARGIN BOTTOM TO <nMargen>


    Note: The following functions perform the same action:
    Nota: las siguientes funciones realizan la misma acción:
    mg_SetPrinterMarginLeft( nValue )
    mg_SetPrinterMarginTop( nValue )
    mg_SetPrinterMarginRight( nValue )
    mg_SetPrinterMarginBottom( nValue )



    Set units of measurement:
    Establecer unidades de medidas:

    SET PRINTER UNITS TO <nUnits>

    where <nUnit> can be:
    donde <nUnit> puede ser:

  • QPrinter_Millimeter (Default)
  • QPrinter_Point
  • QPrinter_Inch
  • QPrinter_Pica
  • QPrinter_Didot
  • QPrinter_Cicero
  • QPrinter_DevicePixel
  • .

    Note: The mg_SetPrinterUnits( nUnits ) function performs the same action.
    Nota: la función mg_SetPrinterUnits( nUnits ) realiza la misma acción.

    The full list of functions related to printing are on topic Functions and Settings
    La lista completa de funciones relacionadas con impresiones se encuentra en el tópico Functions and Settings


    Report Management:
    Manejo del Reporte:


    It handles the concept of the report to create sheets to print:
    Se maneja el concepto de reporte para armar la o las hojas a imprimir:

    CREATE REPORT
       ...
       ...
       ...
    END REPORT


    Inside the report we can create pages as follows:
    Dentro del reporte podemos crear páginas de la siguiente manera:

    CREATE REPORT
       ...
       CREATE PAGEREPORT
          ...
       END PAGEREPORT
       CREATE PAGEREPORT
          ...
       END PAGEREPORT
       CREATE PAGEREPORT
          ...
       END PAGEREPORT
       CREATE PAGEREPORT
          ...
       END PAGEREPORT
       ...
    END REPORT


    Inside the pages will use the PRINT command to add text, shapes, barcodes and images to the report
    Dentro de las páginas usaremos el comando PRINT para agregarle texto, figuras geométricas, códigos de barras o imagenes al reporte

    [ CREATE ] PRINT [ TEXT ] "hello"
    ...
    END PRINT


    or

    [ CREATE ] PRINT LINE
    ...
    END PRINT


    or

    [ CREATE ] PRINT RECTANGLE
    ...
    END PRINT


    or

    [ CREATE ] PRINT ELLIPSE
    ...
    END PRINT


    or

    [ CREATE ] PRINT BARCODE "TextForBarcode"
    ...
    END PRINT


    or

    [ CREATE ] PRINT IMAGE "image.png"
    ...
    END PRINT


    Each of these commands has properties that can be used. Go to the topic Report Inside Controls for more information and to see a fully functional example.
    Cada uno de estos comandos tiene propiedades que pueden ser utilizadas. Vaya al tópico Report dentro de Controles para mas informacion y para ver un ejemplo completo y funcional.

    Finally, the report can be run (ie, send to print), by the following command:
    Finalmente, el reporte se puede ejecutar (o sea, enviar a imprimir), mediante el siguiente comando:

    EXEC REPORT <myReport_1> [ RETO <lSuccess> ]

    If you wish to discard the report to recover memory or because no longer going to be used, you can use the following command:
    Si se desea desechar el reporte para recuperar memoria o porque ya no va a ser utilizado, se puede emplear el siguiente comando:

    DESTROY REPORT <myReport_1>


    APPENDIX:
    APENDICE:


    An abbreviated format exist for the command PRINT TEXT to facilitate the encoding:
    Para el comando PRINT TEXT existe un formato abreviado para facilitar la codificacion:

    @ <nRow> , <nCol> PRINT <cText> [ PROPERTY1 <xProperty1> ] ... [ PROPERTYn <xPropertyn> ]

    The counterpart of this format is that not have the benefits explained in the topic Syntax of Best Practices chapter
    La contra de este formato es que no se tienen las ventajas explicadas en el tópico Sintaxis del capítulo Best Practices

    Here you have a complete example (look at gui/doc/d_report_fast.mip):
    Aqui tiene un ejemplo completo (look at gui/doc/d_report_fast.mip to compile it):

    #include "marinas-gui.ch"

    Function main()

       CREATE WINDOW d_window
          CAPTION "Marinas-GUI Sample for Report Control"
          MAIN .T.
          ONINIT myReport()

          CREATE LABEL L1
             ROW 10
             COL 10
             VALUE "Working..."
          END LABEL

       END WINDOW

       mg_Do( "d_window" , "center" )

       mg_Do( "d_window" , "activate" )

    Return .T.

    Function myReport()
       LOCAL nInx , nRow , nLine

       SET PRINTER PREVIEW TO .T.

       CREATE REPORT myReport_1

          CREATE STYLEFONT StyleFont_1
             FONTSIZE 9
             FONTNAME "mg_monospace"
          END STYLEFONT

          CREATE STYLEPEN StylePen_1
             PENWIDTH 1
             COLOR {0,0,255}
          END STYLEPEN

          SET STYLEFONT TO "StyleFont_1"
          SET STYLEPEN TO "StylePen_1"

          CREATE PAGEREPORT

             nRow := 5
             nLine := 0
             for nInx := 1 to 1000   // Total Lines
                if nLine == 100      // Lines x Page
                   NEWPAGEREPORT
                   nRow := 5
                   nLine := 0
                endif
                nRow := nRow + 2.8
                nLine := nLine + 1
                @ nRow , 20 print "This is a test line number " + mg_allStr( nInx ) FONTNAME "mg_normal" FONTCOLOR { nLine , 255-nLine , 0 }
             next

          END PAGEREPORT

       END REPORT

       EXEC REPORT myReport_1

       DESTROY REPORT myReport_1

       RELEASE WINDOW ( "d_window" )

    Return NIL





    Marinas-GUI Version 03.06 and
    Marinas-IDE Version 05.06 and
    LEX Files Version 02.06


    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    last update: April 27
    2017
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




    A Harbour/QT framework to make multiplatform programs

    (©) Copyright 2009-2017 by Fernando Santolin (aka CarozoDeQuilmes)
    CarozoDeQuilmes@gmail.com

    2009-2017 Beta tester and full English translator: Bruno Luciani
    Bruno.Luciani@gmail.com

    2014-2015 Final English corrector: David Worboys
    DavidWorboys@hotmail.com

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    www.marinas-gui.org


    www.marinas-gui.org  

    Previous topic  First topic  Next topic