la que consegui dice:
Version 2.0b( 27/07/05 )
+ Primera implementacion de CANCELAMENTOgracias.
Version 2.0b( 27/07/05 )
+ Primera implementacion de CANCELAMENTOBuenas
Esa es la 煤ltima vez que la toque. ![]()
Saludos Cordiales
#include "hbclass.ch"
#include "harupdf.ch"
#include "common.ch"
#include "tutilpdf.ch"
******************************************************************************
******************************************************************************
CLASS TUtilPdf
聽 聽 聽 DATA oPrinter 聽// Objeto Hairu en el que trabajar
聽 聽 聽 DATA oBrush 聽 聽// Brocha a usar la clase por defecto
聽 聽 聽 DATA oPen 聽 聽 聽// Lapiz a usar 聽la clase por defecto
聽 聽 聽 DATA nColor INIT 0 聽 // Color de la fuente a usar por defecto
聽 聽 聽 HIDDEN:
聽 聽 聽 DATA nAnchoFont, nAltoFont,nAnchoPage
聽 聽 聽 DATA cLongText 聽 // Texto mas largo dentro de un array o Texto pasado. Uso interno
聽 聽 聽 DATA aAltoFonts 聽// Alto de las Fuentes del bi-array, para el salto de linea
聽 聽 聽 DATA nPos 聽 聽 聽 聽// Posicion de la fuente dentro del array bi que es la mas ancha
聽 聽 聽 DATA aFonts 聽 聽 聽// Array con las fuentes a usar desde un fichero externo
聽 聽 聽 EXPORT:
聽 聽 聽 METHOD New( oPrinter ) CONSTRUCTOR
聽 聽 聽 METHOD Text()
聽 聽 聽 METHOD Box( nArriba, nIzq, nAbajo, nDerecha )
聽 聽 聽 METHOD SayImage( cFileImage, x, y, nWidth, nHeight , ljpg ,lPage )
聽 聽 聽 METHOD Linea( nArriba, nIzq, nAbajo, nDerecha )
聽 聽 聽 METHOD BoxMsg( )
END CLASS
METHOD New( oPrinter ) CLASS TUtilPDF
聽 聽 聽::oPrinter := oPrinter
RETURN Self
******************************************************************************
******************************************************************************
METHOD Text( cText,nRow,nCol, cFont, nSize, nRed,nGreen,nBlue, 聽nAngle ) CLASS TUtilPDF
聽 local nPad := 0, nAl, aDev, unDefined := 0
聽 ::oPrinter:CMSAY( nRow, nCol, cText, cFont, nSize, nRed, nGreen, nBlue, nAngle )
Return Nil
******************************************************************************
******************************************************************************
METHOD Box( nArriba, nIzq, nAbajo, nDerecha, nWitdh, lStroke, nRed, nGreen, nBlue, lFill, nRed2, nGreen2, nBlue2 ) CLASS TUtilPDF
聽 聽DEFAULT nRed 聽TO 0 , nGreen 聽TO 0 , nBlue 聽TO 0,;
聽 聽 聽 聽 聽 聽nRed2 TO 1 , nGreen2 TO 1 , nBlue2 TO 1
聽 聽::oPrinter:GSave()
聽 聽if !empty( nWitdh )
聽 聽 聽 ::oPrinter:SetLineWidth( nWitdh )
聽 聽endif
聽 聽::oPrinter:SetRGBStroke( nRed, nGreen, nBlue )
聽 聽::oPrinter:SetRgbFill( nRed2 , nGreen2, nBlue2 聽)
聽 聽::oPrinter:Rectangle( nArriba, nIzq, nAbajo, nDerecha )
聽 聽::oPrinter:PageFillStroke( ) // Pinta borde y contenido
聽 聽::oPrinter:GRestore()
Return nil
******************************************************************************
******************************************************************************
METHOD SayImage( x, y, nWidth, nHeight, cFileImage, ljpg ,lPage ) CLASS TUtilPDF
聽 聽Local pImage
聽 聽 lJpg := iif( (".jpeg" $ cFileImage .or. ".jpg" $ cFileImage ), .T., .F. )
聽 聽 if lJpg
聽 聽 聽 pImage := ::oPrinter:LoadImageJpg( cFileImage )
聽 聽 else
聽 聽 聽 pImage := ::oPrinter:LoadImagePng( cFileImage )
聽 聽 endif
聽 聽 if (lPage)
聽 聽 聽 聽nWidth 聽:= ::oPrinter:POINTS2CMS( ::oPrinter:GetPageWidth() 聽)- 0.5
聽 聽 聽 聽nHeight := ::oPrinter:POINTS2CMS( ::oPrinter:GetPageHeight() )- 0.5
聽 聽 聽 聽x := 0.25
聽 聽 聽 聽y := 0.25
聽 聽 endif
聽 聽if !empty( pImage )
聽 聽 聽 聽::oPrinter:DrawImage( pImage, x, y, nWidth, nHeight )
聽 聽endif
RETURN NIL
******************************************************************************
/* Dibujando Lineas con el Pen que tenemos o el pasado */
******************************************************************************
METHOD Linea( nArriba, nIzq, nAbajo, nDerecha, nWidth, nRed, nGreen, nBlue ) CLASS TUtilPDF
聽 聽DEFAULT nRed 聽TO 0 , nGreen 聽TO 0 , nBlue 聽TO 0
聽
聽 聽::oPrinter:GSave()
聽 聽if !empty( nWidth )
聽 聽 聽 ::oPrinter:SetLineWidth( nWidth )
聽 聽endif
聽 聽::oPrinter:SetRGBStroke( nRed, nGreen, nBlue )
聽 聽::oPrinter:Line( nArriba, nIzq, nAbajo, nDerecha, nWidth, nRed, nGreen, nBlue )
聽 聽::oPrinter:GRestore()
return NIL
******************************************************************************
* Caja de Textos.
* beta:
* 聽 nMode pasa a lTitle para titulo centrado en la hoja.
* 聽 nMode se convierte para align sobre el Box
* Debemos de escoger la fuente que tenemos y dejarla como estaba
* ya que GetTextWidth() la deja selecciona atraves de SetFont, y
* nos interesa que el comando SELEC siga con la fuente que le dijimos
******************************************************************************
METHOD BoxMsg( nArriba, nIzq, nAbajo, nDerecha ,oBrush, oPen,lRound,nZ,nZ2,;
聽 聽 聽 聽 聽 聽 聽 聽cText, nRow,nCol,oFont, nClrText,nBkMode ,;
聽 聽 聽 聽 聽 聽 聽 聽nAlto, nAncho ,lShadow,nShadow, oBrushShadow,;
聽 聽 聽 聽 聽 聽 聽 聽oPenShadow ,lTitle,cPad,lNoBox, nSize ) CLASS TUtilPdf
聽 Local lEndBrush := .F.
聽 Local lEndPen 聽 := .F.
聽 Local aDev,nMode
聽 Local nLinesArray := 1
聽 ::cLongText := cText 聽 聽// Cadena de texto mas grande dentro del array. Por defecto el texto pasado
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 // Si es un array dimensional , ya se recalculara de nuevo
聽 ::aAltoFonts := {}
聽 ::nAnchoFont := 0
聽 ::nAltoFont 聽:= 0
聽 ::nPos := 0
聽 DEFAULT nShadow TO 0.25,; // Cantidad de Sombra cms
聽 聽 聽 聽 聽 nCol TO 0 聽 聽 聽,;
聽 聽 聽 聽 聽 nRow TO 0 聽 聽 聽,;
聽 聽 聽 聽 聽 nAncho TO .5 聽 ,;
聽 聽 聽 聽 聽 nAlto 聽TO .5 聽 ,;
聽 聽 聽 聽 聽 lTitle TO .F. ,;
聽 聽 聽 聽 聽 oFont 聽TO ::oPrinter:Font_Active,; // Fuente Activa
聽 聽 聽 聽 聽 lShadow TO .F.,;
聽 聽 聽 聽 聽 lNoBox TO .F.
聽IF cPad == "LEFT" 聽 聽 聽 聽 聽; nMode := HPDF_TALIGN_LEFT
聽 聽 ELSEIF cPad == "RIGHT" 聽; nMode := HPDF_TALIGN_RIGHT
聽 聽 ELSEIF cPad == "CENTER" .OR. cPad == "CENTERED" ; nMode := HPDF_TALIGN_CENTER
聽 聽 ELSE
聽 聽 聽 聽nMode := HPDF_TALIGN_CENTER
聽ENDIF
聽 ::nAnchoPage := 聽::oPrinter:Points2Cms( ::oPrinter:GetPageWidth() ) / 10 //Dimensiones fisicas en Cms
聽 ::nAnchoFont := ::oPrinter:GetFontSize() / 10 聽 聽 聽 聽 聽 聽 聽 // Esta en m/m , pasamos a cms
聽 ::nAltoFont 聽:= ::oPrinter:GetFontSize() / 10
聽 if lTitle // Centro.Calculamos la nueva posicion de la columna
聽 聽 聽 聽nCol := ( ::nAnchoPage / 2 ) - ( ::nAnchoFont / 2 ) // La mitad de todo ;)
聽 endif
聽 if lShadow
//METHOD Box( nArriba, nIzq, nAbajo, nDerecha, nWitdh, lStroke, nRed, nGreen, nBlue, lFill, nRed2, nGreen2, nBlue2 ) CLASS TUtilPDF
聽 聽 聽if ( Empty( cText ) ) .OR. nArriba # NIL 聽 //Solamente una Caja
聽 聽 聽 聽 ::Box( nArriba+nShadow-nAlto,;
聽 聽 聽 聽 聽 聽 聽 聽nIzq+nShadow-nAncho,;
聽 聽 聽 聽 聽 聽 聽 聽nAbajo+nShadow+nAlto,;
聽 聽 聽 聽 聽 聽 聽 聽nDerecha+nShadow+nAncho 聽)
聽 聽 聽else
聽 聽 聽 聽 ::Box( nRow+nShadow-nAlto,;
聽 聽 聽 聽 聽 聽 聽 聽nCol+nShadow-nAncho,;
聽 聽 聽 聽 聽 聽 聽 聽nRow+::nAltoFont+nShadow+nAlto,;
聽 聽 聽 聽 聽 聽 聽 聽nCol+::nAnchoFont+nShadow+nAncho 聽)
聽 聽 聽endif
聽 endif
聽 if ( Empty( cText ) ) .OR. nArriba # NIL 聽// Solamente una caja
聽 聽 聽::Box( nArriba - nAlto,;
聽 聽 聽 聽 聽 聽 nIzq - nAncho,;
聽 聽 聽 聽 聽 聽 nAbajo + nAlto,;
聽 聽 聽 聽 聽 聽 nDerecha+ nAncho )
聽 else
聽 聽 聽 if !lNoBox
聽 聽 聽 聽::Box( nRow - nAlto,;
聽 聽 聽 聽 聽 聽 nCol - nAncho,;
聽 聽 聽 聽 聽 聽 nRow+::nAltoFont+nAlto,;
聽 聽 聽 聽 聽 聽 nCol+::nAnchoFont+nAncho 聽)
聽 聽 聽 endif
聽 聽 聽 IF VALTYPE( cText ) == "A"
聽 聽 聽 聽 聽::TextLines( cText,nRow,nCol,oFont,nClrText,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 nBkMode,nLinesArray, nMode, nAncho, lTitle )
聽 聽 聽 ELSE
聽 聽 聽 聽 聽// Alineacion dentro de la Caja de Mensaje
聽 聽 聽 聽 聽DO CASE
聽 聽 聽 聽 聽 聽 CASE nMode == 0 聽// Left
聽 聽 聽 聽 聽 聽 聽 聽 聽nCol -= 聽nAncho - 0.1
聽 聽 聽 聽 聽 聽 CASE nMode == 1 // Right
聽 聽 聽 聽 聽 聽 聽 聽 聽nCol += 聽nAncho - 0.1
聽 聽 聽 聽 聽END CASE
聽 聽 聽 聽 聽//TODO: Falta pasar tama帽o fuente y color
聽 聽 聽 聽 聽 聽 DEFAULT nArriba to nRow - nAlto
聽 聽 聽 聽 聽 聽 DEFAULT nIzq 聽 聽to nCol - nAncho
聽 聽 聽 聽 聽 聽 DEFAULT nAbajo 聽to nRow+::nAltoFont+nAlto
聽 聽 聽 聽 聽 聽 DEFAULT nDerecha to nCol+::nAnchoFont+nAncho
聽 聽 聽 聽 聽 聽::oPrinter:CMSAYRECT( nRow, nCol, cText, oFont, 15, 0,0, 0, 0, nArriba, nIzq, nAbajo, nDerecha, nMode )
聽 聽 聽 ENDIF
聽 endif
RETURN NIL// ------------------------------------------------------------------------------------
// (c) 2011-2012 Rafa Carmona
// ------------------------------------------------------------------------------------
聽 聽#define rLEFT 聽 1
聽 聽#define rTOP 聽 聽2
聽 聽#define rRIGHT 聽3
聽 聽#define rBOTTOM 4
#xcommand DEFINE UTILPDF 聽<oUtil> 聽;
聽 聽 聽 聽 聽 [ < of: PRINTER,OF> <oPrinter> ] 聽;
聽 聽 聽 聽 聽 [ BRUSH <oBrush> ] ;
聽 聽 聽 聽 聽 [ PEN 聽 <oPen> 聽 ] ;
聽 聽 聽 聽 聽=>;
聽 聽 聽 聽 聽[ <oUtil> := ] TUtilPdf():New( <oPrinter>,<oBrush>,<oPen> )
#xcommand UTILPDF <oUtil> ;
聽 聽 聽 聽 聽 [ <nRow>,<nCol> SAY <cText> ];
聽 聽 聽 聽 聽 [ FONT <cFont> ] [SIZE <nSize> ];
聽 聽 聽 聽 聽 [ COLOR RGB <nRed>,<nGreen>,<nBlue> ];
聽 聽 聽 聽 聽 [ ROTATE <nAngle>];
聽 聽 聽 聽 聽=>;
聽 聽 聽 聽 聽 聽<oUtil>:Text( <cText>,<nRow>,<nCol>,<cFont>,<nSize>, <nRed>,<nGreen>,<nBlue>, <nAngle>)
#xcommand ISEPARATOR [ <nSpace> ] [<lBody: BODY>];
聽 聽 聽 聽 聽=>;
聽 聽 聽 聽 聽 聽::Separator( <nSpace> , <.lBody.>)
#xcommand UTILPDF <oUtil> ;
聽 聽 聽 聽 聽 BOX <nX>,<nY> TO <nX2>,<nY2> ;
聽 聽 聽 聽 聽 [ 聽<lStroke: STROKE> [ SIZE <nWitdh>] [ COLOR <nRed>,<nGreen>,<nBlue> ] ];
聽 聽 聽 聽 聽 [ 聽<lFill: FILLRGB> <nRed2>,<nGreen2>,<nBlue2> 聽];
聽 聽 聽 聽 聽=>;
聽 聽 聽 聽 聽 聽<oUtil>:Box( <nX>,<nY>,<nX2>,<nY2>,<nWitdh>,<.lStroke.>,<nRed>,<nGreen>,<nBlue>,<.lFill.>,<nRed2>,<nGreen2>,<nBlue2> )
#xcommand UTILPDF <oUtil> ;
聽 聽 聽 聽 聽 LINEA <nX>,<nY> TO <nX2>,<nY2> ;
聽 聽 聽 聽 聽 [ WITDH <nWitdh>];
聽 聽 聽 聽 聽 [ COLOR <nRed>,<nGreen>,<nBlue> ] ;
聽 聽 聽 聽 聽=>;
聽 聽 聽 聽 聽 聽<oUtil>:Linea( <nX>,<nY>,<nX2>,<nY2>,<nWitdh>,<nRed>,<nGreen>,<nBlue> )
#xcommand UTILPDF <oUtil> ;
聽 聽 聽 聽 聽 [<nX>,<nY>] IMAGE <cFile> [ SIZE <nX2>,<nY2> ] ;
聽 聽 聽 聽 聽 [ <lImage: JPG > ];
聽 聽 聽 聽 聽 [ <lPage: PAGE > ];
聽 聽 聽 聽 聽=>;
聽 聽 聽 聽 聽 聽<oUtil>:SayImage( <nX>,<nY>,<nX2>,<nY2>,<cFile>,<.lImage.>,<.lPage.> )
#xcommand UTILPDF <oUtil> ;
聽 聽 聽 聽 聽 MSG [ <cText> 聽[ AT <nRow>,<nCol> ] [TEXTFONT <oFont> ] [TEXTCOLOR <nClrText>] ];
聽 聽 聽 聽 聽 [<nX>,<nY> TO <nX2>,<nY2>] ;
聽 聽 聽 聽 聽 [ BRUSH <oBrush>];
聽 聽 聽 聽 聽 [ PEN <oPen> ] ;
聽 聽 聽 聽 聽 [ <lRound: ROUND > 聽[ <nZ>,<nZ2> 聽] ];
聽 聽 聽 聽 聽 [ <lShadow: SHADOW> [ WIDTH <nShadow> ] ];
聽 聽 聽 聽 聽 [SHADOWBRUSH <oBrushShadow>];
聽 聽 聽 聽 聽 [SHADOWPEN <oPenShadow>];
聽 聽 聽 聽 聽 [ EXPANDBOX <nAlto>,<nAncho> ] ;
聽 聽 聽 聽 聽 [ ALIGN <nMode> ] ;
聽 聽 聽 聽 聽=>;
聽 聽 聽 聽 聽 聽<oUtil>:BoxMsg( <nX>,<nY>,<nX2>,<nY2>,<oBrush>,<oPen>,<.lRound.>,<nZ>,<nZ2>,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 <cText>,<nRow>,<nCol>,<oFont>, <nClrText>,,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 <nAlto>, <nAncho> ,<.lShadow.>,<nShadow>, <oBrushShadow>, <oPenShadow> ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 <nMode>)#include "hbclass.ch"
#include "harupdf.ch"
#include "common.ch"
#include "tutilpdf.ch"
/*
聽******************************************************************************
聽 Clase TIMPRIMEPDF
聽 Nos permite generar ficheros pdf a traves de la libreria Hairu.
聽 Esta clase nos provee la facilidad de trabajar con cms.
聽******************************************************************************
聽*/
CLASS TIMPRIMEPDF
聽 聽 DATA pPdf 聽 聽 聽 聽 聽 聽 聽 聽 聽// Pointer
聽 聽 DATA aPages 聽 聽 聽 聽 聽 聽 聽 聽// Array Pages creates
聽 聽 DATA Page_Active 聽 聽 聽 聽 聽 // Page active
聽 聽 DATA PointToInch INIT 72
聽 聽 DATA Font_Active 聽 聽 聽 聽 聽 // Font Active
聽 聽 DATA nSpace_Separator 聽 INIT 0.5
聽 聽 DATA nEndLine 聽 聽 聽 聽 聽 聽 聽// Fin de la ultima linea
聽 聽 DATA nLinea INIT 1
聽 聽 DATA nFila 聽INIT 1
聽 聽 DATA oUtil
聽 聽 DATA cFontDefault INIT "Courier"
聽 聽 DATA cFileName 聽 聽INIT "tgtk.pdf"
聽 聽 DATA aFonts
聽 聽 DATA aEncodings
聽 聽 DATA cEncoding 聽 INIT "ISO8859-15"
聽 聽 DATA lUTF8toISO 聽INIT .T. 聽 聽 // Esta versi贸n de HARU no tiene soporte de UTF8, hacemos conversion automaticamente del texto a imprimir
聽 聽 DATA def_font
聽 聽
聽 聽 METHOD New( cFile ) CONSTRUCTOR
聽 聽 METHOD Init( cFile ) INLINE ::New( cFile )
聽 聽 MESSAGE Date 聽 聽 聽METHOD _DateTime( nLinea, nFila )
聽 聽 MESSAGE MesFecha 聽METHOD _MesFecha_( dDate )
聽 聽 METHOD SaveAs( cFileToSave ) 聽INLINE HPDF_SaveToFile( ::pPdf, cFileToSave )
聽 聽 METHOD SetCompresion( cMode ) INLINE HPDF_SetCompressionMode( ::pPdf, cMode )
聽 聽 METHOD AddPage()
聽 聽 METHOD PageSetSize( nSize, nDirection ) INLINE HPDF_Page_SetSize( ::Page_Active, nSize, nDirection )
聽 聽 METHOD GetPageHeight() INLINE HPDF_Page_GetHeight( ::Page_Active )
聽 聽 METHOD GetPageWidth() 聽INLINE HPDF_Page_GetWidth( ::Page_Active )
聽 聽 METHOD GetFontSize() 聽 INLINE HPDF_PAGE_GETCURRENTFONTSIZE( ::Page_Active )
聽 聽 METHOD GetFontName() 聽 INLINE HPDF_Font_GetFontName( ::Font_Active )
聽 聽
聽 聽 METHOD SetFontSize( nSize )
聽 聽 METHOD SetFont( cFontName, nSize, cEncoding 聽)
聽 聽 METHOD CMSAY( nRowCms, nColCms, cText, nSize )
聽 聽 METHOD CMS2POINTS( nCms )
聽 聽 METHOD POINTS2CMS( nPoints )
聽 聽 METHOD Rectangle( nTop, nLeft, nRight, nBottom )
聽 聽 METHOD SetRgbStroke( nRed, nGreen, nBlue ) INLINE HPDF_Page_SetRGBStroke( ::page_active, nRed, nGreen, nBlue)
聽 聽 METHOD SetRgbFill( nRed, nGreen, nBlue 聽) 聽INLINE HPDF_Page_SetRGBFill( ::Page_Active, nRed, nGreen, nBlue) // 0 ... 1
聽 聽 METHOD PageFill() 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽INLINE HPDF_Page_Fill( ::Page_Active )
聽 聽 METHOD PageFillStroke() 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽INLINE HPDF_Page_FillStroke( ::Page_Active )
聽 聽 METHOD PageStroke() 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽INLINE HPDF_Page_Stroke( ::Page_Active )
聽 聽 METHOD Separator( nJump )
聽 聽 METHOD CompLinea( nSuma )
聽 聽 METHOD SetPortrait() 聽INLINE ( ::PageSetSize( HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT ),;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽::nEndLine := ::POINTS2CMS( ::GetPageHeight() ) )
聽 聽 METHOD SetLandScape() 聽INLINE ( ::PageSetSize( HPDF_PAGE_SIZE_A4, HPDF_PAGE_LANDSCAPE ),;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽::nEndLine := ::POINTS2CMS( ::GetPageHeight() ) )
聽 聽 //Methods Destructores
聽 聽 METHOD End( lPageCount )
聽 聽 METHOD PageCount()
聽 聽 MESSAGE Eject 聽 聽 METHOD __Eject()
聽 聽 METHOD SetLineWidth( nWidth ) INLINE HPDF_Page_SetLineWidth( ::Page_Active, nWidth )
聽 聽 METHOD GSave() 聽 聽INLINE 聽HPDF_Page_GSave( ::Page_Active ) 聽 聽 聽// Save the current graphic state
聽 聽 METHOD GRestore() INLINE 聽HPDF_Page_GRestore( ::Page_Active ) 聽 // Restore graphic state
/*
聽 聽 METHOD GSave() 聽 聽VIRTUAL
聽 聽 METHOD GRestore() VIRTUAL
*/
聽 聽 METHOD LoadImagePng( cFileImage ) INLINE HPDF_LoadPngImageFromFile( ::pPdf, cFileImage )
聽 聽 METHOD LoadImageJpg( cFileImage ) INLINE HPDF_LoadJpegImageFromFile( ::pPdf, cFileImage )
聽 聽 METHOD ImageGetWidth( pImage ) 聽INLINE HPDF_Image_GetWidth( pImage )
聽 聽 METHOD ImageGetHeight( pImage ) INLINE HPDF_Image_GetHeight( pImage )
聽 聽 METHOD DrawImage( pImage, x, y, nWidth, nHeight )
聽 聽 METHOD UseUTF() INLINE HPDF_UseUTFEncodings( ::pPdf )
聽 聽 METHOD Line( nTop, nLeft, nBottom, nRight, nWitdh, nRed, nGreen, nBlue )
聽 聽 METHOD SetEncoder( cEncoding ) INLINE HPDF_SetCurrentEncoder 聽( ::pPdf, cEncoding )
聽 聽 Method LoadTTF( cFont ) 聽INLINE HPDF_LoadTTFontFromFile ( ::pPdf, "/home/rafa/pol/fonts/"+cFont +".ttf", HPDF_TRUE)
聽 聽 METHOD CMSAYRECT(nRowCms, nColCms, cText, cFont, nSize, nRed, nGreen, nBlue, nAngle, nTop, nLeft, nBottom, nRight, nJustify)
聽 聽 METHOD CreateFonts()
END CLASS
METHOD New( cFile ) CLASS TIMPRIMEPDF
聽 聽::CreateFonts()
聽 聽
聽 聽::pPdf := HPDF_New()
聽 聽::aPages := {}
聽 聽::AddPage() 聽 聽 聽 聽 // Crea pagina para imprimir
聽 聽DEFINE UTILPDF ::oUtil OF Self
聽 聽::cFileName := cFile
RETURN Self
METHOD CreateFonts() CLASS TIMPRIMEPDF
聽 聽::aFonts 聽:= { ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Courier", 聽 聽 聽 聽 聽 聽 聽 聽 聽; // 1
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Courier-Bold", 聽 聽 聽 聽 聽 聽 ; // 2
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Courier-Oblique", 聽 聽 聽 聽 聽; // 3
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Courier-BoldOblique", 聽 聽 聽; // 4
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Helvetica", 聽 聽 聽 聽 聽 聽 聽 聽; // 5
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Helvetica-Bold", 聽 聽 聽 聽 聽 ; // 6
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Helvetica-Oblique", 聽 聽 聽 聽; // 7
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Helvetica-BoldOblique", 聽 聽; // 8
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Times-Roman", 聽 聽 聽 聽 聽 聽 聽; // 9
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Times-Bold", 聽 聽 聽 聽 聽 聽 聽 ; // 10
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Times-Italic", 聽 聽 聽 聽 聽 聽 ; // 11
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Times-BoldItalic", 聽 聽 聽 聽 ; // 12
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Symbol", 聽 聽 聽 聽 聽 聽 聽 聽 聽 ; // 13
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "ZapfDingbats" 聽 聽 聽 聽 聽 聽 聽; // 14
聽 聽 聽 聽 聽 聽 聽 聽 聽 }
聽 ::aEncodings := { ;
聽 聽 聽 聽 聽 聽 "StandardEncoding",;
聽 聽 聽 聽 聽 聽 "MacRomanEncoding",;
聽 聽 聽 聽 聽 聽 "WinAnsiEncoding", ;
聽 聽 聽 聽 聽 聽 "ISO8859-2", 聽 聽 聽 ;
聽 聽 聽 聽 聽 聽 "ISO8859-3", 聽 聽 聽 ;
聽 聽 聽 聽 聽 聽 "ISO8859-4", 聽 聽 聽 ;
聽 聽 聽 聽 聽 聽 "ISO8859-5", 聽 聽 聽 ;
聽 聽 聽 聽 聽 聽 "ISO8859-9", 聽 聽 聽 ;
聽 聽 聽 聽 聽 聽 "ISO8859-10", 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "ISO8859-13", 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "ISO8859-14", 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "ISO8859-15", 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "ISO8859-16", 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "CP1250", 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "CP1251", 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "CP1252", 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "CP1254", 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "CP1257", 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "KOI8-R", 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "Symbol-Set", 聽 聽 聽;
聽 聽 聽 聽 聽 聽 "ZapfDingbats-Set" }
RETURN NIL
*******************************************************************************
METHOD End( lPageCount ) CLASS TIMPRIMEPDF
聽 DEFAULT lPageCount TO .F.
聽 if lPageCount
聽 聽 聽::PageCount( 聽)
聽 endif
聽 ::SaveAs( ::cFileName ) // Save File
聽 HPDF_Free( ::pPdf )
RETURN NIL
*******************************************************************************
METHOD AddPage() CLASS TIMPRIMEPDF
聽 聽::Page_Active := HPDF_AddPage( ::pPdf )
聽 聽::SetFont( ::cFontDefault, 10) 聽// Important, definir font
聽 聽AADD( ::aPages, ::Page_Active )
聽 聽::nEndLine := ::POINTS2CMS( ::GetPageHeight() )
RETURN ::Page_Active
*******************************************************************************
METHOD CMSAY( nRowCms, nColCms, cText, cFont, nSize, nRed, nGreen, nBlue, nAngle ) CLASS TIMPRIMEPDF
聽 聽Local uFont := ::GetFontName()
聽 聽Local uSize := ::GetFontSize()
聽 聽Local nRad1
聽 聽DEFAULT nRed TO 0 , nGreen TO 0 , nBlue TO 0
聽 聽if ::lUTF8toISO
聽 聽 聽 cText := _UTF_8 ( cText )
聽 聽endif
聽 聽::GSave()
聽 聽if !empty( cFont 聽) .OR. !empty( nSize )
聽 聽 聽 ::SetFont( cFont, nSize )
聽 聽endif
聽 聽HPDF_Page_BeginText( ::Page_Active )
聽 聽 if !empty( nAngle 聽)
聽 聽 聽 聽nRad1 := nAngle / 180 * 3.141592
聽 聽 聽 聽HPDF_Page_SetTextMatrix( ::Page_Active, cos(nRad1), sin(nRad1), -sin(nRad1), cos(nRad1), ::CMS2POINTS( nColCms ), ::GetPageHeight() - ::CMS2POINTS( nRowCms ) )
聽 聽 else
聽 聽 聽 聽HPDF_Page_MoveTextPos(::Page_Active , ::CMS2POINTS( nColCms ), ::GetPageHeight() - ::CMS2POINTS( nRowCms ))
聽 聽 endif
聽 聽 HPDF_Page_SetRGBFill( ::Page_Active, nRed, nGreen, nBlue) // 0 ... 1
聽 聽 HPDF_Page_ShowText(::Page_Active, cText )
聽 聽//HPDF_Page_TextOut( ::Page_Active, ::CMS2POINTS( nColCms ), ::GetPageHeight() - ::CMS2POINTS( nRowCms ), cText )
聽 聽HPDF_Page_EndText( ::Page_Active )
聽 聽::GRestore()
RETURN NIL
*******************************************************************************
METHOD CMSAYRECT(nRowCms, nColCms, cText, cFont, nSize, nRed, nGreen, nBlue, nAngle, nTop, nLeft, nBottom, nRight, nJustify) CLASS TIMPRIMEPDF
聽 聽Local uFont := ::GetFontName()
聽 聽Local uSize := ::GetFontSize()
聽 聽Local nRad1
聽 聽Local rect := Array( 4 )
聽 聽rect[ rLEFT 聽 ] := ::CMS2POINTS( nLeft )
聽 聽rect[ rTOP 聽 聽] := ::GetPageHeight() - ::CMS2POINTS( nTop )
聽 聽rect[ rRIGHT 聽] := ::CMS2POINTS( nRight )
聽 聽rect[ rBOTTOM ] := ::GetPageHeight() - ::CMS2POINTS( nBottom )
聽 聽DEFAULT nRed TO 0 , nGreen TO 0 , nBlue TO 0
聽 聽if ::lUTF8toISO
聽 聽 聽 cText := _UTF_8 ( cText )
聽 聽endif
聽 聽::GSave()
聽 聽if !empty( cFont 聽) .OR. !empty( nSize )
聽 聽 聽 ::SetFont( cFont, nSize )
聽 聽endif
聽 聽HPDF_Page_BeginText( ::Page_Active )
聽 聽 if !empty( nAngle 聽)
聽 聽 聽 聽nRad1 := nAngle / 180 * 3.141592
聽 聽 聽 聽HPDF_Page_SetTextMatrix( ::Page_Active, cos(nRad1), sin(nRad1), -sin(nRad1), cos(nRad1), ::CMS2POINTS( nColCms ), ::GetPageHeight() - ::CMS2POINTS( nRowCms ) )
聽 聽 else
聽 聽 聽 聽HPDF_Page_MoveTextPos(::Page_Active , ::CMS2POINTS( nColCms ), ::GetPageHeight() - ::CMS2POINTS( nRowCms ))
聽 聽 endif
聽 聽 HPDF_Page_SetRGBFill( ::Page_Active, nRed, nGreen, nBlue) // 0 ... 1
聽 聽 HPDF_Page_TextRect( ::Page_Active, rect[ rLEFT ], rect[ rTOP ], rect[ rRIGHT ], rect[ rBOTTOM ],;
聽 聽 聽 聽 聽 聽 聽 聽cText, HPDF_TALIGN_CENTER, NIL)
聽 聽HPDF_Page_EndText( ::Page_Active )
聽 聽::GRestore()
RETURN NIL
*******************************************************************************
METHOD Rectangle( nTop, nLeft, nBottom, nRight ) CLASS TIMPRIMEPDF
聽 聽Local rect := Array( 4 )
聽 聽rect[ rLEFT 聽 ] := ::CMS2POINTS( nLeft )
聽 聽rect[ rTOP 聽 聽] := ::GetPageHeight() - ::CMS2POINTS( nTop )
聽 聽rect[ rRIGHT 聽] := ::CMS2POINTS( nRight )
聽 聽rect[ rBOTTOM ] := ::GetPageHeight() - ::CMS2POINTS( nBottom )
聽 聽HPDF_Page_SetLineCap( ::Page_Active, HPDF_ROUND_END)
聽 聽HPDF_Page_Rectangle( ::Page_Active, rect[ rLEFT ], rect[ rBOTTOM ], rect[ rRIGHT ] - rect[ rLEFT ], ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽rect[ rTOP ] - rect[ rBOTTOM ] )
RETURN NIL
*******************************************************************************
METHOD Line( nTop, nLeft, nBottom, nRight, nWitdh, nRed, nGreen, nBlue ) CLASS TIMPRIMEPDF
聽 聽Local rect := Array( 4 )
聽 聽rect[ rLEFT 聽 ] := ::CMS2POINTS( nLeft )
聽 聽rect[ rTOP 聽 聽] := ::GetPageHeight() - ::CMS2POINTS( nTop )
聽 聽rect[ rRIGHT 聽] := ::CMS2POINTS( nRight )
聽 聽rect[ rBOTTOM ] := ::GetPageHeight() - ::CMS2POINTS( nBottom )
聽 聽HPDF_Page_MoveTo( ::Page_Active, rect[ rLEFT 聽 ] , rect[ rTOP ] )
聽 聽HPDF_Page_LineTo( ::Page_Active, rect[ rRIGHT 聽], 聽rect[ rBOTTOM ])
聽 聽::PageStroke()
RETURN NIL
*******************************************************************************
METHOD DrawImage( pImage, x, y, nWidth, nHeight ) 聽CLASS TIMPRIMEPDF
聽 聽x := ::GetPageHeight() - ::CMS2POINTS( x )
聽 聽y := ::CMS2POINTS( y )
聽 聽if empty( nWidth )
聽 聽 聽 nWidth := ::ImageGetWidth( pImage )
聽 聽else
聽 聽 聽 nWidth := ::CMS2POINTS( nWidth )
聽 聽endif
聽 聽if empty( nHeight )
聽 聽 聽 nHeight := ::ImageGetHeight( pImage )
聽 聽else
聽 聽 聽 nHeight := ::CMS2POINTS( nHeight 聽)
聽 聽endif
聽 聽//Nota: Restamos la mitad del alto para obtener la posicion real de X
聽 聽x -= nHeight
聽 聽HPDF_Page_DrawImage( ::Page_Active, pImage, y, x, nWidth, nHeight )
RETURN NIL
*******************************************************************************
METHOD SetFont( cFontName, nSize, cEncoding 聽) CLASS TIMPRIMEPDF
聽 聽
聽 聽DEFAULT cEncoding 聽TO ::cEncoding , nSize TO 10
聽 聽::Font_Active := HPDF_GetFont( ::pPdf, cFontName, cEncoding 聽)
聽 聽
聽 聽if !empty( nSize )
聽 聽 聽 ::SetFontSize( nSize )
聽 聽endif
RETURN NIL
*******************************************************************************
METHOD SetFontSize( nSize ) CLASS TIMPRIMEPDF
聽 聽HPDF_Page_SetFontAndSize( ::Page_Active, ::Font_Active, nSize )
RETURN NIL
*******************************************************************************
METHOD CMS2POINTS( nCms ) CLASS TIMPRIMEPDF
RETURN ( nCms/2.54*::PointToInch )
*******************************************************************************
METHOD POINTS2CMS( nPoints ) CLASS TIMPRIMEPDF
RETURN ( nPoints / ::PointToInch * 2.54 )
*******************************************************************************
/* Funcion que nos comprueba si tenemos que realizar una pagina nueva
聽 El salto de pagina se produce cuando la Linea sobrepasa la dimension
聽 fisica de la hoja en vertical.
聽 Esto nos da como resultado usar cualquier tipo de papel sin complicaciones.
聽 Si salta pagina devuelve .T. , sino .F.
聽 */
*******************************************************************************
METHOD CompLinea( nSuma ) CLASS TIMPRIMEPDF
聽 聽 聽 聽Static nPage := 1
聽 聽 聽 聽DEFAULT nSuma TO 0
聽 聽 聽 聽IF ::nLinea > ( ::nEndLine + nSuma 聽)
聽 聽 聽 聽 聽 ::Addpage() 聽// Add page to document
聽 聽 聽 聽 聽 ::nLinea := 1
聽 聽 聽 聽 聽 Return .T.
聽 聽 聽 聽ENDIF
Return .F.
*******************************************************************************
METHOD Separator( nSpace , nSuma ) CLASS TIMPRIMEPDF
聽 聽 聽Local lRet
聽 聽if Empty( nSpace ) /* Si no paso espacio, por defecto */
聽 聽 聽 nSpace := ::nSpace_Separator
聽 聽endif
聽 聽::nLinea += nSpace
聽 聽lRet := ::CompLinea( nSuma ) 聽// Retorna si se ha producido salto de pagina
Return lRet
*******************************************************************************
*******************************************************************************
METHOD PageCount( ) 聽CLASS TIMPRIMEPDF
聽 聽Local x
聽 聽Local nFilesLong := Len( ::aPages )
聽 聽Local nHojas := nFilesLong
聽 聽Local nEndCol
聽 聽Local nEndLine
聽 聽Local cInfo_Page
聽 聽if nFilesLong <= 1 聽// Solamente una pagina, Si hay copia son X Copias
聽 聽 聽 Return Nil
聽 聽endif
聽 聽FOR x := 1 TO 聽nFilesLong
聽 聽 聽 ::Page_Active := ::aPages[ x ]
聽 聽 聽 nEndCol 聽 := ::Points2Cms( ::GetPageWidth() ) 聽- 3
聽 聽 聽 nEndLine 聽:= ::POINTS2CMS( ::GetPageHeight() ) - 1
聽 聽 聽 cInfo_Page := "Hoja " + Alltrim( Str( x ) ) +" de " + Alltrim( Str( nFilesLong ) )
聽 聽 聽 ::CMSAY( nEndLine +.5, nEndCol, cInfo_Page, "Courier" )
聽 聽NEXT
Return NIl
******************************************************************************
******************************************************************************
METHOD __Eject() CLASS TIMPRIMEPDF
聽 聽 聽::AddPage()
RETURN NIL
METHOD _DateTime( nLinea, nFila ) CLASS TIMPRIMEPDF
聽 DEFAULT nLinea TO 0.5
聽 DEFAULT nFila 聽TO 15
聽 UTILPDF Self:oUtil nLinea,nFila SAY "Fecha: " + DTOC( Date() )+" Hora: "+ Time() FONT ::aFonts[2] SIZE 8
Return Self
******************************************************************************
******************************************************************************
METHOD _MesFecha_( dDate ) CLASS TIMPRIMEPDF
聽 Local cMes
聽 DO CASE
聽 聽 聽CASE Month(dDate) == 1 ; cMes := "Enero"
聽 聽 聽CASE Month(dDate) == 2 ; cMes := "Febrero"
聽 聽 聽CASE Month(dDate) == 3 ; cMes := "Marzo"
聽 聽 聽CASE Month(dDate) == 4 ; cMes := "Abril"
聽 聽 聽CASE Month(dDate) == 5 ; cMes := "Mayo"
聽 聽 聽CASE Month(dDate) == 6 ; cMes := "Junio"
聽 聽 聽CASE Month(dDate) == 7 ; cMes := "Julio"
聽 聽 聽CASE Month(dDate) == 8 ; cMes := "Agosto"
聽 聽 聽CASE Month(dDate) == 9 ; cMes := "Septiembre"
聽 聽 聽CASE Month(dDate) == 10; cMes := "Octubre"
聽 聽 聽CASE Month(dDate) == 11; cMes := "Noviembre"
聽 聽 聽CASE Month(dDate) == 12; cMes := "Diciembre"
聽 聽 聽OTHERWISE
聽 聽 聽 聽cMes := "Incorrecto"
聽 ENDCASE
Return 聽cMes#include "gclass.ch"
#include "hbclass.ch"
#include "tdolphin.ch"
#include "gmante.ch"
#include "pol.ch"
#include "harupdf.ch"
#include "tutilpdf.ch"
MEMVAR oServer, oEmpresa, p_LectorPDF
Function FacturaPdf( lAlbaran, nId, lSeleccion ,lCopia, lProforma, lCompras, lOfertas )
聽 聽Local oFact
聽 聽DEFAULT lCompras := .f.
聽 聽DEFAULT lOfertas := .f.
聽 聽with object oFact := TFacturaPDF():Create()
聽 聽 聽 聽:lAlbaran := lAlbaran
聽 聽 聽 聽:lCompras := lCompras
聽 聽 聽 聽:lOfertas := lOfertas
聽 聽 聽 聽:lSeleccion := lSeleccion
聽 聽 聽 聽:lProforma := lProforma
聽 聽 聽 聽:New( nId, NIL, lCopia )
聽 聽 聽 聽:Print()
聽 聽 聽 聽:End( .T. )
聽 聽 聽 聽if !empty( p_LectorPDF )
聽 聽 聽 聽 聽 hb_ProcessRun( p_LectorPDF + " "+ :Directory + :cFile + ".pdf" )
聽 聽 聽 聽else
聽 聽 聽 聽 聽if "WINDOWS" $ 聽Upper( Os() 聽)
聽 聽 聽 聽 聽 聽 聽 聽hb_ProcessRun( getEnv( "COMSPEC" ) + " /c " + " start " + :Directory + :cFile + ".pdf" )
聽 聽 聽 聽 聽else
聽 聽 聽 聽 聽 聽 winexec( "evince " + " " + :Directory + :cFile + ".pdf" 聽)
聽 聽 聽 聽 聽endif
聽 聽 聽 聽endif
聽 聽end
return nil
/*********************************************************************
聽Ejemplo de impresion de una factura.
聽*********************************************************************/
CLASS TFacturaPDF FROM TIMPRIMEPDF
聽 聽 聽 DATA nEndBody INIT 23 聽 聽 聽 聽 聽 // Limite donde tiene que llegar las lineas de la factura
聽 聽 聽 DATA lAlbaran INIT .F. 聽 聽 聽 聽 聽 // Albaran 聽, si es .F., se tratar谩 de una factura
聽 聽 聽 DATA lCompras INIT .F. 聽 聽 聽 聽 聽 // Albaran de Compra
聽 聽 聽 DATA lOfertas INIT .F. 聽 聽 聽 聽 聽 // Oferta de Compra
聽 聽 聽 DATA lProforma INIT .F. 聽 聽 聽 聽 聽// Si es una factura proforma
聽 聽 聽 DATA lCabecera INIT .T. 聽 聽 聽 聽 聽// Cabecera en todas las paginas
聽 聽 聽 DATA lCopia,nVeces 聽 聽 聽 聽 聽 聽 聽 // Si queremos copias
聽 聽 聽 DATA nCopies INIT 1 聽 聽 聽 聽 聽 聽 聽// y cuantas copias quiero del original
聽 聽 聽 DATA nID 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 // ID que identifica a un albaran, factura, o compra
聽 聽 聽 DATA lSeleccion INIT .F. 聽 聽 聽 聽 // False := Serie A 聽, True = Serie B
聽 聽 聽 DATA Directory 聽 INIT "./pdfs/" 聽 聽 聽 // "./pdfs/"
聽 聽 聽 DATA cFile
聽 聽 聽 DATA nTotal INIT 0
聽 聽 聽 DATA oData
聽 聽 聽 DATA oSlave
聽 聽 聽 DATA oCliente
聽 聽 聽 METHOD Create( ) INLINE Self
聽 聽 聽 METHOD New( cFile )
聽 聽 聽 METHOD Reset()
聽 聽 聽 METHOD Print()
聽 聽 聽 METHOD Body()
聽 聽 聽 METHOD Plantilla( nLinea )
聽 聽 聽 METHOD Separator( nSpace, lBody )
聽 聽 聽 METHOD Headers()
聽 聽 聽 METHOD Footers() VIRTUAL
聽 聽 聽 METHOD CompLinea( nSuma )
聽 聽 聽 METHOD Lineas( nIdAlbaran )
聽 聽 聽 METHOD LineasFac() 聽 聽 聽 聽 聽VIRTUAL
聽 聽 聽 METHOD Copia()
聽 聽 聽 METHOD MEMO()
聽 聽 聽 METHOD CajaTotal()
ENDCLASS
*********************************************************************
METHOD New( nID, cFile, lCopia ) CLASS TFacturaPDF
聽 聽 DEFAULT lCopia := .F.
聽 聽 ::lCopia := lCopia
聽 聽 // Si quiero copias , las que quiero mas el original.
聽 聽 if ::lCopia
聽 聽 聽 聽::nCopies += 1 聽// ::nCopies + 1 := El + 1 es por el original + nCopies
聽 聽 endif
聽 聽 if empty( cFile )
聽 聽 聽 聽if ::lAlbaran
聽 聽 聽 聽 聽 if ::lCompras
聽 聽 聽 聽 聽 聽 聽 if ::lOfertas
聽 聽 聽 聽 聽 聽 聽 聽 聽cFile := "Oferta_"+alltrim( CStr( nID 聽)) // Es una oferta
聽 聽 聽 聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽 聽 聽 聽cFile := "Pedido_Compra_"+alltrim( CStr( nID 聽)) // Es una compra
聽 聽 聽 聽 聽 聽 聽 endif 聽
聽 聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽 聽cFile := "Albaran_"+alltrim( cStr( nID 聽))
聽 聽 聽 聽 聽 endif
聽 聽 聽 聽else
聽 聽 聽 聽 聽 if ::lProforma
聽 聽 聽 聽 聽 聽 聽cFile := "Factura_PROFORMA_"+alltrim( CStr(nID ) )
聽 聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽 聽cFile := "Factura_"+alltrim( CStr(nID ) )
聽 聽 聽 聽 聽 endif
聽 聽 聽 聽endif
聽 聽 endif
聽 聽 ::cFile := cFile + "_" + cValtoChar( oEmpresa:Ejercicio )+ iif( ::lCopia, "_copia", "" ) + iif( ::lSeleccion, "B","")
聽 聽 ::nID := nID
聽 聽
聽 聽 Super:New( ::Directory + ::cFile + ".pdf" )
RETURN Self
*********************************************************************
METHOD Print() CLASS TFacturaPDF
聽 聽 Local cQry, cQryCliente, oError
聽 聽 Local lResult := .T.
聽 聽 cQryCliente := [ select 聽cli.nombre as nombre , val.texto as valoracion, pago.descripcion as fpago, pago.idpago as idpago, cli.dias, cli.proveedor, codproveedor, 聽]+;
聽 聽 聽 聽 聽 聽 聽 聽 聽 [ 聽 聽 聽 聽 聽cli.nif, cli.direccion, cli.direccion2, cli.direccion3, cli.direccion4, textopago, iban, entidad, oficina, dc, cuenta ]+;
聽 聽 聽 聽 聽 聽 聽 聽 聽 [ from cliente cli ] +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 [ left join valoracion val on val.idvalor 聽= cli.idvalor 聽 ] +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 [ left join fpago pago 聽 聽 on pago.idpago 聽= cli.fk_idpago ] +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 [ where cli.idcliente= ]
聽 聽 if ::lAlbaran 聽 聽 聽 聽 // Empezamos por si es un albaran
聽 聽 聽 聽 if ::lCompras
聽 聽 聽 聽 聽 聽if ::lOfertas
聽 聽 聽 聽 聽 聽 聽 cQry := [ select a.id_oferta as idoferta , a.total as total, a.fecha as fecha, fk_idempresa , fk_idcliente , plazo] +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 [ from oferta a 聽] +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 [ where 聽fk_idempresa=] 聽+ CStr( oEmpresa:IdEmpresa 聽) + [ and 聽id_oferta = ]
聽 聽 聽 聽 聽 聽else
聽 聽 聽 聽 聽 聽 聽 cQry := [ select a.id_compra as idcompra , a.total as total, a.fecha as fecha, fk_idempresa , fk_idcliente , plazo] +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 [ from compra a 聽] +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 [ where 聽fk_idempresa=] 聽+ CStr( oEmpresa:IdEmpresa 聽) + [ and 聽id_compra = ]
聽 聽 聽 聽 聽 聽endif 聽 聽 聽 聽
聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽cQry := [ select a.id_albaran as idalbaran , a.total as total, a.fecha as fecha, 聽a.fk_factura as factura ,fk_idempresa , fk_idcliente ] +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽[ from albaran a 聽] +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽[ where 聽fk_idempresa=] 聽+ CStr( oEmpresa:IdEmpresa 聽) + [ and 聽id_albaran = ]
聽 聽 聽 聽 endif
聽 聽 聽 聽 try
聽 聽 聽 聽 聽 if ::lCompras
聽 聽 聽 聽 聽 聽 聽::oData 聽 聽:= oServer:Query( cQry + CStr( ::nId ) 聽) // Datos de Compra
聽 聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽 聽::oData 聽 聽:= oServer:Query( cQry + CStr( ::nId ) + " and seleccion=" +ClipValue2SQL( ::lSeleccion ) ) // Datos del Albaran
聽 聽 聽 聽 聽 endif 聽
聽 聽 聽 聽 聽 ::oCliente := oServer:Query( cQryCliente + CStr( ::oData:fk_idcliente ) ) 聽 聽 // Datos del Cliente
聽 聽 聽 聽 catch oError
聽 聽 聽 聽 聽 lResult := .F.
聽 聽 聽 聽 聽 MsgAlert( oError:Description + hb_osnewline() + cQry, "Alerta" )
聽 聽 聽 聽 end
聽 聽 else
聽 聽 聽 聽 cQry := [ select a.id_factura as idfactura , base, iva, total, fecha, vto, descripcion_pago as fpago, ]+;
聽 聽 聽 聽 聽 聽 聽 聽 [ 聽 fk_idempresa , fk_idcliente ] +;
聽 聽 聽 聽 聽 聽 聽 聽 [ from factura a 聽] +;
聽 聽 聽 聽 聽 聽 聽 聽 [ where 聽fk_idempresa=] 聽+ CStr( oEmpresa:IdEmpresa 聽) + [ and 聽id_factura = ]
聽 聽 聽 聽 try
聽 聽 聽 聽 聽 ::oData 聽 聽:= oServer:Query( cQry + CStr( ::nId ) + " and seleccion=" +ClipValue2SQL( ::lSeleccion ) ) 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 // Datos del Albaran
聽 聽 聽 聽 聽 ::oCliente := oServer:Query( cQryCliente + CStr( ::oData:fk_idcliente ) ) 聽 聽 // Datos del Cliente
聽 聽 聽 聽 聽 ::oCliente:FPago 聽:= ::oData:fPago 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽// La de la factura.
聽 聽 聽 聽 catch oError
聽 聽 聽 聽 聽 lResult := .F.
聽 聽 聽 聽 聽 MsgAlert( oError:Description + hb_osnewline() + cQry, 聽"Alerta" )
聽 聽 聽 聽 end
聽 聽 endif
聽 聽 if lResult
聽 聽 聽 ::Reset()
聽 聽 聽 ::Headers()
聽 聽 聽 ::Body()
聽 聽 聽 ::Footers()
聽 聽 聽 if ::lCopia
聽 聽 聽 聽 聽::Copia()
聽 聽 聽 endif
聽 聽 endif
RETURN NIL
*********************************************************************
METHOD Headers() CLASS TFacturaPDF
*********************************************************************
聽Local ctexto
聽::Plantilla( 9 )
聽if ::lAlbaran
聽 聽 UTILPDF ::oUtil 1,1.5 IMAGE "./gui/logotipo.jpg" SIZE 8,5 JPG
聽else
聽 聽 UTILPDF ::oUtil 1,1.5 IMAGE "./gui/logotipo.jpg" SIZE 8,5 JPG
聽endif
聽UTILPDF ::oUtil 1.5,6.5 IMAGE "./gui/imageiso.png" SIZE 4,2.5 聽 聽 聽 聽 // IMAGEISO
聽UTILPDF ::oUtil LINEA 4.064,10.54 TO 4.064,11.00
聽UTILPDF ::oUtil LINEA 4.064,10.54 TO 4.464,10.54
聽UTILPDF ::oUtil LINEA 4.064,19.04 TO 4.064,19.50 聽// up der hor
聽UTILPDF ::oUtil LINEA 4.064,19.50 TO 4.464,19.50 聽// up der vert
聽UTILPDF ::oUtil LINEA 8.428,10.54 TO 8.428,11.00
聽UTILPDF ::oUtil LINEA 8.028,10.54 TO 8.428,10.54
聽UTILPDF ::oUtil LINEA 8.428,19.04 TO 8.428,19.50
聽UTILPDF ::oUtil LINEA 8.028,19.50 TO 8.428,19.50
聽IF ::lAlbaran 聽 聽 聽 聽//2.2
聽 聽 if ::lCompras
聽 聽 聽 聽if ::lOfertas
聽 聽 聽 聽 聽 聽UTILPDF ::oUtil 7.0,1.5 聽 SAY "OFERTA" FONT ::aFonts[10] SIZE 15
聽 聽 聽 聽else 聽 聽
聽 聽 聽 聽 聽 聽UTILPDF ::oUtil 7.0,1.5 聽 SAY "PEDIDO" FONT ::aFonts[10] SIZE 15
聽 聽 聽 聽endif 聽 聽
聽 聽 else
聽 聽 聽 聽 UTILPDF ::oUtil 7.0,1.5 聽 SAY "ALBARAN" FONT ::aFonts[10] SIZE 15
聽 聽 endif 聽 聽
聽ELSE
聽 聽 IF ::lProforma
聽 聽 聽 聽UTILPDF ::oUtil 7.0,1.5 聽 SAY "FACTURA PROFORMA" FONT ::aFonts[10] SIZE 15
聽 聽 ELSE
聽 聽 聽 聽UTILPDF ::oUtil 7.0,1.5 聽 SAY "FACTURA" FONT ::aFonts[10] SIZE 15
聽 聽 ENDIF
聽ENDIF
IF ::lProforma
聽 聽UTILPDF ::oUtil 7.5,1.5 SAY "NUMERO: P/"+ CStr( ::nID ) FONT ::aFonts[10] SIZE 13
ELSE
聽 聽UTILPDF ::oUtil 7.5,1.5 SAY "NUMERO:"+ CStr( ::nID ) 聽 聽FONT ::aFonts[10] SIZE 13
ENDIF
聽 聽UTILPDF ::oUtil 8.0,1.5 SAY "Fecha:"+ Fecha( ::oData:Fecha ) FONT ::aFonts[10] SIZE 13
聽 聽 if 聽!Empty( ::oCliente:CodProveedor )
聽 聽 聽 聽 UTILPDF ::oUtil 8.5,1.5 SAY "Proveedor N: " + CStr( ::oCliente:codproveedor ) FONT ::aFonts[10]
聽 聽 endif
聽 聽 UTILPDF ::oUtil 5.0,11 聽SAY ::oCliente:Nombre 聽 聽 聽FONT ::aFonts[10] SIZE 10
聽 聽 UTILPDF ::oUtil 5.5,11 聽SAY ::oCliente:Direccion 聽 FONT ::aFonts[10] SIZE 10
聽 聽 UTILPDF ::oUtil 6.0,11 聽SAY ::oCliente:Direccion2 聽FONT ::aFonts[10] SIZE 10
聽 聽 UTILPDF ::oUtil 6.5,11 聽SAY ::oCliente:Direccion3 聽FONT ::aFonts[10] SIZE 10
聽 聽 UTILPDF ::oUtil 7.0,11 聽SAY ::oCliente:Direccion4 聽FONT ::aFonts[10] SIZE 10
聽 聽 UTILPDF ::oUtil 7.8,15 聽SAY "N.I.F/D.N.I: " + ::oCliente:NIF 聽FONT ::aFonts[10] SIZE 10
聽if !::lAlbaran 聽// Si no es un albaran
聽 聽 if empty( ::oCliente:TextoPago )
聽 聽 聽 聽UTILPDF ::oUtil 25.5,1.75 聽 SAY ::oCliente:FPago 聽FONT ::aFonts[10] SIZE 12 聽 聽 聽 聽 //oDbf:Fpago
聽 聽 else
聽 聽 聽 聽UTILPDF ::oUtil 24.70,4.75 聽SAY alltrim( ::oCliente:TextoPago ) FONT ::aFonts[2] SIZE 9
聽 聽 聽 聽UTILPDF ::oUtil 26,1.6 聽SAY ::oCliente:Iban 聽 聽 FONT ::aFonts[10] SIZE 10
聽 聽 聽 聽UTILPDF ::oUtil 26,3.2 聽SAY ::oCliente:Entidad 聽FONT ::aFonts[10] SIZE 10
聽 聽 聽 聽UTILPDF ::oUtil 26,4.8 聽SAY ::oCliente:Oficina 聽FONT ::aFonts[10] SIZE 10
聽 聽 聽 聽UTILPDF ::oUtil 26,6.3 聽SAY ::oCliente:DC 聽 聽 聽 FONT ::aFonts[10] SIZE 10
聽 聽 聽 聽UTILPDF ::oUtil 26,7.4 聽SAY ::oCliente:Cuenta 聽 FONT ::aFonts[10] SIZE 10
聽 聽 endif
聽 聽 UTILPDF ::oUtil 26,10.75 聽SAY cValtoChar( ::oData:Vto ) 聽 FONT ::aFonts[10] SIZE 12 聽//oDbf:Vto
聽 聽 UTILPDF ::oUtil 26,13.60 聽SAY cValtoChar( ::oData:Base ) 聽FONT ::aFonts[10] SIZE 12 聽//oDbf:Base
聽 聽 UTILPDF ::oUtil 26,15.60 聽SAY cValtoChar( ::oData:Iva 聽) 聽FONT ::aFonts[10] SIZE 12 聽//oDbf:Iva
聽 聽 UTILPDF ::oUtil 26,17.80 聽SAY cValtoChar( ::oData:Total ) FONT ::aFonts[10] SIZE 12 聽//oDbf:Total
聽endif
聽 if ::lAlbaran
聽 聽 聽cTexto := "Tu Empresa a pi帽on....."
聽 聽 聽UTILPDF ::oUtil 22, 0.5 聽SAY cTexto FONT ::aFonts[10] SIZE 7 ROTATE 90
聽 聽 聽UTILPDF ::oUtil 27.5,1.5 聽SAY "A estos precios se ha de sumar el I.V.A" FONT ::aFonts[1] SIZE 10
聽 else
聽 聽 聽cTexto := "Sociedad Inscrita en el Registro Mercantil de Barcelona."+;
聽 聽 聽 聽 聽 聽 聽 聽" Tomo XXXX, Inscripcion 1."
聽 聽 聽UTILPDF ::oUtil 22,0.5 聽SAY 聽cTexto 聽FONT ::aFonts[10] SIZE 7 ROTATE 90 聽
聽 endif
RETURN NIL
*********************************************************************
METHOD Body() CLASS TFacturaPDF
*********************************************************************
聽 聽 聽 Local oAlbaran, oError, cQry
聽 聽 聽 ::nLinea := 10.5 聽 聽// Comenzamos de nuevo lineas de albaran
聽 聽 聽 if ::lAlbaran
聽 聽 聽 聽 聽::Lineas( ::nId )
聽 聽 聽 else
聽 聽 聽 聽 聽// Lineas de albaranes
聽 聽 聽 聽 cQry := [ select id_albaran as idalbaran 聽from albaran 聽] +;
聽 聽 聽 聽 聽 聽 聽 聽 [ where 聽fk_idempresa=] 聽+ CStr( oEmpresa:IdEmpresa 聽) + [ and 聽fk_factura = ]
聽 聽 聽 聽 try
聽 聽 聽 聽 聽 oAlbaran 聽 聽:= oServer:Query( cQry + CStr( ::nId ) + 聽" and seleccion=" +ClipValue2SQL( ::lSeleccion ) + " order by id_albaran" ) // Datos del Albaran
聽 聽 聽 聽 catch oError
聽 聽 聽 聽 聽 MsgAlert( oError:Description + hb_osnewline() + cQry, "Alerta" )
聽 聽 聽 聽 end
聽 聽 聽 聽 while !oAlbaran:Eof()
聽 聽 聽 聽 聽 聽 聽 ::Lineas( oAlbaran:idalbaran )
聽 聽 聽 聽 聽 聽 聽 oAlbaran:Skip()
聽 聽 聽 聽 end while
聽 聽 聽 endif
RETURN Nil
*********************************************************************
METHOD Plantilla( nLinea ) CLASS TFacturaPDF
*********************************************************************
聽 Local nFila := 1
聽 Local cTexto
聽 if ::lAlbaran
聽 聽UTILPDF ::oUtil BOX nLinea,1.5 TO nLinea + 1,13.25 STROKE SIZE 0.1 FILLRGB (171/255),(218/255),(248/255) 聽 // Primera caja descripcion
聽 else
聽 聽UTILPDF ::oUtil BOX nLinea,1.5 TO nLinea + 1,3 聽 聽 STROKE SIZE 0.1 FILLRGB (171/255),(218/255),(248/255)
聽 聽UTILPDF ::oUtil BOX nLinea,3 聽 TO nLinea + 1,13.25 STROKE SIZE 0.1 FILLRGB (171/255),(218/255),(248/255)
聽 endif
聽 UTILPDF ::oUtil BOX nLinea,13.25 TO nLinea + 1,14.8 STROKE SIZE 0.1 FILLRGB (171/255),(218/255),(248/255)// FILLRGB (171/255),205/255,244/255
聽 UTILPDF ::oUtil BOX nLinea,14.8 聽TO nLinea + 1,17 聽 STROKE SIZE 0.1 FILLRGB (171/255),(218/255),(248/255)
聽 UTILPDF ::oUtil BOX nLinea,17 聽 聽TO nLinea + 1,19.5 STROKE SIZE 0.1 FILLRGB (171/255),(218/255),(248/255)
聽 if ::lAlbaran
聽 聽UTILPDF ::oUtil BOX nLinea+1,1.5 TO 24.0,19.5 STROKE SIZE 0.1
聽 else
聽 聽UTILPDF ::oUtil BOX nLinea+1,1.5 TO 24.0,19.5 STROKE SIZE 0.1
聽 聽UTILPDF ::oUtil LINEA nLinea+1,3 TO if(::lAlbaran,26.5,24),3 WITDH 0.5
聽 endif
聽 UTILPDF ::oUtil LINEA nLinea+1,13.25 TO 24,13.25 WITDH 0.1
聽 UTILPDF ::oUtil LINEA nLinea+1,14.8 聽TO 24,14.8 聽WITDH 0.1
聽 UTILPDF ::oUtil LINEA nLinea+1,17.0 聽TO 24,17 聽 聽WITDH 0.1
聽 nLinea += .25
聽 if ::lAlbaran
聽 聽 *UTILPRN ::oUtil nLinea + 0.25,1.65 聽SAY "Pedido" 聽 FONT oFnt
聽 else
聽 聽UTILPDF ::oUtil nLinea + 0.25,1.65 聽SAY "Albaran" 聽FONT ::aFonts[2] SIZE 9
聽 endif
聽 UTILPDF ::oUtil nLinea + 0.25,5 聽 聽SAY "Descripcion / Operaciones " FONT ::aFonts[5] SIZE 10
聽 UTILPDF ::oUtil nLinea + 0.25,13.3 SAY "Cantidad" 聽 FONT ::aFonts[5] SIZE 9
聽 UTILPDF ::oUtil nLinea + 0.25,15 聽 SAY "Precio U." 聽FONT ::aFonts[5] SIZE 9
聽 UTILPDF ::oUtil nLinea + 0.25,17.5 SAY "Totales" 聽 聽FONT ::aFonts[5] SIZE 10
聽IF !::lAlbaran
聽 聽 UTILPDF ::oUtil BOX 24.2,1.5 聽TO 26.5,19.5 STROKE SIZE 0.1
聽 聽 UTILPDF ::oUtil BOX 24.2,1.5 聽TO 25.0,19.5 STROKE SIZE 0.1 FILLRGB (171/255),(218/255),(248/255)
聽 聽 UTILPDF ::oUtil LINEA 24.2,13.25 TO 26.5,13.25 WITDH 0.1
聽 聽 UTILPDF ::oUtil LINEA 24.2,17 聽 聽TO 26.5,17 聽 聽WITDH 0.1
聽 聽 UTILPDF ::oUtil 24.70,1.75 聽 SAY "Forma de Pago:" FONT ::aFonts[2] SIZE 10
聽 聽 if !empty( ::oCliente:textopago )
聽 聽 聽 聽//TODO: Dibujar cajas de entidad bancaria
聽 聽 聽 UTILPDF ::oUtil LINEA 25,2.8 TO 26.5,2.8 WITDH 0.1
聽 聽 聽 UTILPDF ::oUtil LINEA 25,4.5 TO 26.5,4.5 WITDH 0.1
聽 聽 聽 UTILPDF ::oUtil LINEA 25,6.0 TO 26.5,6.0 WITDH 0.1
聽 聽 聽 UTILPDF ::oUtil LINEA 25,7.0 TO 26.5,7.0 WITDH 0.1
聽 聽 聽 UTILPDF ::oUtil LINEA 24.2,10.5 TO 26.5,10.5 WITDH 0.1
聽 聽 聽 UTILPDF ::oUtil LINEA 25.55,1.5 TO 25.55,10.5 WITDH 0.1
聽 聽 聽 // AQUI
聽 聽 聽 UTILPDF ::oUtil 25.5,1.6 聽SAY "IBAN" 聽 聽 FONT ::aFonts[2] SIZE 9
聽 聽 聽 UTILPDF ::oUtil 25.5,3.0 聽SAY "Entidad" 聽FONT ::aFonts[2] SIZE 9
聽 聽 聽 UTILPDF ::oUtil 25.5,4.6 聽SAY "Oficina" 聽FONT ::aFonts[2] SIZE 9
聽 聽 聽 UTILPDF ::oUtil 25.5,6.3 聽SAY "DC" 聽 聽 聽 FONT ::aFonts[2] SIZE 9
聽 聽 聽 UTILPDF ::oUtil 25.5,7.4 聽SAY "N.Cuenta" FONT ::aFonts[2] SIZE 9
聽 聽 else
聽 聽 聽 聽UTILPDF ::oUtil 24.70,1.75 聽 SAY "Forma de Pago:" FONT ::aFonts[2] SIZE 10
聽 聽 endif
聽 聽 UTILPDF ::oUtil 24.70,10.75 聽SAY "Vencimiento" 聽 聽FONT ::aFonts[2] SIZE 10
聽 聽 UTILPDF ::oUtil 24.70,13.75 聽SAY "Base" 聽 聽 聽 聽 聽 FONT ::aFonts[2] SIZE 10
聽 聽 UTILPDF ::oUtil 24.70,15.75 聽SAY "I.V.A" 聽 聽 聽 聽 聽FONT ::aFonts[2] SIZE 10
聽 聽 UTILPDF ::oUtil 24.70,17.75 聽SAY "TOTAL" 聽 聽 聽 聽 聽FONT ::aFonts[2] SIZE 12
聽ENDIF
聽IF ::lAlbaran
聽 聽 UTILPDF ::oUtil BOX 24.2,1.5 聽TO 25.8,10.5
聽 聽 if ::lCompras
聽 聽 聽 聽if ::lOfertas
聽 聽 聽 聽else
聽 聽 聽 聽 聽 UTILPDF ::oUtil 25,2.0 聽SAY _UTF_8( "- PLAZO DE ENTREGA : " + Str( ::oData:Plazo, 3 ) + " dias" )
聽 聽 聽 聽endif 聽
聽 聽 else 聽
聽 聽 聽 聽UTILPDF ::oUtil 25,2.0 聽SAY 聽"- PLAZO DE ENTREGA : " + Str( 30, 3 ) + " dias"
聽 聽 endif 聽
聽 聽 UTILPDF ::oUtil 25.5,2.0 聽SAY "- DEVOLVER COPIA COMO ACUSE DE RECIBO"
聽ENDIF
Return nil
**********************************************************************************
**********************************************************************************
METHOD Separator( nSpace, lBody ) CLASS TFacturaPDF
聽 聽IF ::nLinea >= ::nEndBody
聽 聽 聽 ::Eject()
聽 聽 聽 ::nLinea := 10.5
聽 聽 聽 ::Headers()
聽 聽 聽 ::Footers()
聽 聽ELSEIF Super:Separator( nSpace )
聽 聽 聽 ::Headers()
聽 聽 聽 ::Footers()
聽 聽ENDIF
聽 Return NIL
聽 *******************************************************************************
/* Funcion que nos comprueba si tenemos que realizar una pagina nueva
聽 nLinea > 26 Si es mayor de 26 cms ( A4 )
聽 nSuma 聽:= La caja de total tiene el final de linea en la linea 27*/
*******************************************************************************
METHOD CompLinea( nSuma ) CLASS TFACTURAPDF
聽DEFAULT nSuma := 0
聽IF If( ::lAlbaran,::nLinea >= ( 23.5 + nSuma 聽), ::nLinea >=( 23.5 +nSuma ) ) .OR. ::nLinea < 5 // nLinea < 4 para la caja del total
聽 聽 ::nLinea := 10.5
聽 聽 ::AddPage() // Nueva Pagina
聽 聽 if ::lCabecera 聽 // Si queremos cabecera en todas las paginas
聽 聽 聽 聽::nLinea := 10.5
聽 聽 聽 聽::Headers( )
聽 聽 聽 聽::Footers()
聽 聽 endif
聽 聽return .t.
聽ENDIF
Return .F.
*******************************************************************************
/* Reseteamos valores */
*******************************************************************************
METHOD Reset() CLASS TFACTURAPDF
聽 ::nLinea := 10.5 // Comenzamos de nuevo lineas de albaran
聽 ::nTotal := 0 聽// Empezamos a totalizar
Return Nil
*******************************************************************************
/* Cuando es una copia Rev2 */
*******************************************************************************
METHOD Copia() 聽CLASS TFACTURAPDF
聽 Local oFont
聽 Local cCopia := "ALBARAN ES COPIA"
聽 if ::lCopia 聽//.AND. ::nVeces >= 2
聽 聽 聽 聽if ::lAlbaran
聽 聽 聽 聽 聽 if ::lCompras
聽 聽 聽 聽 聽 聽 聽if ::lOfertas
聽 聽 聽 聽 聽 聽 聽 聽 cCopia := "OFERTA ES COPIA"
聽 聽 聽 聽 聽 聽 聽else 聽
聽 聽 聽 聽 聽 聽 聽 聽 cCopia := "PEDIDO ES COPIA"
聽 聽 聽 聽 聽 聽 聽endif
聽 聽 聽 聽 聽 endif
聽 聽 聽 聽else
聽 聽 聽 聽 聽 聽cCopia := "FACTURA ES COPIA"
聽 聽 聽 聽endif
聽 聽 聽 聽UTILPDF ::oUtil if(::lAlbaran,27.3,28.5),; 聽 //25,22
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽if(::lAlbaran,1.5,1.5) ; 聽 聽//.5,1
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽SAY cCopia FONT ::aFonts[10] SIZE 52 聽COLOR RGB (200/255),(200/255),(200/255)
聽 endif
return NIL
*******************************************************************************
// Lineas de Albaran Cliente
*******************************************************************************
METHOD Lineas( nIdAlbaran ) CLASS TFACTURAPDF
聽 聽 聽Local cQry
聽 聽 聽static nAlbaran := 0
聽 聽 聽if ::lCompras
聽 聽 聽 聽 if ::lOfertas
聽 聽 聽 聽 聽 聽cQry 聽 := [ SELECT descripcion,cantidad,precio_u,precio_t FROM lineas_oferta where fk_idoferta = ] + CStr( nIdAlbaran ) +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽[ and fk_idempresa=] 聽+ CStr( oEmpresa:IdEmpresa 聽) 聽+[ order by idlinea ]
聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽cQry 聽 := [ SELECT descripcion,cantidad,precio_u,precio_t FROM lineas_compra where fk_idcompra = ] + CStr( nIdAlbaran ) +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽[ and fk_idempresa=] 聽+ CStr( oEmpresa:IdEmpresa 聽) 聽+[ order by idlinea ]
聽 聽 聽 聽 endif 聽 聽 聽 聽 聽
聽 聽 聽else
聽 聽 聽 聽 聽cQry 聽 := [ SELECT descripcion,cantidad,precio_u,precio_t FROM lineas_albaran where fk_idalbaran = ] + CStr( nIdAlbaran ) +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽[ and fk_idempresa=] 聽+ CStr( oEmpresa:IdEmpresa 聽) 聽+ [ and seleccion=] + ClipValue2SQL( ::lSeleccion ) + [ order by idlinea ]
聽 聽 聽endif 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽::oSlave 聽:= oServer:Query( cQry 聽)
聽 聽 聽 while !::oSlave:Eof()
聽 聽 聽 聽 聽 聽 聽if ::lAlbaran
聽 聽 聽 聽 聽 聽 聽 聽 ::nFila := 4.1
聽 聽 聽 聽 聽 聽 聽else
聽 聽 聽 聽 聽 聽 聽 聽 聽if !Empty( nIdAlbaran ) .AND. nAlbaran != nIdAlbaran
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 UTILPDF Self:oUtil Self:nLinea,1.65 SAY StrZero( nIdAlbaran,6 ) FONT ::aFonts[1] SIZE 9
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 nAlbaran := nIdAlbaran
聽 聽 聽 聽 聽 聽 聽 聽endif
聽 聽 聽 聽 聽 聽 聽 聽::nFila := 4.1
聽 聽 聽 聽 聽 聽 聽endif
聽 聽 聽 聽 聽 聽 聽if ::lAlbaran
聽 聽 聽 聽 聽 聽 聽 聽 UTILPDF ::oUtil Self:nLinea,1.6 SAY ::oSlave:Descripcion FONT ::aFonts[1] SIZE 9
聽 聽 聽 聽 聽 聽 聽else
聽 聽 聽 聽 聽 聽 聽 聽 UTILPDF ::oUtil Self:nLinea,3.1 SAY ::oSlave:Descripcion FONT ::aFonts[1] SIZE 9
聽 聽 聽 聽 聽 聽 聽endif
聽 聽 聽 聽 聽 聽 聽if !Empty( ::oSlave:Cantidad )
聽 聽 聽 聽 聽 聽 聽 聽 聽UTILPDF ::oUtil Self:nLinea,::nFila+9.4 SAY Str( ::oSlave:Cantidad,5 ) FONT ::aFonts[1] SIZE 9
聽 聽 聽 聽 聽 聽 聽endif
聽 聽 聽 聽 聽 聽 聽if !Empty( ::oSlave:Precio_U )
聽 聽 聽 聽 聽 聽 聽 聽 UTILPDF ::oUtil Self:nLinea,Self:nFila+10.65 SAY Str( ::oSlave:Precio_U,10,2 ) FONT ::aFonts[1] SIZE 9
聽 聽 聽 聽 聽 聽 聽endif
聽 聽 聽 聽 聽 聽 聽if !Empty( ::oSlave:Precio_T )
聽 聽 聽 聽 聽 聽 聽 聽 聽UTILPDF ::oUtil Self:nLinea,::nFila+12.9 SAY Str( ::oSlave:Precio_T,11,2 ) FONT ::aFonts[1] SIZE 9
聽 聽 聽 聽 聽 聽 聽 聽 ::nTotal += ::oSlave:Precio_T
聽 聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 ::nLinea += .5 ; ::CompLinea()
聽 聽 聽 聽 ::oSlave:Skip()
聽 聽 聽 end while
聽 聽 聽 // La ultima linea no debe de ser visualizada.!!! Para factura( albaranes) Mirar
聽 聽 聽 // METHOD LineasFac()
聽 聽 聽 //17/06/2002
聽 聽 聽 IF ::lAlbaran
聽 聽 聽 聽 聽IF !::oSlave:Eof()
聽 聽 聽 聽 聽 聽 ::nLinea += .5 ; ::CompLinea()
聽 聽 聽 聽 聽 聽 UTILPDF ::oUtil LINEA ::nLinea,1.5 TO ::nLinea, 19.5 //PEN ::oPen
聽 聽 聽 聽 聽 聽 ::nLinea += .5 ; ::CompLinea()
聽 聽 聽 聽 聽ENDIF
聽 聽 聽 ENDIF
聽 聽::nLinea += 0.25 ; ::CompLinea( )
聽 聽IF ::lAlbaran
聽 聽 聽 ::nLinea += 0.75 ; ::CompLinea( )
聽 聽 聽 ::CajaTotal()
聽 聽ENDIF
聽 聽nAlbaran := 0 //11-07-02 Reinicializamos para el siguiente albaran.
RETURN NIL
*******************************************************************************
聽// Dibujamos caja del Total
*******************************************************************************
METHOD CajaTotal() CLASS TFACTURAPDF
聽IF ::lAlbaran .AND. ::nTotal > 0
聽 聽 ::nLinea -= 聽0.75 聽// Volvemos para atras para dibujar caja total
聽 聽 IF ::oSlave:LastRec() > 0
聽 聽 聽 聽 聽::CompLinea( 1 )
聽 聽 聽 聽 UTILPDF ::oUtil BOX ::nLinea,13.25 TO ::nLinea + 1,14.8
聽 聽 聽 聽 UTILPDF ::oUtil BOX ::nLinea,14.8 聽TO ::nLinea + 1,19.5
聽 聽 聽 聽 UTILPDF ::oUtil Self:nLinea+.6,13.4 聽SAY "Total" 聽 聽 聽 聽 聽 聽 聽FONT ::aFonts[2] SIZE 12
聽 聽 聽 聽 UTILPDF ::oUtil Self:nLinea+.6,15.62 SAY Str( ::nTotal,11,2 ) FONT ::aFonts[2] SIZE 14
聽 聽 ENDIF
聽ENDIF
Return Nil
*******************************************************************************
* Impresion del MEMO de las descripciones ALbaran/ Factura
*******************************************************************************
METHOD MEMO( cText ) CLASS TFACTURAPDF
聽 聽 Local cLinea,nLineas,oFont
聽 聽 FOR nLineas := 1 TO 聽MLCOUNT( cText, 56 ) 聽//53
聽 聽 聽 聽 cLinea := MEMOLINE( cText, 56, nLineas )
聽 聽 聽 聽 if ::lAlbaran
聽 聽 聽 聽 聽 聽 UTILPDF ::oUtil Self:nLinea,2 SAY cLinea FONT ::aFonts[1]
聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽 UTILPDF ::oUtil Self:nLinea,3.2 SAY cLinea FONT ::aFonts[1]
聽 聽 聽 聽 endif
聽 聽 聽 聽 ::nLinea += .5 ; ::CompLinea( .5 )
聽 聽 NEXT
Return NIL
/* Fecha en Spanish para clipper 5.3 English */
Static Func Fecha( dDate )
Local cMes
DO CASE
聽 聽CASE Month(dDate) == 1 ; cMes := "Enero"
聽 聽CASE Month(dDate) == 2 ; cMes := "Febrero"
聽 聽CASE Month(dDate) == 3 ; cMes := "Marzo"
聽 聽CASE Month(dDate) == 4 ; cMes := "Abril"
聽 聽CASE Month(dDate) == 5 ; cMes := "Mayo"
聽 聽CASE Month(dDate) == 6 ; cMes := "Junio"
聽 聽CASE Month(dDate) == 7 ; cMes := "Julio"
聽 聽CASE Month(dDate) == 8 ; cMes := "Agosto"
聽 聽CASE Month(dDate) == 9 ; cMes := "Septiembre"
聽 聽CASE Month(dDate) == 10; cMes := "Octubre"
聽 聽CASE Month(dDate) == 11; cMes := "Noviembre"
聽 聽CASE Month(dDate) == 12; cMes := "Diciembre"
ENDCASE
Return ( Str(Day(dDate),2)+" "+ cMes +" del "+Str(Year(dDate),4) )Muchas gracias por el aporte Rafa, y muchas gracias por la "vieja" TImprime, la cual a algunos nos "ense帽贸" a imprimir en Windows.
Dos preguntas, a ser posible:
1) 驴 No hubiera sido buena cosa que en vez de crear una TImprimePdf haber modificado la TImprime con una DATA lToPdf para que la impresion se realizara a Pdf y directamente hubiera funcionado todo el codigo existente de la TImprime ? Quiza haya algun problema que yo desconozco..
2) 驴 Necesita harupdf algun componente, dll, ocx... para usarse ?
Gracias por todo
PD. No veo en el fuente de la TImprimePdf la estampaci贸n de la versi贸n. Personalmente me gusta poner a todo numero de versi贸n, ayuda mucho a saber qu茅 estad铆o de la clase es.
#include "fivewin.ch"
#include "utilprn.ch"
function main()
imprime init "spot de prueba"
page
imprime datetime
endpage
imprime end
return (nil)Error description: Error BASE/1003 Variable does not exist: SELF
Args:
Stack Calls
===========
Called from: Z:\32_bits\testtimprime\source\test.PRG => MAIN( 5 )
#include "fivewin.ch"
#include "utilprn.ch"
class TApp from TImprime
method new() constructor
end class
//--------------( ) ---------------------
method new()
imprime init "hola"
imprime end
return (self)
//--------------( ) ---------------------
function main()
local a:= TApp():new()
return (nil)karinha wrote:Yo no puedo decir, pero esto es muy interesante:
http://fivewin-contributions.googlecode.com/files/Bucaneros.pdf
Salu2
::aFonts 聽:= { ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Courier", 聽 聽 聽 聽 聽 聽 聽 聽 聽; // 1
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Courier-Bold", 聽 聽 聽 聽 聽 聽 ; // 2
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Courier-Oblique", 聽 聽 聽 聽 聽; // 3
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Courier-BoldOblique", 聽 聽 聽; // 4
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Helvetica", 聽 聽 聽 聽 聽 聽 聽 聽; // 5
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Helvetica-Bold", 聽 聽 聽 聽 聽 ; // 6
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Helvetica-Oblique", 聽 聽 聽 聽; // 7
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Helvetica-BoldOblique", 聽 聽; // 8
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Times-Roman", 聽 聽 聽 聽 聽 聽 聽; // 9
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Times-Bold", 聽 聽 聽 聽 聽 聽 聽 ; // 10
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Times-Italic", 聽 聽 聽 聽 聽 聽 ; // 11
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Times-BoldItalic", 聽 聽 聽 聽 ; // 12
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Symbol", 聽 聽 聽 聽 聽 聽 聽 聽 聽 ; // 13
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "ZapfDingbats", 聽 聽 聽 聽 聽 聽 ; // 14
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Courier New";
聽 聽 聽 聽 聽 聽 聽 聽 聽 }HPDF_LoadTTFontFromFile ( tPdf:pPdf, "c:\windows\fonts\arial.ttf", HPDF_TRUE)Angel, pudiste compilarlo para FWH y Borland ?. Con la versi贸n de Harbour 3.1 y compilandolo con hbmk2.exe funciona pero al compilarlo con Fwh1412 y Bcc587 no se queja pero no me crea el .pdf. Muchas gracias
Saludos
Function CargaFuentesPdf (tPdf, aFuentes)
/* =================================================================
聽 聽 tPdf - Objeto harupdf
聽 聽 aFuentes - Array de fuentes a incrustar en el PDF (Ej. {"Arial","Courier New","Verdana"}
聽 聽==================================================================
*/
Local cDirFonts:=GetWinDir(), nC:=0, aFicheros:={}, cTemporal, aFuentesCreadas:={}, nFuentes:=Len(aFuentes)
聽 /* Obtengo el directorio de windows y comprueba si existe una fuente por defecto
聽 聽 Esto lo hago porque en sesi贸n de Terminal Server GetWinDir() devuelve una carpeta temporal del usuario en
聽 聽 lugar del de la instalaci贸n de Windows */
聽
聽 If !File (cDirFonts+"\fonts\arial.ttf") // Compruebo si existe arial.ttf que aparece en todas las instalaciones de windows que he probado.
聽 聽 cDirFonts:="c:\windows"
聽 Endif
聽 cDirFonts:=cDirFonts+"\fonts\"
聽
聽 For nC:=1 To nFuentes
聽 聽 cTemporal:=cDirFonts+GetProfString( "Fonts", aFuentes[nC]+" (TrueType)" )
聽 聽
聽 聽 If File (cTemporal)
聽 聽 聽 aAdd (aFicheros,cTemporal)
聽 聽 Else
聽 聽 聽 MsgInfo ("El tipo de letra "+aFuentes[nC]+" utilizado en el formato no se encuentra en el sistema. Se reemplazar谩 por el tipo Arial","Atenci贸n")
聽 聽 聽 aAdd (aFicheros,cDirFonts+"arial.ttf")
聽 聽 Endif
聽 Next
聽
聽 // Cargo los ficheros en el formato DPF
聽 For nC:=1 To nFuentes
聽 聽 cTemporal:=HPDF_LoadTTFontFromFile ( tPdf:pPdf, aFicheros[nC], HPDF_TRUE)
聽 聽 If Len(Alltrim(cTemporal))<>0
聽 聽 聽 aAdd (aFuentesCreadas,cTemporal)
聽 聽 Else
聽 聽 聽 MsgInfo ("No se ha podido incrustar el tipo de letra "+aFuentes[nC]+" en el archivo PDF. Ser谩 sustituida por el tipo Arial","Atenci贸n")
聽 聽 聽 aAdd (aFuentesCreadas,"ArialMT")
聽 聽 Endif
聽 Next
Return (aFuentesCreadas)horacio wrote:Angel, pudiste compilarlo para FWH y Borland ?. Con la versi贸n de Harbour 3.1 y compilandolo con hbmk2.exe funciona pero al compilarlo con Fwh1412 y Bcc587 no se queja pero no me crea el .pdf. Muchas gracias
Saludos
Gracias por contestar, pudiste entonces compilarlo con Fwh1204 y bcc ? Muchas gracias.
Saludos
No me hizo falta, la versi贸n de harbour que tengo instalada ya incluye la librer铆a.