Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Viewers please share Any Idea or your views to devoted a application of easy way print addresses envelopes in C#.

thank you.
Posted
Comments
Richard MacCutchan 3-Feb-13 3:34am    
The same way you would print anything. Define the size of your print area, fill the details and send to the printer.

Look at using a PrintDocument[^] to do the actual work - the link includes an example.

Your major problem will not be the actual printing, but working with your data source to get the address information.
I have no idea how you are sourcing your addresses so I can't be at all specific.
 
Share this answer
 
Comments
sonu Ranjan 3-Feb-13 3:43am    
I am try to customize the Envelope size . where user set the value of envelope size or width...using this code
f (Convert.ToString(cmbEnvlopeSize.SelectedItem) == "Custome Size")
{
PrintDialog objDialog = new PrintDialog();
objDialog.ShowDialog();
}

PrintPreview objPreview = new EnvelopeSoftware.PrintPreview();
PagePreview objCrystalPreview = new EnvelopeSoftware.PagePreview();

DataTable dtEnvelope = _GetData.GetDataTable("Select * from EnvlopeSize Where SizeName='" + cmbEnvlopeSize.SelectedItem + "'");



if (Convert.ToString(cmbEnvlopeSize.SelectedItem) != "Custome Size")
{
// Not For custom paper
FontStyle objFontStyle = FontStyle.Regular;
if (Convert.ToBoolean(dtEnvelope.Rows[0]["Bold"]))
{
objFontStyle = FontStyle.Bold;
}
if (Convert.ToBoolean(dtEnvelope.Rows[0]["Italic"]))
{
objFontStyle = FontStyle.Italic;
}
if (Convert.ToBoolean(dtEnvelope.Rows[0]["UnderLine"]))
{
objFontStyle = FontStyle.Underline;
}

int SenderLeft = Convert.ToInt16(dtEnvelope.Rows[0]["SenLmargin"]), SenderTop = Convert.ToInt16(dtEnvelope.Rows[0]["SenTmargin"]), ReceiverLeft = Convert.ToInt16(dtEnvelope.Rows[0]["RecLmargin"]), ReceiverTop = Convert.ToInt16(dtEnvelope.Rows[0]["RecRmargin"]), pictureLeft = Convert.ToInt16(dtEnvelope.Rows[0]["LogoLeft"]), pictureTop = Convert.ToInt16(dtEnvelope.Rows[0]["LogoRight"]), MsgTop = Convert.ToInt16(dtEnvelope.Rows[0]["MsgTop"]), MsgLeft = Convert.ToInt16(dtEnvelope.Rows[0]["MsgLeft"]);
float SenderFontSize = float.Parse(Convert.ToString(dtEnvelope.Rows[0]["SenFontSize"])), receiverFontSize = float.Parse(Convert.ToString(dtEnvelope.Rows[0]["RecFontSize"])), paperWidth = 0, paperHeight = 0;
string paperSize = Convert.ToString(dtEnvelope.Rows[0]["PaperSize"]);
PrintDocument objPaperSize = new PrintDocument();
for (int i = 0; i < objPaperSize.PrinterSettings.PaperSizes.Count; i++)
{
if (objPaperSize.PrinterSettings.PaperSizes[i].PaperName == paperSize)
{
objCrystalPreview.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)objPaperSize.PrinterSettings.PaperSizes[i].RawKind;
break;
}
}
ReportObject objSender = objCrystalPreview.Section3.ReportObjects["SName1"] as ReportObject;
ReportObject objReceiver = objCrystalPreview.Section3.ReportObjects["RName1"] as ReportObject;
ReportObject objPicture = objCrystalPreview.Section3.ReportObjects["Picture1"] as ReportObject;
ReportObject objMsg = objCrystalPreview.Section3.ReportObjects["Message1"] as ReportObject;

FieldObject sFont = objCrystalPreview.Section3.ReportObjects["SName1"] as FieldObject;
FieldObject rFont = objCrystalPreview.Section3.ReportObjects["RName1"] as FieldObject;
FieldObject msgFont = objCrystalPreview.Section3.ReportObjects["Message1"] as FieldObject;

Font SenderFont = new Font(Convert.ToString(dtEnvelope.Rows[0]["SenFontStyle"]), SenderFontSize, o
OriginalGriff 3-Feb-13 3:48am    
And?
What am I supposed to do with that lot?
sonu Ranjan 3-Feb-13 4:00am    
i want to know how to print Envelope in any paper size when user have decided to the Height and width of Envelope..
OriginalGriff 3-Feb-13 4:34am    
PrintDocument pd = new PrintDocument();
pd.DefaultPageSettings.PaperSize = pd.PrinterSettings.PaperSizes(myWidth, myHeight);
sonu Ranjan 3-Feb-13 4:42am    
sir OriginalGriff.
PrintDocument pd = new PrintDocument();
pd.DefaultPageSettings.PaperSize = pd.PrinterSettings.PaperSizes(myWidth, myHeight);

in this code PaperSize is properties and we have not use Like Method.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900