How can I print an image in 8.5" x 11" size (letter) ?
oImg1:Print( , , , 06 )I know that the
oImg1:Print( , , , n )Thank you very much !
oImg1:Print( , , , 06 )oImg1:Print( , , , n )Error E0030 Syntax error "syntax error at '@'"@ 1, 1 PRINT TO oPrn IMAGE cImage SIZE 7,9 INCHES NOTRANSPARENT STRETCHFWH 16.03: Please use the method:
PrintImage( nRow, nCol, cImage, nWidth, nHeight, lStretch, nAlpha, lTransp, lGray ) // All units in pixels
Ex:
oPrn:PrintImage( 100,100, "c:\fwh\bitmaps\olga1.jpg", 5000,7000 )
Rao:
Thank you for your help. How can I find out the pixel size of the full image and how many pixels does an 8.5" x 11" page has ?
Thank you very much my friend.
Gustavo,
The Image is adjusted to a given page-area.
Using small images there is a zoom-factor
look at Your post :
viewtopic.php?f=3t=32880p=193508#p193508
regards
Uwe ![]()
&&
Gustavo,
> How can I find out the pixel size of the full image
oImage:nWidth() and oImage:nHeight()
METHOD Inch2Pix( nRow, nCol ) CLASS TPrinter
nRow = Max( 0, ( nRow * ::nVertRes() / (::nVertSize() / 25.4 ))-::nYoffset )
nCol = Max( 0, ( nCol * ::nHorzRes() / (::nHorzSize() / 25.4 ))-::nXoffset )
return { nRow, nCol }nRow = Max( 0, ( nRow * ::nVertRes() / (::nVertSize() / 25.4 ))-::nYoffset )
nCol = Max( 0, ( nCol * ::nHorzRes() / (::nHorzSize() / 25.4 ))-::nXoffset )



Uwe,
> but the calculation ( pixel ) to center the images doesn*t work for any reason
How are you painting them ?

FUNCTION P_REPORT4( oMeter, oText, oDlg )
LOCAL aPoint
LOCAL oPRINT, oFont1, oFont2, oFont3, oPen1
LOCAL nLinI, nColI, nLinF, nColF
LOCAL nLablBord, nLablWidth, nImgTop, nImgBord, nImgWidth, nImgCent
LOCAL I := 1, nTextLeft[7], nImgLeft, nTextPos
PRINTER oPRINT ; // FROM USER ;
PREVIEW MODAL ;
NAME "Patientenliste drucken"
IF EMPTY( oPRINT:hDC )
MsgStop ( "Drucker nicht bereit !" )
RETURN(.f.)
ENDIF
IF aVal[180] = 2 // fix for report thumbnails
TPreview():lListViewHide := .T.
ENDIF
DEFINE FONT oFont1 NAME "Arial" SIZE 0, -18 BOLD OF oPRINT
DEFINE FONT oFont2 NAME "Arial" SIZE 0, -18 OF oPRINT
DEFINE FONT oFont3 NAME "Arial" SIZE 0, -14 BOLD OF oPRINT
DEFINE PEN oPen1 WIDTH 12 OF oPRINT
// ----- TEXT ----------
// defined 0.5
nLablBord := aODat[65]
// defined 4.1
nLablWidth := aODat[70]
// start with left space
nTextPos := nLablBord
// ----- IMAGE ( pixel ) --------
// defined 7.2 to be calculated to pixel
nImgTop := Max( 0, ( ( aODat[76] ) * oPRINT:nVertRes() / (oPRINT:nVertSize() / 25.4 )) - oPRINT:nYoffset )
// defined 0.5 to be calculated to pixel
nImgBord := Max( 0, ( aODat[65] * oPRINT:nHorzRes() / (oPRINT:nHorzSize() / 25.4 )) - oPRINT:nXoffset )
// defined 4.1 to be calculated to pixel
nImgWidth := Max( 0, ( aODat[70] * oPRINT:nHorzRes() / (oPRINT:nHorzSize() / 25.4 )) - oPRINT:nXoffset )
// defined 1. image-center
nImgCent := nImgBord + ( nImgWidth / 2 )
I := 1
FOR I := 1 TO 7
nTextLeft[I] := nLablBord
NEXT
oPRINT:SetPage(9) // A4
IF aODat[72] = .T.
oPRINT:SetPortrait()
ELSE
oPRINT:SetLandscape()
ENDIF
PAGE
I := 1
X := 8
FOR I := 1 TO 7 // define var-start-values of 7 labels
IF I = 2
X := 17 ( array-positions )
ELSEIF I = 3
X := 26
ELSEIF I = 4
X := 35
ELSEIF I = 5
X := 44
ELSEIF I = 6
X := 53
ELSEIF I = 7
X := 62
ENDIF
// add label-width to position
nTextPos += nLablWidth
// add label-width to position ( pixel ) after 1. loop
IF I > 1
nImgCent += nImgWidth / 2
ENDIF
// define if text-centered
IF aODat[74] = .T.
// Left textposition if centered ( Label-width - Text- width )
nTextLeft[1] := nLablWidth - ( aODat[70] - oPRINT:CmtrGetTextWidth( TRIM(aODat[X-7]), oFont1 ) ) / 2
nTextLeft[2] := nLablWidth - ( aODat[70] - oPRINT:CmtrGetTextWidth( TRIM(aODat[X-6]), oFont2 ) ) / 2
nTextLeft[3] := nLablWidth - ( aODat[70] - oPRINT:CmtrGetTextWidth( TRIM(DTOC(aODat[X-5])),oFont2 ) ) / 2
nTextLeft[4] := nLablWidth - ( aODat[70] - oPRINT:CmtrGetTextWidth( TRIM(aODat[X-4]), oFont2 ) ) / 2
nTextLeft[5] := nLablWidth - ( aODat[70] - oPRINT:CmtrGetTextWidth( TRIM(aODat[X-3]), oFont3 ) ) / 2
nTextLeft[6] := nLablWidth - ( aODat[70] - oPRINT:CmtrGetTextWidth( TRIM(aODat[X-2]), oFont3 ) ) / 2
nTextLeft[7] := nLablWidth - ( aODat[70] - oPRINT:CmtrGetTextWidth( TRIM(aODat[X-1]), oFont3 ) ) / 2
ENDIF
IF aODat[X] = .T. // selected label
oPRINT:cmSay( aODat[64], nTextPos - nTextLeft[1], aODat[X-7], oFont1,,CLR_BLACK,,PAD_LEFT ) // 1
oPRINT:cmSay(aODat[66], nTextPos - nTextLeft[2], aODat[X-6], oFont2,,CLR_BLACK,,PAD_LEFT ) // 2
IF aODat[71] = .T. // select line-painting
nFil := aODat[64] + 1.0 // Top
nCol := nLeft // Left
nTop := aODat[64] + 1.0 // Top
nBot := nLeft + 3.5 // Right
aCoord1 := oPRINT:Cmtr2Pix( @nFil, @nCol )
aCoord2 := oPRINT:Cmtr2Pix( @nTop, @nBot )
oPRINT:Line ( nFil, nCol, nTop, nBot, oPen1 )
ENDIF
IF aODat[73] = .F. // print with date
oPRINT:cmSay(aODat[67], nTextPos - nTextLeft[3], TRIM(DTOC(aODat[X-5])),oFont2,,CLR_BLACK,,PAD_LEFT ) // 3
oPRINT:cmSay(aODat[68], nTextPos - nTextLeft[4], aODat[X-4], oFont2,,CLR_BLACK,,PAD_LEFT ) // 4
oPRINT:cmSay(aODat[69], nTextPos - nTextLeft[5], aODat[X-3], oFont3,,CLR_BLACK,,PAD_LEFT ) // 5
oPRINT:cmSay(aODat[69] + 0.8, nTextPos - nTextLeft[6], aODat[X-2], oFont3,,CLR_BLACK,,PAD_LEFT ) // 6
oPRINT:cmSay(aODat[69] + 1.6, nTextPos - nTextLeft[7], aODat[X-1], oFont3,,CLR_BLACK,,PAD_LEFT ) // 7
ELSE // NO date
oPRINT:cmSay(aODat[67], nTextPos - nTextLeft[4], aODat[X-4], oFont2,,CLR_BLACK,,PAD_LEFT )
oPRINT:cmSay(aODat[68], nTextPos - nTextLeft[5], aODat[X-3], oFont3,,CLR_BLACK,,PAD_LEFT )
oPRINT:cmSay(aODat[68] + 0.8, nTextPos - nTextLeft[6], aODat[X-2], oFont3,,CLR_BLACK,,PAD_LEFT )
oPRINT:cmSay(aODat[68] + 1.6, nTextPos - nTextLeft[7], aODat[X-1], oFont3,,CLR_BLACK,,PAD_LEFT )
ENDIF
// ---------------- IMAGE ---------
IF aODat[75] = .T. // print nImgCent - ( image-sze / 2 )
IF aODat[77] = 500 // defined image-sizes
nImgLeft := nImgCent - 250 // 50 % minus
ENDIF
IF aODat[77] = 600
nImgLeft := nImgCent - 300
ENDIF
IF aODat[77] = 700
nImgLeft := nImgCent - 350
ENDIF
IF aODat[77] = 800
nImgLeft := nImgCent - 400
ENDIF
// PrintImage( nRow, nCol, uImage, image-name nWidth, nHeight, lStretch, nAlpha, lTransp, lGray )
oPRINT:PrintImage( nImgTop, nImgLeft, c_Pfad1 + aODat[X+1], aODat[77], aODat[77], .T.) // 9
ENDIF
ENDIF
NEXT
ENDPAGE
ENDPRINT
oFont1:End()
oFont2:End()
oFont3:End()
RETURN( NIL )
IF nStyle = 7 // Labels
nILablWidth := 896
// Text => 1.6 3.8
// nLablBord + ( nILablWidth / 2 ) - ( Imagesize / 2 )
nImgLeft := 310 + 448 - aODat[99] / 2 // Pixel centered
ENDIF
IF nStyle = 9 // Labels
nILablWidth := 730
// Text => 1.0 3.1
// nLablBord + ( nILablWidth / 2 ) - ( Imagesize / 2 )
nImgLeft := 170 + 365 - aODat[99] / 2 // Pixel centered
ENDIF
IF nStyle = 4 // Labels
nILablWidth := 1420
// Text => 3.0 6.0
// nLablBord + ( nILablWidth / 2 ) - ( Imagesize / 2 )
nImgLeft := 630 + 710 - aODat[99] / 2 // Pixel centered
ENDIFTPrinter object methods SayText() and PrintImage() automatically do all the calculations and center text (or multiline text) and images within given rectangle. Not only center, they can also optionally align the text/image to any of the 8 sides (4 sides and 4 corners of the given rectangle optionally. In the recent versions we can specify any units for the rectangle. There are also commands which make calling these methods easy.
If you still want to do all these calculations yourself, it is upto you.

