SELECT PRINTER PDF

Moderator: Rathinagiri

Post Reply
User avatar
giuper63
Posts: 10
Joined: Wed Oct 17, 2012 10:40 pm
DBs Used: DBF, mysql, sqlite, PostgresSQL
Location: Montecassiano
Contact:

SELECT PRINTER PDF

Post by giuper63 » Sun Aug 06, 2017 9:30 am

Hi to all,
I did the code above:

Code: Select all

#Include '.\hbwin.ch'
#include "hmg.ch"

Function Main
SET LANGUAGE TO ITALIAN
SET CODEPAGE TO ENGLISH
PdfTest()
Return

Procedure PdfTest()
Local lPDF:=1 ////////////////////// 1 = Stampa tramite stampante - 2 = Genera PDF
Local PdfName:="PDF.pdf"
Private nRig:=10, nCol:=10

If lPDF==1
	SELECT PRINTER 'PDFCreator';	
		TO lSuccess ;
		ORIENTATION	PRINTER_ORIENT_PORTRAIT ;
		PAPERSIZE	PRINTER_PAPER_A4 ;
		COPIES 1 ;
		QUALITY	PRINTER_RES_MEDIUM

	START PRINTDOC NAME 'Stampa'
Else
	SELECT PRINTER PDF PdfName;	
		TO lSuccess ;
		ORIENTATION	PRINTER_ORIENT_PORTRAIT ;
		PAPERSIZE	PRINTER_PAPER_A4
// SET HPDFDOC ENCODING TO "CP1250"
// SET PRINTDOC ENCODING TO "WinAnsiEncoding"
Endif

	START PRINTDOC
		START PRINTPAGE
	
		nColDim=5
	
		nRig:=25
		nDim=12
		Sta_txt(nRig,5,Chr( 218 ) + Chr( 196 ) + Chr(194) + Chr( 191 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,5,Chr( 195 ) + Chr( 179 ) + Chr(197) + Chr( 180 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,5,Chr( 192 ) + Chr( 196 ) + Chr(193) + Chr( 217 ),nDim); nRig:=nRig+nColDim
		
		nRig:=25
		nDim=12
		Sta_txt(nRig,35,Chr( 218 ) + Chr( 196 ) + Chr(194) + Chr( 191 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,35,Chr( 195 ) + Chr( 179 ) + Chr(197) + Chr( 180 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,35,Chr( 192 ) + Chr( 196 ) + Chr(193) + Chr( 217 ),nDim); nRig:=nRig+nColDim

		nRig:=25
		nDim=12
		Sta_txt(nRig,65,Chr( 218 ) + Chr( 196 ) + Chr(194) + Chr( 191 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,65,Chr( 195 ) + Chr( 179 ) + Chr(197) + Chr( 180 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,65,Chr( 192 ) + Chr( 196 ) + Chr(193) + Chr( 217 ),nDim); nRig:=nRig+nColDim

		nRig:=55
		Sta_txt(nRig,5,Chr( 201 ) + Chr( 205 ) + Chr(203) + Chr( 187 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,5,Chr( 204 ) + Chr( 186 ) + Chr(206) + Chr( 185 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,5,Chr( 200 ) + Chr( 205 ) + Chr(202) + Chr( 188 ),nDim); nRig:=nRig+nColDim
		
		nRig:=55
		Sta_txt(nRig,35,Chr( 201 ) + Chr( 205 ) + Chr(203) + Chr( 187 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,35,Chr( 204 ) + Chr( 186 ) + Chr(206) + Chr( 185 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,35,Chr( 200 ) + Chr( 205 ) + Chr(202) + Chr( 188 ),nDim); nRig:=nRig+nColDim
		
		nRig:=55
		Sta_txt(nRig,65,Chr( 201 ) + Chr( 205 ) + Chr(203) + Chr( 187 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,65,Chr( 204 ) + Chr( 186 ) + Chr(206) + Chr( 185 ),nDim); nRig:=nRig+nColDim
		Sta_txt(nRig,65,Chr( 200 ) + Chr( 205 ) + Chr(202) + Chr( 188 ),nDim); nRig:=nRig+nColDim
		             
		nRig:=180
		For nM:=32 to 224 STEP 16 
			For nN:=0 to 15
				sta_txt(nRig,5+(nN*9),Str(nN+nM)+':'+Chr(nN+nM),7)
			Next
			nRig:=nRig+4
		Next
		nRig:=nRig+3
		For nM:=32 to 224 STEP 16 
			For nN:=0 to 15
				sta_txt(nRig,5+(nN*9),Str(nN+nM)+':'+Chr(nN+nM),7,"Symbol")
			Next
			nRig:=nRig+4
		Next
		END PRINTPAGE
	END PRINTDOC
	If lPDF<>1
	  if file(PdfName)
	     execute file PdfName
	  endif
	Endif   
Return

**-----------------
Function  Sta_txt(nRig,nCol,cTesto,nSize,cFont,lGras,lCors,lSott,lBarr)
**-----------------
nSize:=If(Valtype(nSize)=='N',nSize,10)
lGras:=If(Valtype(lGras)=='L',lGras,.f.)
lCors:=If(Valtype(lCors)=='L',lCors,.f.)
lSott:=If(Valtype(lSott)=='L',lSott,.f.)
lBarr:=If(Valtype(lBarr)=='L',lBarr,.f.)
cFont:=If(Valtype(cFont)=='C',cFont,"Times")

iif( _HMG_SYSDATA [513],; 
	_HMG_HPDF_PRINT ( nRig,nCol,cFont,nSize,,,,cTesto,lGras,lCors,lSott,lBarr,,.t.,.t.,),; 
	_HMG_PRINTER_H_PRINT(_HMG_SYSDATA[374],nRig,nCol,cFont,nSize,,,,cTesto,lGras,lCors,lSott,lBarr,,.t.,.t.,))
Return
In line 15 I can set lPdf:=1 to print on printer and lPdf:=2 to directly create PDF.
The problem is that when i use lPdf:=1 it print the BoxChar correctly, when i use lPdf:=2 the procedure create a PDF with defective boxchar!
I think it is a problem of charset but I don't find a way to correct it. (See lines 29 and 30)
I have read other treads HPDFPRINT Font misprint BoxChar, Underline and italic in PDF seems not work and Learning to print without finding a solution.
Giuseppe
Italian developer

Post Reply