2
Answers

how to print a document in c# windows application with same

Hi friends,

I have developed a c# desktop application in which i need to print a file(document like .doc, .rtf) with same styles(fonts,alignment, color,size etc).
I have converted the text in a rich text box to .doc and saved to a path when i am trying to print that file i am losing styles(fonts,alignment, color,size etc).

So. Please help me with code or example

THANKS IN ADVANCE
Answers (2)
0
Suthish Nair
NA 31.7k 4.6m 14y
If your query got resolved, then accept the post that helped you as Answer.
0
Suthish Nair
NA 31.7k 4.6m 14y
attach your both pages..
0
Madhu K
NA 2k 446k 14y
The name 'ContractId' does not exist in the current context

Clearly tells that ContractId isn't declared as string. and from your code I observed that you did not used the query string anywhere else. Anyhow just declare ContractId as string.


string ContractId = Request.QueryString["ContractId"].ToString();


0
Amit Choudhary
NA 27.7k 3m 14y
Hi becky,

Everything seems to be fine in Code ... Try Rebuild your solution to get the fresh assemblies of updated code.


0
Becky Bloomwood
NA 119 240.2k 14y

I added in he code thatyou gave me, but there is still error:

protected void Page_Load(object sender, EventArgs e)
{
//string strContractId = Request.QueryString["ContractId"].ToString();
//string cid = Convert.ToString(Request.QueryString["ContractId"]);
//if (cid != null)
//{
// Response.Write("Fetch Records on the basis of ContracID " + cid);
//}
if(Request.QueryString["ContractId"]!=null)
{
ContractId = Request.QueryString[
"ContractId"].ToString();
}



if (!IsPostBack)
{
//Set the sortExpression
ViewState[
this.ToString() + "_SortExpression1"] = "Terms";
ViewState[
this.ToString() + "_SortDirection1"] = "ASC";
//Set the sortExpression
ViewState[
this.ToString() + "_SortExpression2"] = "FileName";
ViewState[
this.ToString() + "_SortDirection2"] = "ASC";
//Set the sortExpression
ViewState[
this.ToString() + "_SortExpression3"] = "Item";
ViewState[
this.ToString() + "_SortDirection3"] = "ASC";



//populate the criticalterms datatable
DataTable tmpdt = vrmdb.Get_CriticalTerms().Tables[0];
//tmpdt = new DataTable();
tmpdt.PrimaryKey =
new DataColumn[] { tmpdt.Columns[0] };
ViewState[viewStateGVName] = tmpdt;

//populate the uploadeddocuments datatable
DataTable tmpdtt = vrmdb.Get_UploadedDocuments().Tables[0];
tmpdtt =
new DataTable();
tmpdtt = vrmdb.Get_UploadedDocuments().Tables[0];
tmpdtt.PrimaryKey =
new DataColumn[] { tmpdtt.Columns[0] };
ViewState[viewStateGVUDName] = tmpdtt;
//populate the uploadeddocuments datatable
DataTable tmpCdt = vrmdb.Get_Checklist().Tables[0];
tmpCdt =
new DataTable();
tmpCdt = vrmdb.Get_Checklist().Tables[0];
tmpCdt.PrimaryKey =
new DataColumn[] { tmpCdt.Columns[0] };
ViewState[viewStateGVCLName] = tmpCdt;



BindGrid();
BindGrid1();
BindGrid2();
//string strContractId = Request.QueryString["ContractId"].ToString();


}
}
This is the error:

Server Error in '/VRM_WebSite' Application.

Compilation Error


Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'ContractId' does not exist in the current context

Source Error:

Line 36:              if(Request.QueryString["ContractId"]!=null)
Line 37:                 {
Line 38:                     ContractId = Request.QueryString["ContractId"].ToString();
Line 39:                 }
Line 40: 

Source File: c:\Users\L31410\Desktop\Peggie\Peggie\Deployment Source\Phase 1\Deployment 25 Nov for StarHub\VS Projects Source\VRM_WebSite\app\vrm\ContractThreeGridView.aspx.cs    Line: 38




 




Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955
Thanks!
0
Madhu K
NA 2k 446k 14y
By using following code you can get rid of the error.
If(Request.QueryString["ContractId"]!=null)
{
strContractId = Request.QueryString["ContractId"].ToString();
}

Use the debugger place a breakpoint and check whether you are getting the value from
from the query string or not.