Unit TbPrint |
Classes |
TPrintPreview -
TTbExcel - if Assigned(FOnEndGroup) then FOnEndGroup(FinGrupo);
TTbPrinter -
TTbReport -
TTbReportColumn -
TTbReportGroup -
Functions |
Register - Published declarations
Types |
PEscritura
PHorizLine
PPagina
PVertLine
ReportFieldType
ReportTableType
TEscritura
TFuente
THorizLine
TInitialZoom
TLinea
TModelo
TPagina
TPrinterMode
TStatus
TTbEndGroupEvent
TTbEndQueryEvent
TTbGetTextEvent
TTipoFuente
TVertLine
Constants |
Variables |
Functions |
Types |
PEscritura = ^TEscritura
PHorizLine = ^THorizLine
PPagina = ^TPagina
PVertLine = ^TVertLine
ReportFieldType = TFieldTTbTable
ReportTableType = TTable------------------------------------------------------------------------- Fecha: 24/2/1998 Versión: 0.90 Autor: Horacio Jamilis E-Mail: jhoracio@cvtci.com.ar Documentado primero en Español y luego en Ingles. Documented in Spanish first and next in English (or something like that). ------------------------------------------------------------------------- Este es un componente que permite utilizar la impresora con una impresión rápida similar a DOS o con la mismo contenido imprimir utilizando un driver de Windows. ------------------------------------------------------------------------- Este componente es de libre distribución en tanto no se modifique. Puede ser utilizado libremente en software freeware. Para poder ser utilizado en otro tipo de software (shareware, comercial, etc.) debe ser registrado con un valor de $ 15.- De cualquier manera no existen garantías de que el componente funcione en todas las circunstancias. Uselo a su cuenta y riesgo. -------------------------------------------------------------------------- Comentarios, alabanzas y agradecimiento enterno,... serán bien recibidos. -------------------------------------------------------------------------- This component let's you use the printer like you did in DOS or send the same information through the Windows driver. -------------------------------------------------------------------------- This component could be freely distributed while not modified. You could use it freely in any freeware software. To use it in any other type of software (shareware, comercial, etc.) you should register it in u$s 15.- Any way, there are not warranties about the way the component works in all the cases. Use it at your own risk. -------------------------------------------------------------------------- ========================================================================== DESCRIPCION DEL CONJUNTO DE COMPONENTES ========================================================================== TTbPrinter: es el componente que se ocupa de las comunicaciones con la impresora o driver de impresion de Windows. Usted puede mandar un conjunto de lineas de texto a imprimir y este componente se ocupara de que lleguen al papel de la manera apropiada. Propiedades: CompanyData: Es una linea de texto utilizada en todos los reportes enviados por esta impresora (lo usa TTbReport). Copies: es la cantidad de copias que se imprimiran del trabajo. FastFont: Es la tipografía de la impresora utilizada por default, se puede utilizar: Normal = [], Negrita, Italica, Subrayada, Comprimida o cualquier combinacion de ellas. FastPort: es el puerto de impresión al que esta conectada la impresora (ej: 'LPT1') FastPrinter: es el modelo de su impresora cuando se saltea el driver de Windows y se escribe directamente al puerto de impresión (igual que en DOS) Mode: es la forma de funcionamiento del componente, pmFast = envia el texto directamente al puerto de la impresora sin activar el controlador de impresión de Windows (haciendo la impresion más rápida) pmWindows = utilizando el controlador de impresión de Windows (logrando compatibilidad con virtualmente cualquier tipo de impresora. Preview: Establezcalo en True para ver una presentación preliminar antes de imprimir o en False para evitar que aparezca e imprima directamente. Title: Es la linea de texto que describe el trabajo en el controlador de impresión cuando se utiliza la modalidad pmWindows. WinPort: es el nombre del puerto de impresion al imprimir en modo pmWindows. WinPrinter: Es el nombre de la impresora de Windows que se va a utilizar en el modo pmWindows. Zoom: Es el nivel de ampliación inicial al aparecer la ventana de presentación preliminar. Puede ser zReal, zWidth (Ancho de hoja) o zHeight (Alto de hoja). Columnas: (solo lectura) Cantidad de columnas de la pagina (80) Paginas: (solo lectura) Cantidad de paginas en el buffer PrintingWidth: (solo lectura) es el ancho de la pagina PrintingHeight: (solo lectura) es el alto de la página Eventos: OnPrinterError: es un evento que se genera al fallar el intento de impresión dandole al usuario una oportunidad de cambiar el mensaje de error. Metodos: Comenzar: se debe utilizar para comenzar una nueva impresión. Crea la primer página. Sintaxis: Comenzar; Finalizar: se debe utilizar al finalizar una impresión. Elimina su información del buffer. Sintaxis: Finalizar; EscribirStd: Escribe en la columna X, linea Y el TEXTO con la fuente especificada en FastFont. Sintaxis: EscribirStd(X,Y,TEXTO); Escribir: Escribe TEXTO en la linea Y, columna X con la fuente FUENTE. Sintaxis: Escribir(X,Y,TEXTO,FUENTE); Cuadro: Realiza un cuadro en la hoja (solo funciona en modo pmFast) con las coordenadas especificadas y el tipo de linea que puede ser Simple o Doble. Sintaxis: Cuadro(X1,Y1,X2,Y2,TIPOLINEA); LineaHorizontal: realiza una linea horizontal segun las coordenadas y el tipo de linea. Sintaxis: LineaHorizontal(X1,X2,Y,TIPOLINEA); LineaVertical: realiza una linea vertical segun las coordenadas y el tipo de linea. Sintaxis: LineaVertical(X,Y1,Y2,TIPOLINEA); Imprimir: Envia la impresion a la impresora. Si Preview es verdadero realiza la presentación preliminar. Si es falso envia la impresión a la impresora directamente si el modo es pmFast, o a traves del driver de Windows si es pmWindows. Sintaxis: Imprimir; NuevaPagina: Crea una nueva pagina (no se debe utilizar inmediatamente despues de comenzar) Sintaxis: NuevaPagina; SetModeloName: Establece el modelo de la impresora para el modo pmFast por su nombre. Sintaxis: SetModeloName(NOMBRE); GetModeloName: Devuelve el nombre del modelo de impresora seleccionado para el modo pmFast. Sintaxis: GetModeloName; GetModelos: Completa una lista de cadenas (TStrings) con los nombres de los modelos disponibles para el modo pmFast. Se utiliza para darle al usuario la posibilidad de seleccionar su modelo de impresora. Sintaxis: GetModelos(LISTADEMODELOS); ========================================================================== TTbReport: Genera un listado utilizando un TTbPrinter y posiblemente una TTable. Tambien tiene la posibilidad de enviarlo a Microsoft Excel. Propiedades: Printer: es la impresora en la que va a salir el reporte (TTbPrinter) Tabla: es la tabla de la que saldran los datos si la informacion proviene de una TTable. TablaFiltro: el un filtro para la tabla (opcional). Si no se establece se utiliza el filtro activo. TablaIndice: es el nombre del indice de la tabla utilizado durante la generación del reporte (opcional). Si no se establece se utiliza el indice activo. Lineas: es la cantidad de lineas por hoja del reporte. MargenDerecho: Es la posicion del margen derecho (depende de la tipografia) MargenIzquierdo: Es la posicion del margen izquierdo. NumerarPaginas: si se desea imprimir el numero de página en cada pagina. EscribirFechaHora: si se desea que se imprima la fecha y hora de generacion del reporte en cada pagina. SeparacionDeColumnas: es la distancia deseada entre las columnas (en caracteres). Titulo: es el titulo del reporte. Aparece al principio de cada hoja y, en modo pmWindows, en la lista de trabajos pendientes de la impresora. Antes del titulo aparece la linea CompanyData establecida en la impresora. LineaDeTitulo: es la linea de la hoja en la que aparece el titulo. SubTitulo: es el subtitulo del reporte. Aparece en cada hoja. LineaDeSubtitulo: es la linea de la hoja en que aparecera el subtitulo. ColumnaDeTitulo: es la columna en que comienza el titulo en la pagina. ColumnaDeSubtitulo: es la columna en que comienza el subtitulo en la pagina. ColumnaDePieDePagina: es la columna en que comienza el pie de pagina. PieDePagina: es el texto que aparece al pie de cada pagina. Fuente: la tipografia para el reporte (FastFont) Preview: Si se desea que se vea una presentacion preliminar antes de imprimir. TablaAutoFirst: Si se desea que el reporte utilice todos los registros de la tabla. ModoImpresion: el modo de impresion que utilizara la impresora (pmFast o pmWindows) Eventos: OnEndQuery: se genera despues de imprimir cada linea para ver si es la última o hay mas información. Indispensable para reportes no basados en tablas. Metodos: Execute: genera el repote y lo muestra en la pantalla (si preview esta activo) o lo imprime (en otro caso). ExportToExcel: envia el repote a una planilla en Microsoft Excel. ========================================================================== TTbReportColumn: columna de reporte para TTbReport. Los reportes estan compuestos por columnas de información. Deberá poner un objeto de estos por cada columna que desee incluir en el reporte. Propiedades: Indice: Numero de columna. La columna que tiene el indice más chico va a la izquierda. La columna con indice 1 es la primer columna del reporte. Si no se asigna a ningun reporte vale 0 (cero). Reporte: es el reporte del que forma parte (TTbReport). Titulo: es el titulo de la columna en el reporte. Si no se establece un titulo y se establece un campo de la tabla, se usara el titulo del campo. Ancho: es el ancho de la columna en caracteres SumaColumna: establece si desea un total de todos los registros procesados. Formato: es un formato para el campo si proviene de una TTable. Eventos: OnGetText: se genera antes de imprimir el contenido del campo. Si la columna recibe informacion de una tabla contendrá al ejecutarse este evento el valor del campo para el registro que se esta procesando. Aquí puede modificar ese valor. Si la impresión no proviene de una tabla, aquí debe establecer el texto que se va a imprimir en esta columna. ========================================================================== TTbReportGroup: Grupo para el reporte TTbReport. Si desea que la impresión realice agrupaciones debe utilizar este componente para ello. Propiedades: Indice: es el orden del grupo dentro del reporte. Si no tiene asignado reporte valdra 0 (cero). Reporte: es el reporte al que afectará. SaltaDeHoja: si desea que al cambiar de grupo se salte a una nueva hoja. TextoEncabezado: texto del encabezado de cada nuevo grupo. CampoClaveDeAgrupacion: nombre del campo que sera la clave de agrupación. Totaliza: si desea tomar totales para el grupo. FormatoTotal: Formato de impresión del total. Titulo: Titulo del grupo. Eventos: OnEndGroupQuery: se genera al completar un grupo. ========================================================================== TTbExcel: componente que permite facilmente enviar datos a Excel (utilizado por TTbReport) Metodos: Connect: establece la comunicacion con Excel. Si lo logra devuelve True. Disconnect: concluye la comunicacion con Excel. StartExport: comienza el envio de informacion a Excel. EndExport: finaliza el envio de informacion a Excel. Seleccionar: selecciona un conjunto de celdas de Excel. Sintaxis: Seleccionar(X1,Y1,X2,Y2); Alinear: Alinea la celda seleccionada de acuerdo al parametro tipo byte. Sintaxis: Alinear(ALINEACION); SetStr: Establece el contenido de una celda. Sintaxis: SetStr(X,Y,TEXTO) AnchoColumna: Establece el ancho de la/s columna/s seleccionada/s. ========================================================================== ========================================================================== COMPONENT SET DESCRIPTION ========================================================================== TTbPrinter: this is the component that takes care of the communication with the printer or the Windows printer driver. You could send a couple of text lines for printing and this component will take care that this be on the paper in the way you want. Properties: CompanyData: Is a text line used in all the reports sent throw this printer (by TTbReport). Copies: is the number of copies that will print of this job. FastFont: is the printer font for default. You could use: Normal = [], Negrita (Bold), Italica (italic), Subrayada (subscript), Comprimida (compressed) or any other combination of them. FastPort: is the printer port on which the printer is connected to (ej: 'LPT1'). FastPrinter: is the printer model when used the component in pmFast mode bypassing Windows and writing directly the de printer port (as you do in DOS). Mode: is the way the component works, pmFast = sends the text directly to de printer port, not using the Windows printer driver (making the printing faster). pmWindows = using the Windows printer driver (having compatibility with virtually any type of printer). Preview: set it to True to see a print preview before printing or to False if you don't want it, and prefer to print directly. Title: is a text line wich describes the job in the Windows printer spooler when use the pmWindows mode. WinPort: is the name of the printer port when printing in pmWindows mode. WinPrinter: is the name of the printer when printing in pmWindows mode. Zoom: is the initial zoom level when showing the print preview form. It could be zReal, zWidth (Page Width) o zHeight (Page Height). Columnas: (read only) Number of character columns on the page (80). Paginas: (read only) Number of pages in the buffer. PrintingWidth: (read only) is the page Width. PrintingHeight: (read only) is the page Height. Events: OnPrinterError: it works when fails a printer try giving the user the oportunity to change de error message. Methods: Comenzar: you should call it to start a new job. It creates the first page.. Sintaxis: Comenzar; Finalizar: you should call it to end the job (after printing). It cleans the buffer. Sintaxis: Finalizar; EscribirStd: Writes in the column X, line Y the TEXT with the font especified in FastFont. Sintaxis: EscribirStd(X,Y,TEXT); Escribir: Writes TEXT in the line Y, column X with the fastfont FONT. Sintaxis: Escribir(X,Y,TEXT,FONT); Cuadro: Writes a rect on the page (only works in pmFast mode) using the coordinates and the line type (Simple -single- o Doble -double-) especified. Sintaxis: Cuadro(X1,Y1,X2,Y2,LINETYPE); LineaHorizontal: writes an horizontal line using the coordinates and line type. Sintaxis: LineaHorizontal(X1,X2,Y,LINETYPE); LineaVertical: writes a vertical line. Sintaxis: LineaVertical(X,Y1,Y2,LINETYPE); Imprimir: Sends the printing to the printer. If Preview is True shows the print preview form. Else sends the printing directly to the printer (if mode is pmFast) or to the Windows driver (if mode is pmWindows). Sintaxis: Imprimir; NuevaPagina: Creates a new page (you shouldn't use it inmediatelly next to Comenzar) Sintaxis: NuevaPagina; SetModeloName: Sets the printer model for the pmFast mode by name. Sintaxis: SetModeloName(NAME); GetModeloName: Returns the selected printer model name for de pmFast mode. Sintaxis: GetModeloName; GetModelos: Fill a string list (TStrings) with the model names availables for the pmFast mode. It is used to give the user the posibility to select his/her printer model. Sintaxis: GetModelos(MODELSLIST); ========================================================================== TTbReport: Generates a report using a TTbPrinter and posibly a TTable. It has also the hability to send it to Microsoft Excel. Properties: Printer: is the printer on which the report will goes out (TTbPrinter) Tabla: is the TTable from where the information comes if used one. TablaFiltro: is a table filter (optional). If you don't set one will use the actual filter. TablaIndice: is the table index name used while generating the report (opcional). if you don't set it is used the actual one. Lineas: is the number of lines per page for the report. MargenDerecho: is the right margin position in characters (depends of font). MargenIzquierdo: is the left margin position. NumerarPaginas: if you want to print the page number on each page. EscribirFechaHora: if you want to print the generation date and time in each page. SeparacionDeColumnas: is the distance between columns (in characters). Titulo: is the report title. Apears at the begining of each page and, in pmWindows mode, in the pending jobs list for the printer spooler. Before the title apears the text set in CompanyData for the printer. LineaDeTitulo: is the line of the page where goes the title. SubTitulo: is the report subtitle. Goes in each page. LineaDeSubtitulo: is the line of the page where goes the subtitle. ColumnaDeTitulo: is the page column where goes the title. ColumnaDeSubtitulo: is the page column where goes the subtitle. ColumnaDePieDePagina: is the page column where goes the foot page. PieDePagina: is the foot page text which goes on every page. Fuente: is the fonr used in the report (FastFont) Preview: if you want to see the print preview form before printing. TablaAutoFirst: if you want to include all the table records (or only the records that comes after the actual one). ModoImpresion: is the printer mode used for this report (pmFast o pmWindows). Events: OnEndQuery: ir works after printing each line to ask if this is the last one or not. Useful when writing reports not based on tables. Methods: Execute: generates the report and then shows it on the screen (if preview is set) or sends it to the printer (if not). ExportToExcel: sends the report to a Microsoft Excel work sheet. ========================================================================== TTbReportColumn: is a report column for TTbReport. The reports are made with information columns. You should put one object of this for each column you wish to include in the report. Properties: Indice: Column number. The column that has the littier number goes to the left. The column with index 1 is the first one (on the left). If you don't assing a report it's value is 0 (zero). Reporte: is the report the column is part (TTbReport). Titulo: is the column report title. If you don't set one and set a Table Field, it will use it's field title. Ancho: is the column width in characters. SumaColumna: if you want to sum the column. Formato: is the format to the field used when Table Field is set. Events: OnGetText: it works before sending the information to the printer. If the column has it's information from a table it will have when running this events the field value for the current record. Here you could change that value. If the printing doesn't come from e table, here you must set the text that the column will print. ========================================================================== TTbReportGroup: Grupo para el reporte TTbReport. Si desea que la impresión realice agrupaciones debe utilizar este componente para ello. Properties: Indice: es el orden del grupo dentro del reporte. Si no tiene asignado reporte valdra 0 (cero). Reporte: es el reporte al que afectará. SaltaDeHoja: si desea que al cambiar de grupo se salte a una nueva hoja. TextoEncabezado: texto del encabezado de cada nuevo grupo. CampoClaveDeAgrupacion: nombre del campo que sera la clave de agrupación. Totaliza: si desea tomar totales para el grupo. FormatoTotal: Formato de impresión del total. Titulo: Titulo del grupo. Events: OnEndGroupQuery: se genera al completar un grupo. ========================================================================== TTbExcel: componente que permite facilmente enviar datos a Excel (utilizado por TTbReport) Methods: Connect: establece la comunicacion con Excel. Si lo logra devuelve True. Disconnect: concluye la comunicacion con Excel. StartExport: comienza el envio de informacion a Excel. EndExport: finaliza el envio de informacion a Excel. Seleccionar: selecciona un conjunto de celdas de Excel. Sintaxis: Seleccionar(X1,Y1,X2,Y2); Alinear: Alinea la celda seleccionada de acuerdo al parametro tipo byte. Sintaxis: Alinear(ALINEACION); SetStr: Establece el contenido de una celda. Sintaxis: SetStr(X,Y,TEXTO) AnchoColumna: Establece el ancho de la/s columna/s seleccionada/s. ==========================================================================
TEscritura = record
X : byte;
Y : byte;
Fuente : TFuente;
Texto : string;
end;
TFuente = Set of TTipoFuente
THorizLine = record
X1 : byte;
X2 : byte;
Y : byte;
Tipo : TLinea;
end;
TInitialZoom = (zReal,zWidth,zHeight);
TLinea = (Simple,Doble);
TModelo = (Cannon_F60,Cannon_Laser,Epson_FX,HP_Deskjet,HP_Laserjet,HP_Thinkjet,IBM_Color_Jet,IBM_PC_Graphics,IBM_Proprinter,NEC_3500,NEC_Pinwriter);
TPagina = record
Escritura : TList;
LineasVerticales : TList;
LineasHorizontales : TList;
LineasImpresas : byte;
end;
TPrinterMode = (pmFast,pmWindows);
TStatus = (Lista,OffLine,SinPapel,Apagada,Desconocido);string
TTbEndGroupEvent = procedure(var EndGroup : boolean) of objectif Assigned(FOnGetText) then FOnGetText(TextoAImprimir);
TTbEndQueryEvent = procedure(var EndReport : boolean) of object
TTbGetTextEvent = procedure(var Text : string) of objectif Assigned(FOnEndQuery) then FOnEndQuery(FinReporte);
TTipoFuente = (Negrita,Italica,Subrayado,Comprimido);
TVertLine = record
X : byte;
Y1 : byte;
Y2 : byte;
Tipo : TLinea;
end;
Constants |
Variables |