|
hi,
The reson is because of few factors.
1) Font Size of your content.
2) No of lines per page etc.
What you can do is, if you want to print without any breaking then please see the below mwntioned code. This will deside howmany lines need to print based on Font Size
private void menuItem6_Click(object sender, System.EventArgs e)
{
try
{
PrintDia=new PrintDialog();
PrintDia.Document=printDocument1;
string content=this.Editor.Text;
StrReader=new StringReader(content);
if(PrintDia.ShowDialog()==DialogResult.OK)
{
this.printDocument1.Print();
}
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message.ToString());
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
float Lines_Per_Page = 0;
float Y_Position = 0;
int Count = 0;
float Left_Margin = e.MarginBounds.Left;
float Top_Margin = e.MarginBounds.Top;
string Line = null;
Font fnt = Editor.Font;
SolidBrush Solid = new SolidBrush(Color.Black);
Lines_Per_Page=e.MarginBounds.Height/Font.GetHeight(e.Graphics);
while(Count < Lines_Per_Page && ((Line=StrReader.ReadLine())!=null ))
{
// calculate the next line position based on
// the height of the font according to the printing device
Y_Position =Top_Margin + (Count * fnt.GetHeight(e.Graphics));
// draw the next line in the rich edit control
e.Graphics.DrawString(Line ,fnt ,Solid ,Left_Margin ,Y_Position ,new StringFormat());
Count++;
}
if(Line !=null)
e.HasMorePages=true;
else
e.HasMorePages=false;
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message.ToString());
}
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
try
{
string Content=Editor.Text;
StrReader = new StringReader(Content);
PrintPreviewDialog Print_Preview=new PrintPreviewDialog();
Print_Preview.Document=printDocument1;
Print_Preview.ShowDialog();
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message.ToString());
}
}
}
}
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
This gave me an idea. What my problem is that my users print receipts at the end of the month collectively and even a marginal error in determining the height of the page will make a big difference say on 900th page.
I thought I can make the width of the page very large and print a 1000 inch height as a page. But as I said a page is a4 and when i draw by GDI+ say on y=30 cm (out of a4 height) it simply does not print it.
Now it seems to me that I can modify your code to satisfy my needs. The papersize remains A4 and I print multiple A4 pages but adjust coordinates so that the code regularly prints on A4. I will now measure the height of my receipt and I hope that it is 1/2 or 1/3 of a A4
But anyway, why changing paper size is problem? why do we need to write a lot of code instead of just defining a custom paper size? I am afraid MS engineers think that only companies with laser or ink jet printers will run their code or maybe youngsters which will print their term projects or favorite lyrics
|
|
|
|
|
hi
Levent Özkan Wrote :
This gave me an idea.
This is the thing i expect from my effort after submitting the answer which is known to me.
Levent Özkan Wrote :
Now it seems to me that I can modify your code to satisfy my needs.
This is the thing that we want from your side. Because now a days i seen lot of youngsters want spoon feeding. And it is not possible to sit and figurout their entire needs (I am working for some other company).
Good.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi,
Thanks for the code again, be sure that this effort will generate an tutorial on continuous form paper. I also learned another way to print text-only reports. I will use this if any other methods fail.
There is an article from Ms which tells how to send raw data to the printer by bypassing GDI+. By using this you can send raw text to printer. The good side of this approach is that the character width is fixed. We can set printer to narrow mode (136 columns) by sending Chr(15) & Chr(15) as first bytes. Then I printed a reference page on which there are column and row positions are printed and put receipt on it to fing receipt content coordinates. Somebody told me that all receipt papers, independent from its type, has a height which is a integer multiple of the height of one row when you print raw strings. The only problem with this path is that you must write some custom code in win98
|
|
|
|
|
Does your printer (and driver) support custom paper sizes? (Many do not)
Use the GetDeviceCaps API call (or there may be a .NET class equivalent) to find out.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
I realized that setting the PaperSize in program is not enough. My host printer is OKI Microline 3320 and I solved my problem by setting Page Length to 6 inch. Then giving value of (W:780, H:600) which is the receipt size of my customers to PaperSize, I saw that now the tractor of the printer rolls the page correctly.
|
|
|
|
|
Hello all
I want to import my outlook address book into my vb.net application.
Any Solution?
Thanks
Sumit Domyan
Software Developer
ANALEC INFOTECH
|
|
|
|
|
Hi all,
see I have class module which has a subroutine say
private sub myrt()
dim str as string
str="just check"
form1.reta(str)
end sub
there is a subroutine in the form (named as form1) module
named as reta
private sub reta(byref asd as string)
asd="the return value"
end sub
the problem with this is that, even though the variable is passed as refrence in the subroutine, the value of str is still showing "just checking" instead of "the return value"
after executing the sub reta
this only happ in the class module, do it in the same nodule the problem does not exists.
|
|
|
|
|
You'll have to step through your code and find the second function you defined as reta .
Next, since you defined the function reta as Private in Form1, it can't be called by any code outside of Form1 class.
Lastly, did you pass a reference to Form1 to your class module where myrt is defined? If not, your not using the Form1 instanace that you think you are. Forms in VB.NET do not work like they did in VB6 and below.
In order to diagnose this further, we'd need to see more of your code, preferrably copied and pasted between <pre></pre> tags.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanx for the info dave, but I am using VB and not VB.Net, so the problem is comming in that, so if u have any idea, kindly reply the same
|
|
|
|
|
The same rules for public/private subs and functions as well as passing parameters apply to both VB and VB.NET. We'll have to see the code your using to see what's going on.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Lots of ways to skin this cat...
* Just about any reporting tool
* 3rd party .NET PDF component (there are many)
* Open Source .NET PDF component (there are a couple)
* Print to PDF using (free) PDF995 or (pay) Adobe software
I have used Aspose PDF with some success. Try This search for some articles.
my blog
|
|
|
|
|
Anybody know how I can programmatically have a PDF file created and shoot records into it, then save it?
Thanks!
I'm using VB.Net and SQL Server.
|
|
|
|
|
Someone pls tell me how to change the page orientation setting for a printer before sending a job to printer, and how to restore the setting after printing.
i.e. i want to change the setting completely so i can even see it in control panel as the new setting.
In vb6. Thanks.
1fm1fu
|
|
|
|
|
use the GetDeviceCaps API call to see if you can set the printer landscape.
If so use the OpenPrinter API call to get a handle to the printer and pass this to the SetPrinter API call to change the settings.
..although rememeber that users don't really like you to change their settings system wide...
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
I'm trying to setup a CSV file to report data on a Crystal Report from within .NET using Visual Basic.
I'm setting the data source up under the "More data sources", "Access/Excel" section. I can pull the fields and place them on the report and the project builds without any errors, but when executed it asks for the login id and password.
There is no login id or password on a csv file. Is it possible to pull data into a crystal report via a csv file? If it is possible, does someone have a solution or sample code?
Thanks in advance for any help!
Lost in the vast sea of .NET
|
|
|
|
|
I didn't receive any replies at CodeProject to this thread, but I did want to share the solution that I was given on GotDotNet.com. Hopefully this will help someone in the future with the same problem. Here is the link:
http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx?id=264311&Page=1#265396
Lost in the vast sea of .NET
|
|
|
|
|
hey
i have the same problem
but your given link is down
can you provide any new link
or provide any example
thanks in advance
waiting for rply
Regards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
Hi Narendra,
Sorry for the delay in response. I was on vacation last week when you posted. The Microsoft GotDotNet.com website is no longer maintained so the link I posted in 2004 no longer works. I dug back through the e-mails I kept and here were the 4 suggestions I received on that forum. Not sure which one I used or even which project I was working on at that time to even check, but hopefully posting the actual responses that they gave me will help you in some way.
1st answer:
You could write the schema of the dataset created out to an xmlfile, and then add the xml file to crystal reports using More Data Sources, ADO.Net(XML).
Public Sub CreateXmlFile(ByVal XmlFilename As String, ByVal XmldataSet As DataSet)
Dim XmlFile As System.IO.FileStream
Dim XmlFileStream As New System.IO.FileStream _
(XmlFilename, System.IO.FileMode.Create)
Dim XmlOutput As New System.Xml.XmlTextWriter _
(XmlFileStream, System.Text.Encoding.Unicode)
XmldataSet.WriteXmlSchema(XmlOutput)
End Sub
2nd answer:
Can't you just connect to the CSV file with an OleDb.OleDbConnection, and fill a DataSet with an OleDb.OleDbDataAdpater?
I fill datasets in this way all the time.
-------------------------------------------
Dim txtConn as New OleDb.OleDbConnection
txtConn.ConnectionString = "Provider=miscrosoft.jet.oledb.4.0;Data Source=Directory Name;Extended Properties=Text;"
Dim txtCmd as New OleDb.OleDbCommand
txtCmd.Connection = txtConn
txtCmd.CommandText = "SELECT * FROM [filename.csv];"
Dim txtAdpt as New OleDb.OleDbDataAdpater
txtAdpt.SelectCommand = txtCmd
Dim ds as New Dataset
txtAdpt.Fill(ds)
------------------------------------------------
Now you have a disposable dataset that should be able to interact with Crystal Reports.
3rd answer:
There is a workaround for this problem on page 262 of the book at this site:
http://www.crystalreportsbook.com/?cpgn=ngcr_021803
This is a very good .Net Crystal Reports book.
It states to connect to the Excel file using DAO, then design the report, and since the DAO connection prompts for login, password, switch the connection to ODBC after the report is designed.
4th answer:
I think crystal made a fix to this problem, you might check their support site.
Lost in the vast sea of .NET
|
|
|
|
|
hi
i want to know how to make windows application template for vb.net
|
|
|
|
|
|
Hi,
Has anyone worked with WinHTTP and multithreading in VB.NET
I have written a small application for understanding threading in VB.NET.
It consists of initializing new thread, each consisting of a winHTTP request to open a particular page located on our local LAN.
The code for opening a new page in a new thread is
Private Sub Start()
Dim myWinHTTP As New WinHttp.WinHttpRequest()
myWinHTTP.Abort()
myWinHTTP.SetTimeouts(5000, 5000, 5000, 5000)
myWinHTTP.Open("GET", "http://192.168.0.60/Alliance/Login.aspx", False)
myWinHTTP.Send()
textbox.Multiline = True
textbox.Text = textbox.Text & " $$$ " & myWinHTTP.StatusText & ". Thread Id : " & Thread.CurrentThread.GetHashCode()
countLbl.Text = serial
End Sub
As observed, there were frequent errors in opening the page. The sub Stated above too was not completely exectued for quite a few threads. The control used to dissaper from the code post the command 'Dim myWinHTTP As New WinHttp.WinHttpRequest()' itself.
In anyone has any clue abt the corresponding error, please inform.
Amit
|
|
|
|
|
I've got a couple of questions...
Why are you using WinHTTPxxx instead of the System.Net namespace and the WebRequest class? Are you using some component for Web requests or are you using a library your put together yourself?
Why are you creating a new WinHttpRequest object and the first thing you do is call the .Abort method?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need the user of my program to select a computer name from the computers attached to his network, but have no idea how to get started to make a list of the computers.
This has to be done in VB6 (or Delphi)
Once that is done I can readily handle all the rest of the code I need.
Laurie
|
|
|
|
|
Try to check the information from here.[^]
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|