473,237 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,237 software developers and data experts.

How can I move the margin to the left?

Ho can I move the margin to the left
by adding which code below?

Many thanks,
Adrian.

**************************

using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Windows.Forms;

namespace PRL058
{
public class Printing
{
private Font printFont;
private StreamReader streamToPrint;
public static int reset;
int rule_param1;
int rule_param2;

public Printing()
{
getRuleParam();
doPrinting();
}

// The PrintPage event is raised for each page to be printed.
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
#region settings
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
if (reset!=0)
topMargin = reset;
string line=null;
#endregion

#region make up the page
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
;
Pen blackPen = new Pen(Color.Black,.5F);

while (count < linesPerPage && ((line=streamToPrint.ReadLine()) != null))
{
yPos = topMargin + (count * printFont.GetHeight(ev.Graphics));

if(line.IndexOf("----") -1 )
{
ev.Graphics.DrawLine(blackPen,rule_param1, yPos, rule_param2, yPos);
count++;
continue;
}

if(line.IndexOf("====") -1 )
{
ev.Graphics.DrawLine(blackPen,rule_param1, yPos, rule_param2, yPos);
ev.Graphics.DrawLine(blackPen,rule_param1, yPos+2, rule_param2,
yPos+2);
count++;
continue;
}

ev.Graphics.DrawString (line, printFont, Brushes.Black,leftMargin, yPos,
new StringFormat());
count++;
}
// If more lines exist, print another page.
if (line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}

private void getRuleParam()
{
try
{
using(StreamReader sr = new StreamReader("RuleParam.txt"))
{
rule_param1 = Convert.ToInt32(sr.ReadLine());
rule_param2 = Convert.ToInt32(sr.ReadLine());
}
}
catch
{
rule_param1 = 750;
rule_param2 = 60;
}
}
#endregion

#region do printing
public void doPrinting()
{
try
{
streamToPrint = new StreamReader ("temporary.txt");
try
{
printFont = new Font("Courier New", 8);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.DefaultPageSettings.Landscape=true;
// Print the document.
pd.Print();
}
finally
{
streamToPrint.Close() ;
}
}
catch
{
}
}
#endregion
}
}
Nov 22 '06 #1
0 1154

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

Similar topics

22
by: moocow | last post by:
Hi. I am using a background image in a form button. The problem I am having is that there is a 1 pixel margin inside the button on all sides. I would like my background image to fill the...
0
by: Helge | last post by:
Hi there I have a question regarding http://www.chriss.no/test. The <div id="rightcorner"> doesn't move up to where it should be in Internet Explorer. The HTML is like this: <div...
3
by: stan | last post by:
I have code that produces 5 boxes across the screen width. So far I have only tested it in IE 6 and NS 8. It works in IE, but in NS I am not able to fit in the 5th box. I am using two...
10
by: Alan Silver | last post by:
Hello, In my (seemingly) endless quest to understand CSS, I have yet another problem. Please look at http://www.kidsinaction.org.uk/ph/x.html in Opera, where you will see it how I expected. If...
1
by: Edward | last post by:
I created a simple CSS layout (code and example below) for bloggin/writing but ran into five issues that I need help with: 1. How do I get rid of the right-margin red line on the last three...
13
by: Mounir | last post by:
Hi, Assume that right and left are multiple select elements. It's about the following line : right.options=left.options; It copies the content of left.options into right.options, but...
1
by: superDk | last post by:
Hello, IE6 is adding a large margin between my two containers (container1 & container2) everything works fine in IE7 and Firefox. I've been searching on-line for a fix but I've had no luck. It...
7
by: GTalbot | last post by:
Hello fellow authoring.stylesheets colleagues, Can someone please explain why the bottom margin of the last inflow block-level child in an overflowed parent should not have its margin reachable....
1
by: innivive | last post by:
I am having a problem with having margins display correctly in IE7, Firefox and Safari. I am not sure if it is the "double margin error" or something else. Any help would be appreciated. The file...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.