Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Watermark
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01240837
Message ID:
01241826
Views:
33
Russel,

>Where is that new version, anyway?

In my first message to you in this thread I sent you a link to get that new version.

Anyway, forget it now.

Please test this one, and tell me how it works.
You'll find instructions on how to use it here:
Watermark your reports with GdiPlusX
http://weblogs.foxite.com/cesarchalom/archive/2007/07/17/4405.aspx

I've created a new version, and would apreciate if you could test it with your report.

In this version I've added a RenderType property, that will tell the listener if the watermark is to be drawn before or after the page is rendered. Some other slight modifications will improve the speed for the case of reports that contain more than one page.

Please try switching the property "RenderType" from 2 to 1, and check if there's a difference in the final result.
_SCREEN.AddProperty("System", NEWOBJECT("xfcSystem", LOCFILE("system.vcx","vcx"))) 

LOCAL loListener as ReportListener 
loListener = CREATEOBJECT("WatermarkListener")

loListener.LISTENERTYPE = 1
loListener.WaterMarkImage = HOME() + "Graphics\Gifs\morphfox.gif"
loListener.WaterMarkType = 1 && 1 = Colored ; 2 = GreyScale
loListener.WaterMarkTransparency = 0.25 && 0 = transparent ; 1 = Opaque
loListener.WaterMarkWidthRatio = 0.75   && 0 - 1
loListener.WaterMarkHeightRatio = 0.75  && 0 - 1
loListener.RenderType = 2 && 1 = Before rendering page ; 2 = After rendering page

* Run the report using the new report engine (object-assisted output)
REPORT FORM (ADDBS(HOME()) + "samples/solution/europa/employeesmd.frx") OBJECT loListener

RETURN





DEFINE CLASS WatermarkListener AS _ReportListener OF HOME() + "FFC\" + "_ReportListener.VCX"
	NewPage = .T.
	WaterMarkImage = ""
	WaterMarkType = 1 && 1 = Colored ; 2 = GreyScale
	WaterMarkTransparency = 0.50 && 0 = transparent ; 1 = Opaque
	WaterMarkWidthRatio = 0.50
	WaterMarkHeightRatio = 0.50
	RenderType = 1 && 1 = Before rendering page ; 2 = After rendering page
	oGDIGraphics = NULL
	oBmp         = NULL
	oImgAttrib   = NULL
	oRect        = NULL
	
	FUNCTION BEFOREREPORT
		DODEFAULT()

		WITH _SCREEN.SYSTEM.Drawing

			This.oGDIGraphics = .Graphics.New()

			LOCAL lnX, lnY, lnWidth, lnHeight
			lnX = (1 - This.WaterMarkWidthRatio) / 2
			lnY = (1 - This.WaterMarkHeightRatio) / 2
			lnWidth = This.WaterMarkWidthRatio
			lnHeight = This.WaterMarkHeightRatio

			* Create a Rectangle of the size of 60% of the report page
			This.oRect = .Rectangle.New(lnX * This.sharedPageWidth, ;
					lnY * This.sharedPageHeight, ;
					This.sharedPageWidth * lnWidth, ;
					This.sharedPageHeight * lnHeight)

			* Load the Image File to GDI+
			This.oBmp = .Bitmap.New(This.WaterMarkImage)

			* Create a color matrix
			LOCAL loClrMatrix AS xfcColorMatrix
			IF This.WaterMarkType = 2 && 1 = Colored ; 2 = GreyScale
				loClrMatrix = .Imaging.ColorMatrix.New( ; 
			        .33, .33, .33, 0  , 0, ; 
		    	    .33, .33, .33, 0  , 0, ; 
		        	.33, .33, .33, 0  , 0, ;
			        0, 0, 0, This.WaterMarkTransparency, 0, ; 
			        0, 0, 0, 0, 0)
			ELSE
				loClrMatrix = .Imaging.ColorMatrix.New()
				loClrMatrix.Matrix33 = This.WaterMarkTransparency
			ENDIF 				

			* Create an ImageAttributes and associate the ClrMatrix to it
			This.oImgAttrib = .Imaging.ImageAttributes.New() 
			This.oImgAttrib.SetColorMatrix(loClrMatrix)

		ENDWITH
	ENDFUNC

	FUNCTION BEFOREBAND(nBandObjCode, nFRXRecNo)
		#DEFINE FRX_OBJCOD_PAGEHEADER 1
		IF nBandObjCode==FRX_OBJCOD_PAGEHEADER AND This.RenderType = 1 && Before the page is rendered
			This.DrawWatermark()
		ENDIF
		DODEFAULT(nBandObjCode, nFRXRecNo)
	ENDFUNC

	PROCEDURE AfterBand(nBandObjCode, nFRXRecNo)
		#DEFINE FRX_OBJCOD_PAGEFOOTER 7
		IF nBandObjCode==FRX_OBJCOD_PAGEFOOTER AND This.RenderType = 2 && After the page is rendered
			This.DrawWatermark()
		ENDIF 
		DODEFAULT(nBandObjCode, nFRXRecNo)
	ENDPROC

	PROCEDURE DrawWatermark
		IF NOT EMPTY(This.WatermarkImage)

			* Get GDI+ Graphics handle
			IF NOT This.IsSuccessor
				This.SharedGDIPlusGraphics = This.GDIPLUSGRAPHICS
			ENDIF
			This.oGDIGraphics.Handle = This.SharedGDIPlusGraphics

			* Draw the watermark
			This.oGdiGraphics.DrawImage(This.oBmp, This.oRect, This.oBmp.GetBounds(), 2, This.oImgAttrib)
		ENDIF 
	ENDPROC 	

ENDDEFINE
>>Russel,
>>
>>>Use the GDIPlusX library, there is a sample in the download:
>>>http://www.codeplex.com/VFPX/Release/ProjectReleases.aspx?ReleaseId=1711
>>>
>>>Look at: samples\report_logowatermark_cool.prg
>>
>>The WaterMarkListener that I suggested is based on that sample, and provides the possibility to set some other properties. When I created that sample, I was just thinking on creating a sample, so I suggest you to work with the new one.
>>
>>
>>
>>
>>>>>It appears that watermarks are not real simple in the VFP report writer, even in 9. If I put one in the page header, it makes the page header become quite large (larger than it needs to be for the data, but large enough for the watermark). In other words, the watermark is not spanning bands. I'd just like a one or two word watermark placed diagonally an spanning most of the page from lower left to upper right. Perhaps there's a trick I've not discovered. Any suggestions?
>>>>
>>>>Cathy Pountney shows how to create watermark in What's New in the Visual FoxPro 9.0 Report Writer
>>>
>>>Thanks, Sergey and Naomi and Cesar. As far as I can tell, placing the watermark as suggested in Cathy's article does not work as advertised. I tried various settings, but it caused the page header band to expand beyond the required height.
>>>
>>>I ended up using a suggestion from Bo Durban which prints the watermark correctly and lets me control opacity.
>>>
>>>From Bo:
>>>
>>>Use the GDIPlusX library, there is a sample in the download:
>>>http://www.codeplex.com/VFPX/Release/ProjectReleases.aspx?ReleaseId=1711
>>>
>>>Look at: samples\report_logowatermark_cool.prg
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform