473,387 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

printing on the right side of paper

Friends,

I'm (a bit) dissapointed about the printing possibilities in c#. It could
also be lack of knowedge.

I would like to align a text on the right side of the paper when printing.

For example
tekst = DateTime.Today.Date.ToString("dd-MM-yyyy");
// asign content to the variable tekst
SizeF stringSize= ev.Graphics.MeasureString(tekst, printFont);
// measure the length of the tekst ... in what??
xPos = (float) ev.MarginBounds.Right - stringSize;
// to aligh it on thr right side of the paper
ev.Graphics.DrawString (tekst, printFont, Brushes.Black, xPos, yPos, new
StringFormat());

I would like to print tekst now but I have problems with the typing.

I tried all kinds of things but there must be some easy way of doing this.
Who can help me with this..

and who knows a bunch of nice printing functions. I dont like the way C#
handles the printer control.

regards
Gerrit Esmeijer


Nov 16 '05 #1
1 2457
See microsoft.public.dotnet.framework.drawing for many discussions on
drawing/printing things.

That said, you want to use a StringFormat.GenericTypographic to measure
and print the string as it provided better measurement for this. The
default StringFormat used in MeasureString some padding around the string
when measuring it. MeasureString returns values in the units selected for
the current Graphics.
You will also need to consider printer hard margins when printing as 0,0
starts at the top/left of the printable area by default. Using Framework
1.1 you can set OriginAtMargins to true and then 0,0 will be at the
intersection of your left and top margins.
I basically wrote my own set of printing utilities to do my printing so
that I have methods to align a string at a point including left and center
aligning. This was a rewrite of the utilities I've been using ever since I
was writing Postscript code to draw custom forms on the early Apple
Laserwriters.
If you actually want to get the printer's hard margins and printable
extent I have some C# routines that you can have.

Ron Allen
"G.Esmeijer" <ge****@nomail.nl> wrote in message
news:41**********************@dreader2.news.tiscal i.nl...
Friends,

I'm (a bit) dissapointed about the printing possibilities in c#. It could
also be lack of knowedge.

I would like to align a text on the right side of the paper when printing.

For example
tekst = DateTime.Today.Date.ToString("dd-MM-yyyy");
// asign content to the variable tekst
SizeF stringSize= ev.Graphics.MeasureString(tekst, printFont);
// measure the length of the tekst ... in what??
xPos = (float) ev.MarginBounds.Right - stringSize;
// to aligh it on thr right side of the paper
ev.Graphics.DrawString (tekst, printFont, Brushes.Black, xPos, yPos, new
StringFormat());

I would like to print tekst now but I have problems with the typing.

I tried all kinds of things but there must be some easy way of doing this.
Who can help me with this..

and who knows a bunch of nice printing functions. I dont like the way C#
handles the printer control.

regards
Gerrit Esmeijer

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: mykidisgollum | last post by:
Greetings, I have code which prints a document who's attributes are saved as flags in a database. One of the those attributes is letter or legal. When I am printing, I use the following...
4
by: Rajani | last post by:
Hello, I am generating reports from database in HTML format. When i print from browser, its printing so slow on my dotmatrix printer. How can i print in DOS mode? I need to print on continuous...
0
by: Niyazi | last post by:
Hi all, This my aspx page first line of code. <%@ Page CodeBehind="index.aspx.vb" Language="vb" AutoEventWireup="false" Inherits="TB.index" %> Than inside head tag I have following script(s)...
5
by: VMI | last post by:
I have a BMP image (the form is also in PDF) that contains a scanned copy of a paper form that we need to fill out. Is it possible to use this image in my application so that the application can...
2
by: Jurjen de Groot | last post by:
I'm about to start a new ASP.NET application, this application will generate several types of documents (PDF HTML XML-DOC) wich have to be printed at the client-side... (probably on different...
3
by: D Witherspoon | last post by:
No matter what I do the default paper size is always either A3 or 11 by 8.5 .. Here is the code. Dim dlg As DialogResult pd.DocumentName = "Weld Image" Dim pkPaperSize As New...
7
by: tm | last post by:
I am trying to print a form using the following code, everything works fine but the margins are not acted upon. What I am I doing wrong? Private Sub CaptureScreen() Dim myGraphics As...
1
by: Anne DeBlois | last post by:
Hi, I want to programatically set the paper size of a print document. I created a class that inherits PrintDocument, so I can print some database records on 8" x 10" paper. I added this line...
8
by: Frank Rizzo | last post by:
I am trying to print huge images (much bigger than target paper). I try and use e.PageSettings.HardMarginX and e.PageSettings.HardMarginY in the PrintDocument's PrintPage event to try and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.