473,671 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Componen tModel;
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(ob ject sender, PrintPageEventA rgs 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.GetHe ight(ev.Graphic s)
;
Pen blackPen = new Pen(Color.Black ,.5F);

while (count < linesPerPage && ((line=streamTo Print.ReadLine( )) != null))
{
yPos = topMargin + (count * printFont.GetHe ight(ev.Graphic s));

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

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

ev.Graphics.Dra wString (line, printFont, Brushes.Black,l eftMargin, 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(StreamRea der sr = new StreamReader("R uleParam.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 PrintPageEventH andler(pd_Print Page);
pd.DefaultPageS ettings.Landsca pe=true;
// Print the document.
pd.Print();
}
finally
{
streamToPrint.C lose() ;
}
}
catch
{
}
}
#endregion
}
}
Nov 22 '06 #1
0 1181

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

Similar topics

22
19432
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 inside of the button from button border to button border, and not stop 1 pixel shy of that. I have tried:
0
1810
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 id="right"> <div id="content">
3
2166
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 different style sheets, one for IE and on e for NS. The box widths are set to 20%. I would appreciate suggestions on how to get the 5 boxes to fit the screen
10
12901
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 you look at it in IE (6 or 7), you find it also looks fine, except for the top margin missing from the links across the top of the page. That's not the main issue here, but any pointers as to why it doesn't show them would be appreciated.
1
2666
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 right-boxes in Internet Explorer? 2. How can I put a 4px margin BETWEEN the right-boxes, "border-top: 4px" didn't do it and if I put in a "margin-top: 4px;" it shows the red underneath instead of the brown background graphic.
13
1831
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 *removes* the content of the first one !
1
2249
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 would make my day if someone could help me with this. website- http://www.00dogtraining.com/ Thanks for any help, Dave css code:
7
3432
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. I read and re-read carefully the CSS 2.1 spec and I just can not see why. Related webpages: http://www.gtalbot.org/BrowserBugsSection/MSIE8Bugs/MarginBottomChildNotRendered.html
1
3111
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 tabs at the top content area should be flush left and the light blue frame should line up under the logo graphic. Looks great in Safari and Firefox but I can't get it to line up in IE7. http://www.thinairdigital.com/tdi Any help would be...
0
8481
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8400
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8602
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8672
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7441
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6234
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.