Printing Text With a Watermark

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a production application that prints textual information, plus a
graphic watermark on each page. Currently it uses a PrintPageEventHandler
from the System.Drawing.Printing namespace to add the watermark and text to
each page.

The watermark is the same on each page, and is derived from a WMF file whose
size is about 120 KB.

The problem is that the spool files that are produced when we print are
somewhat large. The spool files without the watermark are only about 10 KB
per page. With the watermark (derived from a WMF file) the spool files are
about 300 KB per page.

What I would like to do is send the watermark only once per print job. This
would greatly decrease the load on the network and print server. How can I
accomplish this?
 
Hi,

Thanks for your posting!!

Can you show me what does "derived from a WMF file" mean? Based on my
understanding, you want to set a customized bitmap on your local machine as
default watermark for the printer, so that each printing can leverage this
customized bitmap as the watermark. If I misunderstand you, please feel
free to tell me.

I think, to achieve this, we should find a way to set the local custoimzed
bitmap to the default watermark list for the printer. I will spend some to
see if there is a way to do this customization. I will update you ASAP.
Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi,

After some internal consulting, I was told that there is no common support
for printer to add customized bitmap as the watermark, it is a
device-dependent feature.

If your printer supports downloading watermark bitmaps, then you could
perhaps send the appropriate escape codes. But there's nothing in GDI (nor
GDI+, nor System.Drawing) to implement this for you.

Hope this information helps you.
============================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Jeffrey,

For efficiency reasons, my watermark is a wmf file, since the watermark is a
full-page vector graphic. A bitmap would be quite a bit larger although that
could be OK if we only have to send it once per job to the printer.

I created the wmf file by designing my watermark in Word, copying, pasting
into an application that can save as wmf (I used Corel Draw), and then saving
the file as "Watermark.wmf."

The size of the original Word document is 100 KB, and the wmf file is 150
KB. If I save instead as a bmp file with 8-bit x 300 DPI resolution, the file
is 8 MB.

The PrintEventHandler for my PrintDocument object looks like this:

private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
float lpp = 0 ;
float yPos = 0 ;
int count = 0 ;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
String line=null;

Metafile image = new Metafile("Watermark.wmf");
ev.Graphics.DrawImage (image, 0, 0);
lpp = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics) ;
while (count < lpp && ((line=streamToPrint.ReadLine()) != null))
{
yPos = topMargin + (count * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString (line, printFont, Brushes.Black,
leftMargin, yPos,
new StringFormat());
count++;
}

if (line != null)
ev.HasMorePages = true ;
else
ev.HasMorePages = false ;
}
 
I have a production application that prints textual information, plus a
graphic watermark on each page. Currently it uses a PrintPageEventHandler
from the System.Drawing.Printing namespace to add the watermark and text to
each page.

The watermark is the same on each page, and is derived from a WMF file whose
size is about 120 KB.

The problem is that the spool files that are produced when we print are
somewhat large. The spool files without the watermark are only about 10 KB
per page. With the watermark (derived from a WMF file) the spool files are
about 300 KB per page.

What I would like to do is send the watermark only once per print job. This
would greatly decrease the load on the network and print server. How can I
accomplish this?

Hi Howard,

use an integer variable as pagecounter in your pd_PrintPage() and merge the
wmf file only for the first page.

like this:
int pagecount=1;

private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
float lpp = 0 ;
float yPos = 0 ;
int count = 0 ;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
String line=null;

if pagecount == 1
{
Metafile image = new Metafile("Watermark.wmf");
ev.Graphics.DrawImage (image, 0, 0);
}
else
pagecount +=1;
lpp = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics) ;
while (count < lpp && ((line=streamToPrint.ReadLine()) != null))
{
yPos = topMargin + (count *
printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString (line, printFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
count++;
}

if (line != null)
ev.HasMorePages = true ;
else
ev.HasMorePages = false ;
}


Greeting

Thomas
 
Hi,

Because this issue is the feature of specific printer, .Net has no control
over this, .Net can only generate code that certain device supported,
unfortunately, this feature is not a common supported function.
I think a more reasonable way is first query if the printer supports this
function, for supported printer, there should be some programming interface
exposed by that printer, so you can use that programming interface to
invoke this function. But for un-supported machine, we have to send
watermark to the printer each time, because we can not get what does not
exist.

I hope this makes sense to you.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top