Sobre a pdfclass
Moderador: Moderadores
Sobre a pdfclass
Pessoal, acho sou o único aqui que não usa a pdfclass. Vocês poderiam me ajudar com algumas dicas ? Ela funciona no Linux tb ? Tem algum tutorial ou alguns exemplos ? Onde eu pego a versão mais atualizada ?
Sobre a pdfclass
A versão atualizada sempre estará nesse link : https://github.com/JoseQuintas/sefazclass
No momento só funciona para Windows.
Se tiver alguma dúvida que não conseguiu tirar vendo os exemplos, só invocar o Quintas que ele é o pai da criança.
No momento só funciona para Windows.
Se tiver alguma dúvida que não conseguiu tirar vendo os exemplos, só invocar o Quintas que ele é o pai da criança.
Marcelo Neves
https://produto.mercadolivre.com.br/MLB ... 0067609615
whatsapp (41) 99786-3995
http://harbourdeveloper.blogspot.com
marcelo.souza.das.neves@gmail.com
https://produto.mercadolivre.com.br/MLB ... 0067609615
whatsapp (41) 99786-3995
http://harbourdeveloper.blogspot.com
marcelo.souza.das.neves@gmail.com
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Sobre a pdfclass
Sim Linux também.
Só precisa verificar como se abre PDF em Linux.
Só precisa verificar como se abre PDF em Linux.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- Itamar M. Lins Jr.
- Administrador

- Mensagens: 7928
- Registrado em: 30 Mai 2007 11:31
- Localização: Ilheus Bahia
- Curtiu: 1 vez
Sobre a pdfclass
Ola!
PDF no Linux, além do "abridor" padrão que cada distribuição tem.
O Firefox abre, Chrome, etc,etc...
Saudações,
Itamar M. Lins Jr.
PDF no Linux, além do "abridor" padrão que cada distribuição tem.
O Firefox abre, Chrome, etc,etc...
Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Itamar M. Lins Jr.
-
Fernando queiroz
- Usuário Nível 4

- Mensagens: 779
- Registrado em: 13 Nov 2014 00:41
- Localização: Porto Alegre/RS
Sobre a pdfclass
Código: Selecionar todos
************************************************************************************************************
STATIC FUNCTION RELATORIO_INDIVIDUAL( oServer, UFORNEC, IMPRESSORA )
************************************************************************************************************
LOCAL TOTGERAL:=0.00;
, nLinha;
, nPagina;
, nMaxCol;
, oPDF;
, oQuery;
, cQuery;
, oQuery1;
oQuery1:= oServer:Execute("SELECT * FROM FLAG")
cQuery:="SELECT pagar.FORNECEDOR_ID, pagar.NRAZ_SOC, pagar.DOCUMENTO, pagar.PARCELA, pagar.DATVEN, pagar.VALOR, pagar.DESHIS FROM pagar WHERE pagar.BAIXA = '0' AND pagar.FORNECEDOR_ID='" + STRZERO(UFORNEC,11,0) + "'"
oQuery := oServer:Execute(cQuery)
IF oQuery:Eof()
hwg_msginfo("NÃO EXISTE DADOS DISPONIVEIS PARA ESTE RELATÓRIO", "ATENÇÃO!!!")
RETURN NIL
ENDIF
oPDF := PDFClass()
IF oPDF == NIL
hwg_msginfo("Falha da criação do objeto PDF")
RETURN .F.
ENDIF
oPDF:cFileName := "C:\TEMP\PAGAR"+strzero(HB_RandomInt(1, 99999999),8,0)+'.PDF'
oPDF:cDefaultPrinter := IMPRESSORA
oPDF:SetType( PDFCLASS_LANDSCAPE )
IF oPDF:nPrinterType == PDFCLASS_LANDSCAPE
oPDF:Begin()
nLinha := 100
nPagina := 1
nMaxCol := oPDF:MaxCol()
DO WHILE ! oQuery:Eof()
IF nLinha > 96
oPDF:AddPage()
oPDF:DrawBox( 0, 0, 9, 41, Nil, Nil, Nil ) // box esquerdo
oPDF:DrawImageSize( 0.5, 0.5, 8, 39, "logotipo.jpg" ) // logotipo
oPDF:DrawBox( 0, 41, 9, 117, Nil, Nil, Nil ) // box centro
oPDF:DrawText( 2.0, 42, RTRIM(oQuery1:Fields( "n_xNome" ):Value), nil, 10, "Helvetica-Bold", Nil, Nil )
oPDF:DrawText( 3.5, 42, RTRIM(oQuery1:Fields( "n_xLgr" ):Value) + ', ' + RTRIM(oQuery1:Fields( "n_nro" ):Value), Nil, 8, "Helvetica", Nil, Nil )
oPDF:DrawText( 5.0, 42,'BAIRRO - ' + RTRIM(oQuery1:Fields( "n_xBairro" ):Value), Nil, 8, "Helvetica", Nil, Nil )
oPDF:DrawText( 6.4, 42, "CEP " +oQuery1:Fields( "n_CEP" ):Value + ' - ' + RTRIM(oQuery1:Fields( "n_xMun" ):Value) + ' - ' + oQuery1:Fields( "n_xUF" ):Value + " - FONE: " +oQuery1:Fields( "n_fone" ):Value, Nil, 8, "Helvetica", Nil, Nil )
oPDF:DrawText( 8.0, 42, 'CNPJ-'+RTRIM(oQuery1:Fields( "n_CNPJ" ):Value) + ' Insc.Est.-' + RTRIM(oQuery1:Fields( "n_IE" ):Value) , Nil, 10, "Helvetica-Bold", Nil, Nil )
oPDF:DrawBox( 0, nMaxCol, 9, 41, Nil, Nil, Nil ) // box direito
oPDF:DrawText( 2, 120, "CONTAS A PAGAR 1" , Nil, 10, "Helvetica", Nil, Nil )
oPDF:DrawText( 4, 120, "PAGINA Nr.: " + STRZERO(nPagina,4,0), Nil, 10, "Helvetica", Nil, Nil )
oPDF:DrawText( 6, 120, "DATA: " + DTOC(M->DAT_HOJE), Nil, 10, "Helvetica", Nil, Nil )
oPDF:DrawText( 8, 120, "HORA: " + TIME(), Nil, 10, "Helvetica", Nil, Nil )
oPDF:DrawBox( 9, 0, 12, nMaxCol, Nil, Nil, Nil )
oPDF:DrawText( 11, 3, "Fornecedor: "+STRZERO(oQuery:Fields( "FORNECEDOR_ID" ):Value,11,0)+"-"+oQuery:Fields( "nraz_soc" ):Value , Nil, 10, "Helvetica-Bold", Nil, Nil )
oPDF:DrawBox( 12, 0, 14.5, nMaxCol, Nil, Nil, Nil )
oPDF:DrawText( 14, 1, "TITULO", Nil, 10, "Helvetica-Bold", Nil, Nil )
oPDF:DrawText( 14, 31, "VENCIMENTO" , Nil, 10, "Helvetica-Bold", Nil, Nil )
oPDF:DrawText( 14, 50, " VALOR", Nil, 10, "Helvetica-Bold", Nil, Nil )
oPDF:DrawText( 14, 75, "HISTORICO", Nil, 10, "Helvetica-Bold", Nil, Nil )
nLinha := 16
nPagina += 1
ENDIF
oPDF:DrawText( nLinha, 1, STRZERO(oQuery:Fields( "DOCUMENTO" ):Value,11,0) + "/" + STRZERO(oQuery:Fields( "PARCELA" ):Value,2,0), Nil, 10, "Courier-Bold", Nil, Nil )
oPDF:DrawText( nLinha, 31, oQuery:Fields( "DATVEN" ):Value, Nil, 10, "Courier-Bold", Nil, Nil )
oPDF:DrawText( nLinha, 50, oQuery:Fields( "VALOR" ):Value, "@E 99,999,999.99", 10, "Courier-Bold", Nil, Nil )
oPDF:DrawText( nLinha, 75, oQuery:Fields( "DESHIS" ):Value,"@S45", 10, "Courier-Bold", Nil, Nil )
nLinha +=2
TOTGERAL+=oQuery:Fields( "VALOR" ):Value
oQuery:MoveNext()
ENDDO
IF TOTGERAL # 0.00
oPDF:DrawBox( nLinha, 0, nLinha+3, nMaxCol, Nil, Nil, Nil )
oPDF:DrawText( nLinha+2, 13, "TOTAL A PAGAR ==> "+transform(TOTGERAL,"@E 99,999,999,999.99") , Nil, 10, "Courier-Bold", Nil, Nil )
ENDIF
oPDF:End( )
ENDIF
oPDF:PrintPreview( )
RETURN NIL Código: Selecionar todos
/*
ZE_PDFCLASS - GERACAO DE PDF
José Quintas
*/
// Calculo da folha: cm * 0.03937 * 72
// onde cm = medida em cm
// 0.03937 = fator de conversao de mm para polegadas
// 72 = resolucao DPI default do PDF
// HPDF_Page_SetWidth( oPage, nResultado )
// HPDF_Page_SetHeight( oPage, nResultado )
// TODO: As medidas da página só estão disponíveis após existir uma página
#require "hbhpdf.hbc"
#require "hbct.hbc"
#include "hbclass.ch"
#include "inkey.ch"
#include "hwgui.ch"
#define PDFCLASS_DRAWMODE_ROWCOL 1
#define PDFCLASS_DRAWMODE_CENTIMETER 2
#define PDFCLASS_DRAWMODE_PIXEL 3
#define PDFCLASS_PORTRAIT 1
#define PDFCLASS_LANDSCAPE 2
#define PDFCLASS_TXT 3
#define PDFCLASS_ROLLS 4
#define PDFCLASS_PENSIZE 0.5
CREATE CLASS PDFClass
VAR oPdf
VAR oPage
VAR nPageWidth INIT 595.28 // A4
VAR nPageHeight INIT 841.89 // A4
VAR cFileName INIT ""
VAR nRow INIT 999
VAR nCol INIT 0
VAR nAngle INIT 0
VAR cFontName INIT "Courier"
VAR nFontSize INIT 9
VAR nLineHeight INIT 1.3
VAR nTopMargin INIT 25
VAR nLeftMargin INIT 25
VAR nBottomMargin INIT 25
VAR nRightMargin INIT 25
VAR nPrinterType INIT PDFCLASS_PORTRAIT
VAR nPdfPage INIT 0
VAR nPageNumber INIT 0
VAR acHeader INIT {}
VAR cCodePage INIT "WinAnsiEncoding" // "CP1252"
VAR nDrawMode INIT PDFCLASS_DRAWMODE_ROWCOL
VAR lDrawZebrado INIT .F.
VAR cAppEmpresaNome INIT ""
VAR cDefaultPrinter INIT WIN_PRINTERGETDEFAULT()
METHOD AddPage()
METHOD RowToPDFRow( nValue )
METHOD ColToPDFCol( nValue )
METHOD MaxRow()
METHOD MaxCol()
METHOD Row( nAddRows )
METHOD Col( nAddCols )
METHOD DrawBoxTitleText( nTop, nLeft, nBottom, nRight, cTitle, cText, cPicture, nAlign, nFontSizeText, cFontNameText, nFontSizeTitle, cFontNameTitle )
METHOD DrawText( nTop, nLeft, xValue, cPicture, nFontSize, cFontName, nAngle, anRGB )
METHOD DrawLine( nTop, nLeft, nBottom, nRight, nPenSize )
METHOD DrawBox( nTop, nLeft, nBottom, nRight, nPenSize, nFillType, anRGB )
METHOD DrawBoxSize( nTop, nLeft, nHeight, nWidth, nPenSize, nFillType, anRGB )
METHOD DrawImageBox( nTop, nLeft, nBottom, nRight, cJPEGFile )
METHOD DrawImageSize( nRow, nCol, nHeight, nWidth, cJPEGFile )
METHOD DrawMemImageBox( nTop, nLeft, nBottom, nRight, cJPEGMem )
METHOD DrawMemImageSize( nRow, nCol, nHeight, nWidth, cJPEGMem )
METHOD Cancel()
METHOD PrnToPdf( cInputFile )
METHOD SetType( nPrinterType )
METHOD PageHeader()
METHOD PageFooter()
METHOD MaxRowTest( nRows )
METHOD SetInfo( cAuthor, cCreator, cTitle, cSubject )
METHOD Begin()
METHOD End( lPreview )
METHOD DrawZebrado( nNivel, lDraw )
METHOD SelectPrinterType( nPrinterType )
METHOD PrintOptions( )
METHOD PrintPreview( )
ENDCLASS
METHOD Row( nAddRows ) CLASS PDFCLass
IF nAddRows != NIL
::nRow += nAddRows
::MaxRowTest()
ENDIF
RETURN ::nRow
METHOD Col( nAddCols ) CLASS PDFClass
IF nAddCols != NIL
::nCol += nAddCols
ENDIF
RETURN ::nCol
METHOD Begin() CLASS PDFClass
IF ::nPrinterType == PDFCLASS_TXT
// ::cFileName := MyTempFile( "LST" )
SET PRINTER TO ( ::cFileName )
SetPrc( 0, 0 )
SET DEVICE TO PRINT
ELSE
// ::cFileName := MyTempFile( "PDF" )
::oPdf := HPDF_New()
HPDF_SetCompressionMode( ::oPDF, HPDF_COMP_ALL )
HPDF_SetCurrentEncoder( ::oPDF, ::cCodePage )
//HPDF_SetPassword( ::oPDF, "owner", "" )
//HPDF_SetPermission( ::oPDF, HPDF_ENABLE_READ + HPDF_ENABLE_PRINT ) // + HPDF_ENABLE_EDIT_ALL + HPDF_ENABLE_COPY + HPDF_ENABLE_EDIT )
::SetInfo()
ENDIF
RETURN NIL
METHOD End( lPreview ) CLASS PDFClass
hb_Default( @lPreview, .T. )
::PageFooter()
// Mensagem()
IF ::nPrinterType == PDFCLASS_TXT
SET PRINTER TO
SET DEVICE TO SCREEN
SetPrc(0,0)
IF lPreview
// PrintPreview( ::cFileName, ( ::nPageWidth == 132 ) ) // compress=true for 132 cols
fErase( ::cFileName )
ELSE
PrintBegin()
@ 0,0 SAY MemoRead( ::cFileName )
PrintEnd()
fErase( ::cFileName )
ENDIF
ELSE
// IF ::nPdfPage == 0
// ::AddPage()
// ::DrawText( 10, 10, "NENHUM CONTEUDO (NO CONTENT)",, ::nFontSize * 2 )
// ENDIF
IF File( ::cFileName )
fErase( ::cFileName )
ENDIF
HPDF_SaveToFile( ::oPdf, ::cFileName )
HPDF_Free( ::oPdf )
// ShellExecuteOpen( ::cFileName )
// WAPI_ShellExecute( NIL, "OPEN", ::cFileName , NIL,, NIL )
ENDIF
RETURN NIL
METHOD SetInfo( cAuthor, cCreator, cTitle, cSubject ) CLASS PDFClass
IF ::nPrinterType == PDFCLASS_TXT
RETURN NIL
ENDIF
hb_Default( @cAuthor, "SGC Sistemas" )
hb_Default( @cCreator, "Harupdf" )
hb_Default( @cTitle, "SGC" )
hb_Default( @cSubject, cTitle )
IF ! Empty( cAuthor )
HPDF_SetInfoAttr( ::oPDF, HPDF_INFO_AUTHOR, cAuthor )
ENDIF
IF ! Empty( cCreator )
HPDF_SetInfoAttr( ::oPDF, HPDF_INFO_CREATOR, cCreator )
ENDIF
IF ! Empty( cTitle )
HPDF_SetInfoAttr( ::oPDF, HPDF_INFO_TITLE, cTitle )
ENDIF
IF ! Empty( cSubject )
HPDF_SetInfoAttr( ::oPdf, HPDF_INFO_SUBJECT, cSubject )
ENDIF
HPDF_SetInfoDateAttr( ::oPDF, HPDF_INFO_CREATION_DATE, { Year( Date() ), Month( Date() ), Day( Date() ), Val( Substr( Time(), 1, 2 ) ), Val( Substr( Time(), 4, 2 ) ), Val( Substr( Time(), 7, 2 ) ), "+", 4, 0 } )
RETURN NIL
METHOD SetType( nPrinterType ) CLASS PDFClass
IF nPrinterType != NIL
::nPrinterType := nPrinterType
ENDIF
DO CASE
CASE ::nPrinterType == PDFCLASS_PORTRAIT
::nFontSize := 9
::nPageWidth := 841.89 // A4
::nPageHeight := 595.28 // A4
CASE ::nPrinterType == PDFCLASS_LANDSCAPE
::nFontSize := 6
::nPageWidth := 595.28 // A4
::nPageHeight := 841.89 // A4
CASE ::nPrinterType == PDFCLASS_TXT
::nPageWidth := 132
::nPageHeight := 66
CASE ::nPrinterType == PDFCLASS_ROLLS
::nFontSize := 9
::nPageWidth := 226.77 // ROLLS
::nPageHeight := 836.22 // ROLLS
::nLeftMargin := 10
::nRightMargin := 10
::nTopMargin := 7
::nBottomMargin := 7
ENDCASE
RETURN NIL
/*
Note: rotate page is bad for screen, better to use automatic adjust when print
*/
METHOD AddPage() CLASS PDFClass
IF ::nPrinterType != PDFCLASS_TXT
::oPage := HPDF_AddPage( ::oPdf )
// // HPDF_Page_SetSize( ::oPage, HPDF_PAGE_SIZE_A4, iif( ::nPrinterType == PDFCLASS_LANDSCAPE, HPDF_PAGE_PORTRAIT, HPDF_PAGE_LANDSCAPE ) )
// IF ::nPrinterType == PDFCLASS_PORTRAIT
// HPDF_Page_SetWidth( ::oPage, ::nPageHeight )
// HPDF_Page_SetHeight( ::oPage, ::nPageWidth )
// //HPDF_Page_SetRotate( ::oPage, iif( ::nPrinterType == PDFCLASS_LANDSCAPE, 0, 90 ) )
// ELSE
HPDF_Page_SetWidth( ::oPage, ::nPageWidth )
HPDF_Page_SetHeight( ::oPage, ::nPageHeight )
// ENDIF
HPDF_Page_SetFontAndSize( ::oPage, HPDF_GetFont( ::oPdf, ::cFontName, ::cCodePage ), ::nFontSize )
ENDIF
::nRow := 0
RETURN NIL
METHOD Cancel() CLASS PDFClass
IF ::nPrinterType != PDFCLASS_TXT
HPDF_Free( ::oPdf )
ENDIF
RETURN NIL
METHOD DrawBoxTitleText( nTop, nLeft, nBottom, nRight, cTitle, cText, cPicture, nAlign, nFontSizeText, cFontNameText, nFontSizeTitle, cFontNameTitle ) CLASS PDFClass
hb_Default( @nFontSizeTitle, 6 )
hb_Default( @cFontNameTitle, ::cFontName )
hb_Default( @nFontSizeText, ::nFontSize )
hb_Default( @cFontNameText, ::cFontName )
hb_Default( @cPicture, "" )
hb_Default( @nAlign, HPDF_TALIGN_LEFT )
::DrawBox( nTop, nLeft, nBottom, nRight )
cText := Transform( cText, cPicture )
::nCol := nRight
nTop := ::RowToPDFRow( nTop )
nLeft := ::ColToPDFCol( nLeft )
nBottom := ::RowToPDFRow( nBottom )
nRight := ::ColToPDFCol( nRight )
HPDF_Page_SetFontAndSize( ::oPage, HPDF_GetFont( ::oPDF, cFontNameTitle, ::cCodePage ), nFontSizeTitle )
HPDF_Page_BeginText( ::oPage )
HPDF_Page_TextRect( ::oPage, nLeft + 2, nTop, nRight - 2, nBottom, cTitle, nAlign, NIL )
HPDF_Page_EndText( ::oPage )
HPDF_Page_SetFontAndSize( ::oPage, HPDF_GetFont( ::oPDF, cFontNameText, ::cCodePage ), nFontSizeText )
HPDF_Page_BeginText( ::oPage )
HPDF_Page_TextRect( ::oPage, nLeft + 2, nTop - nFontSizeTitle - 1, nRight - 2, nBottom, cText, nAlign, NIL )
HPDF_Page_EndText( ::oPage )
RETURN NIL
METHOD DrawText( nTop, nLeft, xValue, cPicture, nFontSize, cFontName, nAngle, anRGB ) CLASS PDFClass
LOCAL nRadian , cTexto
hb_Default( @nFontSize, ::nFontSize )
hb_Default( @cFontName, ::cFontName )
hb_Default( @cPicture, "" )
hb_Default( @nAngle, ::nAngle )
cTexto := Transform( xValue, cPicture )
::nCol := nLeft + Len( cTexto )
IF ::nPrinterType == PDFCLASS_TXT
@ nTop, nLeft SAY cTexto
ELSE
nTop := ::RowToPDFRow( nTop )
nLeft := ::ColToPDFCol( nLeft )
HPDF_Page_SetFontAndSize( ::oPage, HPDF_GetFont( ::oPdf, cFontName, ::cCodePage ), nFontSize )
IF anRGB != NIL
HPDF_Page_SetRGBFill( ::oPage, anRGB[ 1 ], anRGB[ 2 ], anRGB[ 3 ] )
HPDF_Page_SetRGBStroke( ::oPage, anRGB[ 1 ], anRGB[ 2], anRGB[ 3] )
ENDIF
HPDF_Page_BeginText( ::oPage )
nRadian := ( nAngle / 180 ) * 3.141592
HPDF_Page_SetTextMatrix( ::oPage, Cos( nRadian ), Sin( nRadian ), -Sin( nRadian ), Cos( nRadian ), nLeft, nTop )
HPDF_Page_ShowText( ::oPage, cTexto )
HPDF_Page_EndText( ::oPage )
IF anRGB != NIL
HPDF_Page_SetRGBFill( ::oPage, 0, 0, 0 )
HPDF_Page_SetRGBStroke( ::oPage, 0, 0, 0 )
ENDIF
ENDIF
RETURN NIL
METHOD DrawLine( nTop, nLeft, nBottom, nRight, nPenSize ) CLASS PDFClass
IF ::nPrinterType == PDFCLASS_TXT
IF nTop == nBottom // Matrix can draw line in a single row
nTop := Round( nTop, 0 )
nLeft := Round( nLeft, 0 )
@ nTop, nLeft SAY Replicate( "-", nRight - nLeft )
::nCol := Col()
ENDIF
ELSE
hb_Default( @nPenSize, PDFCLASS_PENSIZE )
nTop := ::RowToPDFRow( nTop )
nLeft := ::ColToPDFCol( nLeft )
nBottom := ::RowToPDFRow( nBottom )
nRight := ::ColToPDFCol( nRight )
HPDF_Page_SetLineWidth( ::oPage, nPenSize )
HPDF_Page_MoveTo( ::oPage, nLeft, nTop )
HPDF_Page_LineTo( ::oPage, nRight, nBottom )
HPDF_Page_Stroke( ::oPage )
ENDIF
RETURN NIL
METHOD DrawImageBox( nTop, nLeft, nBottom, nRight, cJPEGFile ) CLASS PDFClass
LOCAL oImage, nWidth, nHeight
IF ::nPrinterType == PDFCLASS_TXT // .OR. ! File( cJPEGFile )
RETURN NIL
ENDIF
nWidth := ::ColToPdfCol( nRight - nLeft ) - ::ColToPdfCol( 0 )
nHeight := ( ::RowToPdfRow( 0 ) - ::RowToPdfRow( nBottom - nTop ) )
nBottom := ::RowToPDFRow( nBottom )
nLeft := ::ColToPdfCol( nLeft )
oImage := HPDF_LoadJPEGImageFromFile( ::oPdf, cJPEGFile )
HPDF_Page_DrawImage( ::oPage, oImage, nLeft, nBottom, nWidth, nHeight )
RETURN NIL
METHOD DrawImageSize( nRow, nCol, nHeight, nWidth, cJPEGFile ) CLASS PDFClass
::DrawImageBox( nRow, nCol, nRow + nHeight, nCol + nWidth, cJPEGFile )
RETURN NIL
METHOD DrawMemImageBox( nTop, nLeft, nBottom, nRight, cJPEGMem ) CLASS PDFClass
LOCAL oImage, nWidth, nHeight
IF ::nPrinterType == PDFCLASS_TXT
RETURN NIL
ENDIF
IF cJPEGMem == NIL
RETURN NIL
ENDIF
nWidth := ::ColToPdfCol( nRight - nLeft ) - ::ColToPdfCol( 0 )
nHeight := ( ::RowToPdfRow( 0 ) - ::RowToPdfRow( nBottom - nTop ) )
nBottom := ::RowToPDFRow( nBottom )
nLeft := ::ColToPdfCol( nLeft )
oImage := HPDF_LoadJPEGImageFromMem( ::oPDF, cJPEGMem, Len( cJPEGMem ) )
HPDF_Page_DrawImage( ::oPage, oImage, nLeft, nBottom, nWidth, nHeight )
RETURN NIL
METHOD DrawMemImageSize( nRow, nCol, nHeight, nWidth, cJPEGMem ) CLASS PDFClass
::DrawMemImageBox( nRow, nCol, nRow + nHeight, nCol + nWidth, cJPEGMem )
RETURN NIL
METHOD DrawBox( nTop, nLeft, nBottom, nRight, nPenSize, nFillType, anRGB ) CLASS PDFClass
LOCAL nWidth, nHeight
IF ::nPrinterType == PDFCLASS_TXT
RETURN NIL
ENDIF
hb_Default( @nFillType, 1 )
hb_Default( @nPenSize, PDFCLASS_PENSIZE )
nWidth := nRight - nLeft
nHeight := nBottom - nTop
nTop := ::RowToPDFRow( nTop )
nLeft := ::ColToPDFCol( nLeft )
nWidth := ::ColToPdfCol( nWidth ) - ::ColToPdfCol( 0 )
nHeight := -( ::RowToPdfRow( 0 ) - ::RowToPdfRow( nHeight ) )
HPDF_Page_SetLineWidth( ::oPage, nPenSize )
IF anRGB != NIL
HPDF_Page_SetRGBFill( ::oPage, anRGB[ 1 ], anRGB[ 2 ], anRGB[ 3 ] )
HPDF_Page_SetRGBStroke( ::oPage, anRGB[ 1 ], anRGB[ 2 ], anRGB[ 3 ] )
ENDIF
HPDF_Page_Rectangle( ::oPage, nLeft, nTop, nWidth, nHeight )
IF nFillType == 1
HPDF_Page_Stroke( ::oPage ) // borders only
ELSEIF nFillType == 2
HPDF_Page_Fill( ::oPage ) // inside only
ELSE
HPDF_Page_FillStroke( ::oPage ) // all
ENDIF
IF anRGB != NIL
HPDF_Page_SetRGBStroke( ::oPage, 0, 0, 0 )
HPDF_Page_SetRGBFill( ::oPage, 0, 0, 0 )
ENDIF
RETURN NIL
METHOD DrawBoxSize( nTop, nLeft, nHeight, nWidth, nPenSize, nFillType, anRGB ) CLASS PDFClass
::DrawBox( nTop, nLeft, nTop + nHeight, nLeft + nWidth, nPenSize, nFillType, anRGB )
RETURN NIL
METHOD RowToPDFRow( nValue ) CLASS PDFClass
DO CASE
CASE ::nDrawMode == PDFCLASS_DRAWMODE_ROWCOL
nValue := ::nPageHeight - ::nBottomMargin - ( nValue * ::nFontSize * ::nLineHeight )
CASE ::nDrawMode == PDFCLASS_DRAWMODE_CENTIMETER
nValue := ::nPageHeight - ( nValue * 2.83464 )
CASE ::nDrawMode == PDFCLASS_DRAWMODE_PIXEL
nValue := ::nPageHeight - nValue
ENDCASE
RETURN nValue
METHOD ColToPDFCol( nValue ) CLASS PDFClass
DO CASE
CASE ::nDrawMode == PDFCLASS_DRAWMODE_ROWCOL
nValue := nValue * ::nFontSize / 1.666 + ::nLeftMargin
CASE ::nDrawMode == PDFCLASS_DRAWMODE_CENTIMETER
nValue := nValue * 2.83464 // 72 * 0.03937
CASE ::nDrawMode == PDFCLASS_DRAWMODE_PIXEL
// Nothing to do
ENDCASE
RETURN nValue
METHOD MaxRow() CLASS PDFClass
LOCAL nPageHeight, nMaxRow
IF ::nPrinterType == PDFCLASS_TXT
RETURN 63
ENDIF
nPageHeight := ::nPageHeight - ::nTopMargin - ::nBottomMargin
nMaxRow := Int( nPageHeight / ( ::nFontSize * ::nLineHeight ) )
RETURN nMaxRow
METHOD MaxCol() CLASS PDFClass
LOCAL nPageWidth, nMaxCol
IF ::nPrinterType == PDFCLASS_TXT
RETURN ::nPageWidth
ENDIF
nPageWidth := ::nPageWidth - ::nRightMargin - ::nLeftMargin
nMaxCol := Int( nPageWidth / ::nFontSize * 1.666 )
RETURN nMaxCol
METHOD PrnToPdf( cInputFile ) CLASS PDFClass
LOCAL cTxtReport, cTxtPage, cTxtLine, nRow
cTxtReport := MemoRead( cInputFile ) + Chr(12)
TokenInit( @cTxtReport, Chr(12) )
DO WHILE ! TokenEnd()
cTxtPage := TokenNEXT( cTxtReport ) + hb_eol()
IF Len( cTxtPage ) > 5
IF Substr( cTxtPage, 1, 1 ) == Chr(13)
cTxtPage := Substr( cTxtPage, 2 )
ENDIF
::AddPage()
nRow := 0
DO WHILE At( hb_eol(), cTxtPage ) != 0
cTxtLine := Substr( cTxtPage, 1, At( hb_eol(), cTxtPage ) - 1 )
cTxtPage := Substr( cTxtPage, At( hb_eol(), cTxtPage ) + 2 )
::DrawText( nRow++, 0, cTxtLine )
ENDDO
ENDIF
ENDDO
RETURN NIL
METHOD PageHeader() CLASS PDFClass
LOCAL nCont
IF Len( ::acHeader ) > 0
IF ::nPageNumber != 0 .AND. ::nRow != 0 .AND. ::nPdfPage != 0
::PageFooter()
ENDIF
ENDIF
::nPdfPage += 1
::nPageNumber += 1
::nRow := 0
// Mensagem( "Impressão em andamento, folha " + StrZero( ::nPageNumber, 7 ) )
::AddPage()
IF Len( ::acHeader ) > 0
::DrawText( 0, 0, ::cAppEmpresaNome )
::DrawText( 0, ( ::MaxCol() - Len( ::acHeader[ 1 ] ) ) / 2, ::acHeader[ 1 ] )
::DrawText( 0, ::MaxCol() - 12, "Folha " + StrZero( ::nPageNumber, 6 ) )
::DrawLine( 0.5, 0, 0.5, ::MaxCol() )
::nRow := 2
IF Len( ::acHeader ) > 1
FOR nCont = 2 TO Len( ::acHeader )
IF ! Empty( ::acHeader[ nCont ] )
IF nCont == 2
::DrawText( ::nRow++, 0, Padc( AllTrim( ::acHeader[ 2 ] ), ::MaxCol() ) )
ELSE
::DrawText( ::nRow++, 0, ::acHeader[ nCont ] )
ENDIF
ENDIF
NEXT
::DrawLine( ::nRow - 0.5, 0, ::nRow++ - 0.5, ::MaxCol() )
::nRow++
ENDIF
ENDIF
::nCol := 0
RETURN NIL
METHOD PageFooter() CLASS PDFClass
LOCAL cTxt
MEMVAR m_Prog
IF Len( ::acHeader ) != 0 .AND. ::nPdfPage != 0 // adicionada checagem de nPdfPage
cTxt := "JPA/" + m_Prog + "/" + Right( Dtos( Date() ), 6 ) + SoNumeros( Time() )
::DrawLine( ::MaxRow(), 0, ::MaxRow(), ::MaxCol() - Len( cTxt ) )
::DrawText( ::MaxRow(), ::MaxCol() - Len( cTxt ), cTxt )
ENDIF
RETURN NIL
METHOD MaxRowTest( nRows ) CLASS PDFClass
hb_Default( @nRows, 0 )
IF ::nRow > ::MaxRow() - 2 - nRows
::PageHeader()
ENDIF
RETURN NIL
METHOD DrawZebrado( nNivel, lDraw ) CLASS PDFClass
LOCAL nColor
hb_Default( @nNivel, 1 )
hb_Default( @lDraw, .F. )
nNivel := iif( nNivel < 1, 1, iif( nNivel > 5, 5, nNivel ) )
nColor := ( 10 - nNivel ) / 10 // 0.9, 0.8, 0.7, 0.6
IF nNivel != 1 .OR. ::lDrawZebrado .OR. lDraw
::DrawBox( ::nRow - 1 + 0.3, 0, ::nRow + 0.3, ::MaxCol(), 0.2, 2, { nColor, nColor, nColor } )
ENDIF
IF ! lDraw
::lDrawZebrado := ! ::lDrawZebrado
ENDIF
RETURN NIL
METHOD SelectPrinterType( nPrinterType ) CLASS PDFClass
// wAchoice( 5, 10, txtSaida(), @nPrinterType, "Formato de Saída" )
::SetType( nPrinterType )
RETURN ( LastKey() != K_ESC )
FUNCTION TxtSaida()
RETURN { "PDF Paisagem", "PDF Retrato", "Matricial" }
FUNCTION ConfirmaImpressao()
LOCAL lPrint
lPrint := hwg_MsgYesNo( "Confirma a impressão?" )
// IF lPrint
// Mensagem( "Relatório sendo efetuado... ESC interrompe" )
// ENDIF
RETURN lPrint
FUNCTION PrintSelect( cImpressora )
LOCAL acPrinterList, nOpc := 1, lOk, nCont
acPrinterList := Win_PrinterList()
FOR nCont = 1 TO Len( acPrinterList )
IF acPrinterList[ nCont ] == Win_PrinterGetDefault()
nOpc := nCont
EXIT
ENDIF
NEXT
// WAchoice( 6, Int( MaxCol() / 4 ), acPrinterList, @nOpc, "Impressora" )
lOk := ( LastKey() != K_ESC )
IF lOk
cImpressora := acPrinterList[ nOpc ]
hwg_Exclamation( cImpressora )
// Win_PrinterSetDefault( acPrinterList[ nOpc ] )
ENDIF
RETURN lOk
/*
STATIC FUNCTION PrintRaw( cFileTxt, cReportName )
LOCAL cPrinter := ""
hb_Default( @cReportName, "win_PrintFileRaw" )
cPrinter := Win_PrintDlgDc( @cPrinter,,, )
IF ! Empty( cPrinter )
Win_PrintFileRaw( cPrinter, cFileTxt, cReportName )
ENDIF
RETURN NIL
*/
FUNCTION AppPrinterType( xValue )
STATIC AppPrinterType := PDFCLASS_PORTRAIT
IF xValue != NIL .AND. xValue > 0 .AND. xValue <= Len( TxtSaida() )
AppPrinterType := xValue
ENDIF
RETURN AppPrinterType
FUNCTION PrintBegin()
SET DEVICE TO PRINT
SetPRC( 0, 0 )
RETURN NIL
FUNCTION PrintEnd()
SET DEVICE TO SCREEN
SET PRINTER TO
SetPRC( 0, 0 )
RETURN NIL
METHOD PrintPreview( ) CLASS PDFClass
IF ! EMPTY(::cDefaultPrinter)
WAPI_ShellExecute(NIL, 'OPEN', hb_Dirbase()+'SUMATRA\SumatraPDF.EXE', '"' + ::cFileName + '" -print-to "' + ::cDefaultPrinter + '"',, NIL )
// WAPI_ShellExecute(NIL, 'PRINT', '"' + ::cFileName + '"', '"' + ::cDefaultPrinter + '"',, NIL )
ELSE
WAPI_ShellExecute( NIL, "OPEN", ::cFileName , NIL,, NIL )
ENDIF
return nil
METHOD PrintOptions( ) CLASS PDFClass
LOCAL oDlg;
, oLabel1;
, oCombo1, oCombo2;
, vCombo1;
, nCombo2;
, oLabel2;
, oOwnerbutton2, oOwnerbutton1 ;
, aPrn := Win_PrinterList( .t., .f. );
, iCarga;
, oBitmap1;
, oLabel3;
// IF Empty( aPrn )
// IF hwg_MsgYesNo( "ATENÇÃO !!! Não foi possivel localizar Nenhuma impressora Instalada no Windows, Deseja Instalar uma Agora ?", "Aviso do Sistema" )
// RunApplet_imp( "AddPrinter" )
// ENDIF
// RETURN nil
// ENDIF
for iCarga=1 to len(aPrn)
IF aPrn[iCarga,1] = WIN_PRINTERGETDEFAULT()
::cDefaultPrinter := WIN_PRINTERGETDEFAULT()
vCombo1:=iCarga
exit
ENDIF
next
INIT DIALOG oDlg TITLE "Impressão de Relatórios" ;
ICON MEMVAR->SGC_ICON ;
AT 0,0 SIZE 658,215 CLIPPER NOEXIT
@ 21,48 BITMAP oBitmap1 SHOW 'REL_PRINT' FROM RESOURCE TRANSPARENT STRETCH 0 ;
SIZE 90,90
@ 18,6 SAY oLabel1 CAPTION "INFORME AS OPÇÕES DE IMPRESSÃO" SIZE 644,22 ;
STYLE SS_CENTER ;
FONT HFont():Add( '',0,-16,700,,,)
@ 120,50 SAY oLabel3 CAPTION "Impressora:" SIZE 118,24 ;
STYLE SS_CENTER +WS_DLGFRAME
@ 252,50 GET COMBOBOX oCombo1 VAR vCombo1 ITEMS aPRN SIZE 375,24 ;
ON CHANGE {|| ::cDefaultPrinter := Alltrim(aPrn[vCombo1,1] ) }
@ 252,85 GET COMBOBOX oCombo2 VAR nCombo2 ;
ITEMS {"Relatório Bobina (40 col)","Relatório A4 (80 col)"} SIZE 226,24
@ 120,85 SAY oLabel2 CAPTION "Formato:" SIZE 118,24 ;
STYLE SS_CENTER +WS_DLGFRAME
@ 404,145 OWNERBUTTON oOwnerbutton1 SIZE 98,32 ;
TEXT 'Visualizar' ;
COORDINATES 28, 0, 0, 0 ;
BITMAP 'print_preview' FROM RESOURCE TRANSPARENT;
COORDINATES 5, 0, 0, 0;
ON CLICK {|| IIF(nCombo2 = 1, ::SetType( PDFCLASS_ROLLS ), ::SetType( PDFCLASS_LANDSCAPE )),hwg_Enddialog(), oDlg:lresult:=.T., ::cDefaultPrinter := "" }
@ 525,145 OWNERBUTTON oOwnerbutton2 SIZE 98,32 ;
TEXT 'Imprimir' ;
COORDINATES 30, 0, 0, 0 ;
BITMAP 'print_impressora' FROM RESOURCE TRANSPARENT;
COORDINATES 5, 0, 0, 0;
ON CLICK {|| IIF(nCombo2 = 1, ::SetType( PDFCLASS_ROLLS ), ::SetType( PDFCLASS_LANDSCAPE )),hwg_Enddialog(), oDlg:lresult:=.T. }
ACTIVATE DIALOG oDlg CENTER
RETURN oDlg:lresult
HARBOUR 3.2, HWGUI 2.23 B3, SEFAZCLASS, PDFClass, ADO + MariaDB/MySQL, RMChart
Sobre a pdfclass
Obrigado a todos. Pretendo começar a estudar a pdfclass nos próximos dias.
Gero meus relatórios a moda antiga, com Prow e Pcol com set printer. Se der pra criar sem muita mudança vai ser ótimo. Acho que vai dar certo
Gero meus relatórios a moda antiga, com Prow e Pcol com set printer. Se der pra criar sem muita mudança vai ser ótimo. Acho que vai dar certo
Sobre a pdfclass
Comecei a testar
O link de onde fiz o clone : https://github.com/JoseQuintas/pdfclass
Não vi documentação, vou procurar aqui no fórum. Se alguém tiver algum tutorial/manual poderia disponibilizar ?
Obrigado
O link de onde fiz o clone : https://github.com/JoseQuintas/pdfclass
Não vi documentação, vou procurar aqui no fórum. Se alguém tiver algum tutorial/manual poderia disponibilizar ?
Obrigado
Sobre a pdfclass
Fui no google e tem algumas referencias
Achei esse simples, esse é que é bom para iniciar :
http://forums.fivetechsupport.com/viewt ... =6&t=31280
Tive que realizar umas alterações porque não funcionou de primeira, provavelmente porque a classe mudou de 2015 para cá. Ficou assim:
Esse aqui é o equivalente ao Hello World
Achei esse simples, esse é que é bom para iniciar :
http://forums.fivetechsupport.com/viewt ... =6&t=31280
Tive que realizar umas alterações porque não funcionou de primeira, provavelmente porque a classe mudou de 2015 para cá. Ficou assim:
Código: Selecionar todos
PROCEDURE Main
LOCAL oPDF, nCont, nType
oPDF := PDFClass():New()
oPDF:acHeader := { "TEST REPORT PDF CLASS" }
oPDF:cFileName := "test.pdf"
oPDF:Begin()
FOR nCont = 1 TO 1000
oPDF:MaxRowTest()
oPDF:DrawText( oPDF:nRow++, 0, nCont )
NEXT
oPDF:End()
RETURN
Sobre a pdfclass
Detalhes sobre a geração da classe
Se você não está familiarizado com a geração de libs no harbour seguem algumas observações
(1) Após baixar a lib gere com hbmk2 pdfclass
(2) O arquivo lib vai ser gerado na pasta addons do harbour (só a título de informação)
(3) Eu copiei o pdfclass.hbc para a minha pasta (onde tem os fontes do sistema a ser gerado)
(4) Compilei assim hbmk2 meuarquivo.prg pdfclass.hbc
Se você não está familiarizado com a geração de libs no harbour seguem algumas observações
(1) Após baixar a lib gere com hbmk2 pdfclass
(2) O arquivo lib vai ser gerado na pasta addons do harbour (só a título de informação)
(3) Eu copiei o pdfclass.hbc para a minha pasta (onde tem os fontes do sistema a ser gerado)
(4) Compilei assim hbmk2 meuarquivo.prg pdfclass.hbc
Sobre a pdfclass
Eu criei esse exemplo aqui para mostrar como gerar o PDF de uma base de dados, mas estou tendo problemas.
(1) O projeto onde vou usar a lib foi desenvolvido usando a codificação UTF-8, mas no PDF gerado sai incorreto.
(2) Não entendi a lógica do Header, saiu desalinhado.
Vou colar o código abaixo, mas no zip em anexo tem o projeto pronto para ser gerado e também tem um pdf com um exemplo que foi gerado.
Valeu
(1) O projeto onde vou usar a lib foi desenvolvido usando a codificação UTF-8, mas no PDF gerado sai incorreto.
(2) Não entendi a lógica do Header, saiu desalinhado.
Vou colar o código abaixo, mas no zip em anexo tem o projeto pronto para ser gerado e também tem um pdf com um exemplo que foi gerado.
Código: Selecionar todos
// Adaptado de https://pctoledo.org/forum/viewtopic.php?f=43&t=24256&p=141013&hilit=pdfclass#p141013
#define P_ESPACOS_ENTRE_COLUNAS SPACE(2)
PROCEDURE Main
LOCAL oPDF, cRow
LOCAL aHeader := {}
// Configuração do ambiente
REQUEST HB_CODEPAGE_UTF8EX
hb_cdpSelect( "UTF8EX" )
Set( _SET_DATEFORMAT, "yyyy-mm-dd" )
? "Testando UTF-8"
? "çáéíôã Atenção Água à"
// Cabeçalho
AADD( aHeader , "RELATÓRIO DE TESTES" )
AADD( aHeader , "Código Nome do Cliente Dt Compra Valor" )
AADD( aHeader , "--------- -------------------------- ---------- ---------------" )
TestDBF() // Gerando dbf de testes
USE test
oPDF := PDFClass():New()
oPDF:acHeader := aHeader // Adicionando os cabeçalhos
oPDF:cFileName := "test.pdf"
oPDF:Begin()
DO WHILE .NOT. EOF()
oPDF:MaxRowTest() // Quebra de página
// Dados
cRow := ""
cRow += StrZero( FIELD->CODIGO , 9 )
cRow += P_ESPACOS_ENTRE_COLUNAS
cRow += LEFT( FIELD->NOME , 26 )
cRow += P_ESPACOS_ENTRE_COLUNAS
cRow += DTOC( FIELD->DTCOMPRA )
cRow += P_ESPACOS_ENTRE_COLUNAS
cRow += TRANSFORM( FIELD->VALOR , "@RE 999,999,999.99")
//
oPDF:DrawText( oPDF:nRow++, 0, cRow ) // Impressão
SKIP
ENDDO
oPDF:End()
RETURN
PROCEDURE TestDBF()
LOCAL aTest := {} , x
IF .NOT. FILE( "test.dbf")
? "Gerando dados para teste"
AADD( aTest , { "CODIGO","N" , 12 , 0 })
AADD( aTest , { "NOME" , "C" , 30 , 0 })
AADD( aTest , { "DTCOMPRA" , "D" , 8 , 0 })
AADD( aTest , { "VALOR" , "N" , 12, 2 })
DBCREATE( "test.dbf" , aTest )
USE test
FOR x := 1 TO 500
APPEND BLANK
REPLACE CODIGO WITH x
REPLACE NOME WITH "RICK SPENCE " + STRZERO(x,3)
REPLACE DTCOMPRA WITH DATE()-x
REPLACE VALOR WITH x*2
NEXT
CLOSE test
ENDIF
RETURN
Sobre a pdfclass
Fui pesquisar e vi que o HaruPDF não tem suporte à UTF-8. Já contornei esse problema fazendo as devidas conversões antes de mandar para a PDFClass.
Vi também que aquele problema com o cabeçalho que eu apresentei no post anterior dá pra ser resolvido da seguinte forma :
Agora tenho uma outra dúvida : tem como fazer relatório "zebrado", tipo aqueles formulários antigos ?
Vi também que aquele problema com o cabeçalho que eu apresentei no post anterior dá pra ser resolvido da seguinte forma :
Código: Selecionar todos
AADD( aHeader , "RELATÓRIO DE TESTES" )
AADD( aHeader , "" ) <---------------- Acrescentando essa linha
AADD( aHeader , "Código Nome do Cliente Dt Compra Valor" )
AADD( aHeader , "--------- -------------------------- ---------- ---------------" )
Sobre a pdfclass
Outra coisa, pessoal
Daria para personalizar aquelas linhas de cabeçalho ? Tipo, não poderia ficar só a primeira linha ?
Valeu
Daria para personalizar aquelas linhas de cabeçalho ? Tipo, não poderia ficar só a primeira linha ?
Valeu
Sobre a pdfclass
Com as modificações ficou assim :
Falta só o zebrado e tirar aquela segunda linha horizontal.
Falta só o zebrado e tirar aquela segunda linha horizontal.
Sobre a pdfclass
Criei uma classe que usa a pdfclass, chamei ela de vpdfclass
Essa classe mantêm a pdfclass intacta, nada nela foi alterado, o objetivo é agilizar a criação de relatórios "a moda antiga" em PDF.
Ela totaliza, alinha, define máscara, faz quebra de grupos, gera pdf a partir de arquivos em utf8 ou winansi usando os recursos da PDFClass.
Anexei um zip com a ze_pdfclass para facilitar, mas quem quiser pode usar a sua própria porque podem ter customizado ela.
No zip que eu anexei tem o seguinte
ze_pdfclass.prg e pdfclass.hbc (A PDFClass original que eu baixei do github)
vpdfclass, vpdfclasstext e vpdfclasstextcolumn (eu criei essas)
hbmk.hbm (só as configurações para teste)
diagram.pdf (o diagrama das classes que eu criei)
Com certeza poderia ter ficado melhor, os cabeçalhos estão feios, queria ter feito estilo zebrado e, quem sabe, uma logomarca. Mas do jeito que está talvez ajude alguém, é essa a ideia. Espero não ter reinventado a roda kkkkk. Na realidade o trabalho maior é da ze_pdfclass do Quintas.
Se alguém quiser incrementar pode olhar no diagrama.pdf que tem um bom guia.
Para testar descompacte em uma pasta e faça assim
hbmk2 ex01
E executa o teste.exe
O teste.exe vai gerar o report.pdf (use seu leitor de PDF para ver)
(e assim por diante, até ex06)
O arquivo executável SEMPRE RECEBE o nome de teste.exe e o PDF gerado chama-se report.pdf
Um trecho de um dos exemplos do zip
Essa classe mantêm a pdfclass intacta, nada nela foi alterado, o objetivo é agilizar a criação de relatórios "a moda antiga" em PDF.
Ela totaliza, alinha, define máscara, faz quebra de grupos, gera pdf a partir de arquivos em utf8 ou winansi usando os recursos da PDFClass.
Anexei um zip com a ze_pdfclass para facilitar, mas quem quiser pode usar a sua própria porque podem ter customizado ela.
No zip que eu anexei tem o seguinte
ze_pdfclass.prg e pdfclass.hbc (A PDFClass original que eu baixei do github)
vpdfclass, vpdfclasstext e vpdfclasstextcolumn (eu criei essas)
hbmk.hbm (só as configurações para teste)
diagram.pdf (o diagrama das classes que eu criei)
Com certeza poderia ter ficado melhor, os cabeçalhos estão feios, queria ter feito estilo zebrado e, quem sabe, uma logomarca. Mas do jeito que está talvez ajude alguém, é essa a ideia. Espero não ter reinventado a roda kkkkk. Na realidade o trabalho maior é da ze_pdfclass do Quintas.
Se alguém quiser incrementar pode olhar no diagrama.pdf que tem um bom guia.
Para testar descompacte em uma pasta e faça assim
hbmk2 ex01
E executa o teste.exe
O teste.exe vai gerar o report.pdf (use seu leitor de PDF para ver)
(e assim por diante, até ex06)
O arquivo executável SEMPRE RECEBE o nome de teste.exe e o PDF gerado chama-se report.pdf
Um trecho de um dos exemplos do zip
Código: Selecionar todos
oObj := VPdfClassText():New( PDFCLASS_PORTRAIT , lUtf8 := .f. )
oObj:setSubject("RelRecebimentosDia")
oObj:setAuthor("Sua empresa")
oObj:setFilename("report.pdf")
oObj:setTitle( "Relatório de Nascimentos" )
oObj:addColumn( "id" , "Código" , 10 )
oObj:addColumn( "dtnasc" , "Data de Nascimento" , 18 )
oObj:addColumn( "nome" , "Nome do recém nascido" , 40 , "@!" )
oObj:addColumn( "valor" , "Valor" , 12 , "@re 999,999.99" , "R" , .t. )
oObj:addGroup( "grupo" , "Tipo de nascimento") // <<<<< AQUI O GRUPO (PODEM TER OUTROS NÍVEIS DE GRUPO)
oObj:Run()
oObj:End()