imprimir imagen

22/04/2010 - 22:50 por Edwin Duran | Informe spam
que tal amigos estoy tratando de imprimir imagen en un reporte, estos estan
almacenado en un campo blob, estoy utilizando el metodo que esta en el link
mas abjao, en vista previa se bien, paro al imprimir se distorciona la
imagen y no se ve como en vista previa.

Alguna sugerencia
gracias

http://fox.desdeguate.com/2008/02/1...tes-vfp-9/

Preguntas similare

Leer las respuestas

#1 Edwin Duran
23/04/2010 - 23:28 | Informe spam
Con el codigo mas abajo ya pude solucionar lo de imprimir imagenes
almacenadas en un campo blob, este es el mejor que me ha funcionado, pero no
se porque despues de imprimir se pone lento, tengo que probar en otro
ordenado, si alguin lo puede subir al portalfox mucho mejor.

Saludos

* START CODE

*

*--

* AUTHOR: Trevor Hancock

* CREATED: 03/04/05 01:03:07 P.M.

* ABSTRACT: Code from Microsoft Knowledge Base

* article 895602. Visual FoxPro code that shows how

* to use pictures that are

* stored in a BLOB field in a report.

* This is accomplished by using an

* object reference to an instance of

* an IMAGE class as the control source for

* an OLE Bound control on the report. The IMAGE

* object has its PictureVal property set to a BLOB

* field in a cursor.

*--

Local lcDataDIR As String, ;

lcThisDir As String, ;

loRL As ReportListener

lcDataDIR = Home( ) + 'Samples\Tastrade\'

lcThisDir = Addbs( Justpath( Sys( 16 ) ) )

Cd ( lcThisDir )

Close Data All

*-- Create a temp cursor with a few fields, one of which is a

*-- BLOB. Store pictures in this field as raw binary data.

Select Cast( Alltrim( First_Name ) As Varchar ( 10 ) ) As 'FNAME', ;

CAST( Alltrim( Last_Name ) As Varchar (10 ) ) As 'LNAME', ;

CAST( Filetostr( lcDataDIR + Photo_File ) As Blob ) As 'PIC' ;

FROM ( lcDataDIR + 'data\Employee.dbf' ) ;

INTO Cursor ReportTemp

*-- Close the table that you selected from. It is not needed.

Use In Select( 'EMPLOYEE' )

*-- This calls a function that makes a report programmatically.

*-- This is included here just to make sure that this sample can be run

*-- as-is, without asking the developer to manually create a report.

MakeReport()

*-- Create an instance of the PreviewListener

*-- class defined later in this code.

*-- Call its custom InitBLOBImage() method,

*-- which creates an instance of an IMAGE object.

*-- This IMAGE has its PictureVal property set to the BLOB

*-- field ( 'ReportTemp.PIC' ) and its reference ( loRL.oBlobImage )

*-- is used as the control source for the OLE Bound control

*-- on the report.

loRL = Newobject( 'PreviewListener' )

loRL.InitBLOBImage( 'ReportTemp.PIC' )

*-- Make sure that the cursor is selected,

*-- and then run the report to preview using

*-- the instance of our Report Listener.

Select ReportTemp

Report Form BlobReport TO PRINTER PROMPT PREVIEW Object loRL

Close Data All

Return

?

?

?

?

*--

*-- There has to be some way of redrawing the

*-- picture in the IMAGE class as the record pointer

*-- in the report's driving cursor changes; it does not occur

*-- automatically. This could be done by a UDF() in the PrintWhen

*-- of the OLE Bound control on the report, or as is illustrated here,

*-- by a Report Listener BEFOREBAND() Event.

Define Class PreviewListener As ReportListener

oBlobImage = Null

PicBlobFld = ''

ListenerType = 1 && Preview Listener

Procedure InitBLOBImage(lpcBlobField As String)

This.PicBlobFld = lpcBlobField

This.oBlobImage = Newobject( 'IMAGE' )

This.oBlobImage.PictureVal = This.PicBlobFld

This.oBlobImage.Stretch = 1

Endproc

Procedure BeforeBand( nBandObjCode, nFRXRecNo )

*-- Before the DETAIL band is rendered, ;

*-- just redraw the IMAGE object so that it has

*-- the correct picture from the BLOB field.

If nBandObjCode = 4 && Detail band

This.oBlobImage.PictureVal =EVALUATE( This.PicBlobFld )

This.oBlobImage.Stretch = 1

Endif

Endproc

Enddefine

?

?

?

*--

*-- This function programmatically creates a report

*-- with an OLE Bound control and other fields. This is included

*-- only for demonstration purposes so this article code can stand-alone.

*-- Typically, you would create your own report manually by using

*-- the report designer.

Function MakeReport

Create Report BlobReport From ReportTemp

*-- Open the report file (FRX) as a table.

Use BlobReport.FRX In 0 Alias TheReport Exclusive

Select TheReport

*-- Increase the height of the Detail band

*-- (ObjType = 9 & ObjCode = 4) to fit the

*-- Picture/OLE Bound control that is inserted later.

Update TheReport Set Vpos = 0, Hpos = 0, Height = 23542;

WHERE ObjType = 9 And ObjCode = 4

*-- Since you increased the height of the Detail Band, you need to move

*-- the items from the footer down so they are back in the footer again.

Update TheReport Set Vpos = 29479.167 ;

WHERE ( ObjType = 8 Or ObjType = 5 ) And ;

INLIST( Expr, 'DATE()', '"Page "', '_PAGENO' )

*-- Add a Picture/OLE Bound control to the report by inserting a

*-- record with appropriate values. Using an object that is based on the
EMPTY

*-- class here and the GATHER NAME class later to insert the record makes it
easier to

*-- see which values line up to which fields (when compared to a large

*-- SQL-INSERT command).

Local loNewRecObj As Empty

loNewRecObj = Newobject( 'EMPTY' )

AddProperty( loNewRecObj, 'PLATFORM', 'WINDOWS' )

AddProperty( loNewRecObj, 'Uniqueid', Sys(2015) )

AddProperty( loNewRecObj, 'ObjType', 17 ) && "Picture/OLE Bound Control"

AddProperty( loNewRecObj, 'NAME', 'loRL.oBlobImage' ) && The object ref to
the IMAGE object.

AddProperty( loNewRecObj, 'Hpos', 27500.000) && Place it in DETAIL band.

AddProperty( loNewRecObj, 'Vpos', 3854.167)

AddProperty( loNewRecObj, 'HEIGHT', 21354.167)

AddProperty( loNewRecObj, 'WIDTH', 25104.167)

AddProperty( loNewRecObj, 'DOUBLE', .T. ) && Picture is centered in the
"Picture/OLE Bound Control"

AddProperty( loNewRecObj, 'Supalways', .T. )

*-- For the Picture/OLE Bound control, the contents of the OFFSET field
specify whether

*-- Filename (0), General field name (1), or Expression (2) is the source.

AddProperty( loNewRecObj, 'Offset', 2 )

*-- Add the Picture/OLE Bound control record to the report.

Append Blank In TheReport

Gather Name loNewRecObj Memo

*-- Clean up and then close the report table.

Pack Memo

Use In Select( 'TheReport' )

Endfunc

*

* END CODE
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida