Thanks for the reply Ron.
But i'm kind of a newbie in programming VB.Net, do you happen to know if i
could find a working sample on the net? Cause i've searched online but
nothing came up.
Printing the PDF File wouldn't be a problem as i use Adobe Acrobat to create
the files, its rather the drawing of the data at the correct location. But if
this could also be automated so that i wouldn't have to check the settings
and type the filename that would be really great.
I suppose these toolkits aren't for free, in that case this will not be a
possibility here, because i work with a non-profit organisation.
If I could have a working sample it would be outstanding.
PS: i use Visual Studio.Net 2003
Johan,
I don't know of simple samples available on the net and company rule
prevent me from posting code I've developed for internal use. There are the
text-only print samples from MS.
But in general a PrintDocument that I create overrides
OnBeginPrint - I allocate any fonts and Pens that I use here
OnEndPrint - I deallocate any allocations here
OnQueryPageSettings - I check my XML document current page for
Landscape and set the landscape flag appropriately.
OnPrintPage - Does all the work for each page
To draw a graphic such as a jpg use
Image img = Image.FromFile(theImageFileName) or use a stream with
the data in it
e.Graphics.DrawImage(img, new PointF(100.0f, 100.0f)) to draw at 1",
1"
Note that the standard measurement for a page is in 1/100ths of an inch and
then just draw the strings at the appropriate locations. To do your sample
in ad hoc code.
float x = 100.0f;
float y = 50.0f; // top of page
Image img = (get the image from a file or from a stream)
float deltax = ((float)img.Width/img.HorizontalResolution) * 100.0f;
// width of image in 1/100ths
float x2 = 750.0f; // 1 " from left size of an 8.5x11 page;
e.Graphics.DrawImage(img, newPointF(x2 - deltax, y));
float deltay = ((float)img.Height/img.VerticalResolution) * 100.0f;
// height of image
y += deltay; // if you want the text to start below the logo --
otherwise where desired
Font myBold = new Font("Arial", 10.0f, FontStyle.Bold);
Font myFont = new Font("Arial", 10.0f, FontStyle.Normal);
float leading = (myFont.SizeInPoints / 72.0f) * 100.0f; // get the
leading in 1/100ths
string s = "Activity Date: ";
e.Graphics.DrawString(s, myBold, Brushes.Black, x, y,
StringFormat.GenericTypographic);
float len = e.Graphics.MeasureString(s, myBold, new PointF(x, y),
StringFormat.GenericTypographic);
e.Graphics.DrawString(actDate.ToShortDateString(), myFont,
Brushes.Black, x+len, y,
StringFormat.GenericTypographic);
y += leading; // advance to next line. This would be single
spaced
// print out some more things here
When y is below the bottom margin of the page set HasMorePages to true
and exit the routine. Keep track of data locations either in class
variables of the subclass (as I do) or in some external way.
Ron Allen
> Thanks for the reply Ron.
> But i'm kind of a newbie in programming VB.Net, do you happen to know if i
[quoted text clipped - 48 lines]
>> >
>> > Anyone knows if this is possible?
Johan DM - 30 Jan 2005 19:33 GMT
Thanks for the great information Ron.
This should really get me started.
Sincerely Johan DM
> Johan,
> I don't know of simple samples available on the net and company rule
[quoted text clipped - 99 lines]
> >> >
> >> > Anyone knows if this is possible?
Johan,
Also you need to compensate for the physical margins of the printer
used. Search for GetHardMargins in
microsoft.public.dotnet.framework.drawing or microsoft.dotnet.languages.vb
for some code to do this. If you can't find this I can send a C# module
that does this.
Ron Allen
> Thanks for the reply Ron.
> But i'm kind of a newbie in programming VB.Net, do you happen to know if i
[quoted text clipped - 48 lines]
>> >
>> > Anyone knows if this is possible?