Monthly Archives: November 2005

Dynamically embed image files into Crystal Reports in VS2003 (and probably VS2005, too)

In VB6 with Crystal Reports 8, embedding an image dynamically into a Crystal Reports file was fairly simple. You could merely add a new object to the report on the fly, passing in the path of the image file then drop it into the appropriate section and x/y position on the report.

Dim oleobj As OLEObject
oRpt.Sections(8).AddPictureObject imgfileName, 1920, 1560

In VS.NET 2003 (I haven’t looked at how to do this in 2005 yet), it is hardly as easy as this and I needed to do it to solve a serious file bloat problem. I had a 13kb image that I needed to embed as a watermark into the background of the file. You do this by creating a page header section that is the height of the paper and in the formatting options for the section, check “Underlay Following Sections”. That way, the section will be a watermark under all of the rest of the sections of the report. However, because of the way Crystal does this underlay, my dlls that contain a report with a watermark were over 2MB when compiled. Without the image, they went back down to 200kb – 350kb depending on other variables.

Embedding the watermark image dynamically was going to help me get rid of this file bloat problem, but it was not as simple as the previous crystal API.

I had some help from tech support and modified the code to suit my needs and will share it here.

The trick is to stream the file into a datatable and then add the datatable as one of the datasource objects of the report. Then the field which represents the image, can be dragged and dropped onto the report surface.

What I did was create a class for extending Crystal call CrystalAddOns. In it I have a shared function that takes in the path of the image file and returns a datatable creating the binary for the image.

Here is the class.

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Imports System.IO
Public Class CrystalAddOns

‘========================

Public Shared Function ImageTable(ByVal ImageFile As String) As DataTable
‘ Create a dataTable
  Dim data As New DataTable
‘ Declare a row object.
 
Dim row As DataRow
 
data.TableName = “Images”
‘ Add a Byte Array field to the dataset.
 
data.Columns.Add(“img”, System.Type.GetType(“System.Byte[]”))
‘ Repeat for each image.if you have more than one…
‘==================
‘ Read in the image file.(in VS2005 you can use ReadAllBytes and skip the streaming)
  Dim fs As New FileStream(ImageFile, FileMode.Open)
‘ Create a new binary reader object.
  Dim br As New BinaryReader(fs)
‘ Create a new row object.
  row = data.NewRow()
‘ Stream the image into the row.
  row(0) = br.ReadBytes(br.BaseStream.Length)
‘ Add the row to the dataset.
  data.Rows.Add(row)
 
br =
Nothing
  fs.Close
  fs = Nothing
‘==================
‘ Run through this line of code the the first time you create the dataset
‘ To create the schema file. The schema file will be the datasource for the
‘ subreport that holds the image. Add this to the project and then add it to
‘ the report in design time. Then you can drag & drop the img field onto the
‘ report.

 ‘Dim ds As New DataSet
 ‘ds.Tables.Add(data)
 
‘ds.WriteXmlSchema(System.IO.Directory.GetCurrentDirectory() & “\Image.xsd”)

Return data

‘don’t forget your exceptions!!

End Function
End
Class

Now that you have this class, you can use it easily when instantiating your reports:

rpt.Database.Tables(1).SetDataSource(CrystalAddOns.ImageTable(myfilePath)

This assumes that the schema file was the 2nd datasource in your report.

My class also has additional goo to handle specific watermarks, such as a “draft” watermark. This way my call would ask for CrystalAddOns.DraftImageTable() and the CrystalAddOns class already has the path of the file.

Note that the full blown version of Crystal Reports that can be upgraded to from the one that comes with VS2003 (and the next version that you can upgrade to from VS2005) have a Dynamic Image Location feature (which I have never tried) that supposedly makes this much simpler. My guess is that the Dynamic Image Location does the same thing as my class.

Don’t Forget: www.acehaid.org

What – still no line in WinForms designer?

I think my head has been under the rock as far as vs2005 WinForms UI design stuff is concerened. I was fiddling wtih Winforms the other day and wanted to put a line on the form and realized I still can’t do it the old VB6 way. I just dropped a panel on instead and put the “below the line” stuff inside the panel. I want the line there at design time, so the GDI+ way wasn’t my cup of tea.

Don’t Forget: www.acehaid.org

Vermont IT Jobs: IT Analyst in Rouses Pt NY

Northwestern Vermonters, I received this today:

Our client, a growing national wholesale distributor, is currently seeking an IT Analyst. 
 
The IT Analyst is responsible for writing programs in Visual Basic, maintaining their Windows 2000 network, performing EDI functions and providing user support.   This individual must be flexible to cross over work in other IT areas from developing, administrative, EDI, or support. 
 
The ideal candidate will possess:
 
-3+ years of experience in Visual Basic, SQL and Windows administration
-knowledge of EDI
-great communication skills
 
A Bachelor’s degree is preferred, however, additional experience in lieu of education is acceptable.
 

This is an excellent opportunity offering a base salary commensurate with experience and a comprehensive benefits package.  First round interviews will take place in our office on Wednesday,  November 30 starting at 10:00 AM.

 

If you are both interested and qualified in the above-mentioned opportunity, please contact either David A. Coryer or Melissa Moore at ETS, Inc; 518-562-4673 or toll-free 877-303-7737  We can also be reached via email at dcoryer@etsjobs.com or mmoore@etsjobs.com.  We look forward to hearing from you!

 

ETS, Inc., upstate New York’s premier supplier of temporary and direct-hire recruiting for the past twenty-four years, specializes in the placement of high quality individuals in upstate New York, New England and along the Eastern Seaboard.

Don’t Forget: www.acehaid.org

Sample Certificates in WSE 3.0

For those of you who have used WSE 2.0 or all of the pre-RTM bits of WSE 3.0, we are used to having a folder with the sample certificates inside of the WSE 3.0 program folder. Not finding this with the RTM bits, I did find out where the certs were in the MSDN forums. Mark Fussell says:

The sample certificates were removed from the product and replaced with a setup.bat file in the \Samples directory. This setup file uses MakeCert.exe to generate named certificates, installs them into the correct certificate stores and set the appropriate priviledges when run. This was done to ease the installation on the samples and enable you to get started with the samples sooner

If you want to install certificates by manually you can follow the instructions either in the readme.htm in the samples directory or at the end of the Hands on labs. You can use MakeCert.exe to generate the same certificates as used to be shipped in WSE 2.0.

Now that I know where to look, I see that this information is in the readme document in the samples folder.

Don’t Forget: www.acehaid.org

Hunting season and the usual rambling

As I sit in my office this morning, I have been watching pickup trucks drive slooooowly up my road all morning looking for someplace to hunt. They get to the end of our road, realizing there is no open land up here and turn around. It’s a public road, so I can’t whine about them driving back and forth all day, but I wish I had a right to put a sign at the bottom of the road that says “no place up here to hunt – don’t bother…”  It’s the norm for hunting season, but a little aggravating.

There have already been 2 accidental deaths in Vermont (one right in my town). One was with two young guys out hunting. They had separated and one shot and killed the other, his friend. It’s the most common type of hunting accident – pulling the trigger before you identify your target. The 2nd was a mother who shot her son in the foot while they were hunting. There is no excuse for these accidents. I know a lot of very responsible and respectful hunters. Early in the season, though, it is sadly not uncommon for some trigger happy idiots to just shoot at whatever is moving –  your friend, your son, whatever…

When I lived in Dutchess County (NY State) there was one season with two awful accidents. One was, again, two friends hunting together. One had a great plan for hunting!. He dressed like a deer so the deer wouldn’t be afraid of him. He wore carhartt overalls (tan colored) and a white scarf. He was shot by his friend. Before he died, he made a statement to be try to ensure that his friend did not get charged with his death – something like “stupid me, I was dressed like a deer”.

The other was much more criminal. Two men without legal status to be in the U.S. that had drive up from NYC were hunting on private property, without permission and with some kind of big guns that are totally illegal for hunting. So that’s a pretty bad setup. To top it off, one of them accidentally shot and killed the land owner, who was also out hunting on his property.

When I moved out of NYC in 1999, I had to get used to hunting as it was common where I lived. I even ended up dating two men who hunted and really learned a lot about it and changed my attitude about hunting. I even learned to make a fantastic venison stew from The New Basics Cookbook (lucky me with a juniper bush by my house!). So don’t misunderstand my rants – it is not against hunters or hunting, just against dangerous idiots.

One thing we love about hunting season is the Hunter’s Breakfast from 5-10am Saturdays and Sundays for weeks and weeks at the local church. By 8am it’s just our friends and neighbors all going (the hunters are already up in their tree stands) and very sociable and fun. But this year, it’s too sad to go because one very beloved young man in our town, Luke Palmer, died in a car accident right in the middle of the village on Wednesday. He is always there at the breakfasts with his parents and also at Spaghetti suppers, etc. Luke is autistic, but very high functioning, very loving and challenges us to percieve our world a little differently. I have been getting to know him since we moved here and have always looked forward to learning more about his world from him. Here is his obit, which says a lot about him and how he affected so many people’s lives.

Don’t Forget: www.acehaid.org

Luke Huntington Palmer

I am copying this lovely obituary from the Burlington Free Press (11/18/05) so that it doesn’t get lost forever. With love to Luke, Onnie & Andy.

11/18/2005LUKE HUNTINGTON PALMER — Luke Huntington Palmer, of Huntington, died tragically and unexpectedly in a car accident on Nov. 16, 2005. Born to Onnie and Andy Palmer and brother Tony on April 23, 1987, Luke was a dynamic presence in the lives of his family and friends and will be terribly missed. Luke lived life with great enthusiasm – big plans, a big heart, a great sense of humor. Whether baking bread, snapping photographs, or emailing his many friends, Luke’s approach to all he did took us places we never knew existed. A recent show of his photographs is only one expression of his keen eye. He cooked and baked wonderful food on his own from an age when most kids would not be allowed near the stove. He was most recently working on a hearthstone oven in Martha’s Vineyard with plans for a bakery and “really long baguettes.“ Each of us who knew Luke knows something exciting and unexpected about what we foolishly thought was mundane or boring. No one will ever forget Mrs. Harris, darling. Luke is survived by his parents, Onnie and Andy Palmer, of Huntington, his brother Tony Palmer of Chilmark, Mass., his grandparents, Bill and Betty (Eddy) Lidgerwood of Chilmark, and Melissa Palmer of Slingerlands, N.Y.; his aunts and uncles, David Palmer of Albany, N.Y., Laurie Palmer and Debbie Gould of Chicago, Ill., Frank and Sarah Slingerland of Glenmont, N.Y., Erick McCandles of Altamont, N.Y., Trina McCandles of Groton, Conn., Lisa and Peter White of Tunbridge, Susie Eddy of Chilmark, Bill Eddy and Eileen Walsh of Waquoit, Mass., Carolyn Eddy and Vineyard Haven, Mass., Bruce Adrews of Burlington; his cousins, Dinah and Marcella Andrews, Liza Eddy and her husband, Tim Schaub, Beach White, Erika and Emily Slingerland, Patrick and Lizzie Walsh; Godparents Steve Fischer, Paul Southerland, and Corliss McClean Weston; and many, many special friends and animals from Brewster Pierce Memorial School, Camels Hump Middle School, Mount Mansfield Union High School, Burlington Technical Center, and Vermont and Martha’s Vineyard, Mass. A memorial service for family will be held this week in Chilmark, Mass. A memorial service for Luke’s friends and community will be held in Huntington at a later date. In lieu of flowers, contributions to the Huntington Library Building Fund (c/o Colleen Dychton, Library Trustee, 1275 East St., Huntington, Vt. 05462) may be made in Luke’s memory. Local arrangements are in the care of Gifford Funeral Service, 22 Depot St., Richmond.