|
Check this...[^]
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Hi Friends...
i am working on a webapplication in which i have to create pdf file using itextsharp(must as customer want to use this only). here i will have a gridview which is not databound, not have any column at design time. on page load only i will create a datatable based on some data and bind it to gridview.
after this i need to do formatting of some specific rows in the girdview. this formatting will use pre tag with some attributes like font-family, size, style. so while displaying the gridview after page load some rows of gridview will have specific formatting tags in it's cell's text.
on click of a button i need to create a pdf file using itextsharp. i am able to create pdf only problem is all formatting tags are appearing in file, they are not being replaced with thier html meaning.
can anybody help me to sort it out? please it's very much required at this time...
below is the function to which i am passing a datatable dt, which is nothing but data contained in grid stored into table... also a string headerText, which will come on top of page and will show some note text.
private void CreateSavePdf(DataTable dt, string headerText)
{
// where to store the file
string pdfFileName = "D:\\Report.pdf";
Document document = new Document(PageSize.A4.Rotate(), 50, 50, 50, 50);
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(pdfFileName, FileMode.Create));
document.Open();
Phrase headerPhrase = new Phrase(headerText, FontFactory.GetFont("Verdana", 24));
HeaderFooter header = new HeaderFooter(headerPhrase, false);
header.Border = Rectangle.NO_BORDER;
header.Alignment = Element.ALIGN_LEFT;
document.Header = header;
document.Add(headerPhrase);
HeaderFooter footer = new HeaderFooter(new Phrase("Page "), true);
footer.Border = Rectangle.NO_BORDER;
footer.Alignment = Element.ALIGN_CENTER;
document.Footer = footer;
int numColumns = dt.Columns.Count;
PdfPTable datatable = new PdfPTable(numColumns);
datatable.DefaultCell.Padding = 3;
datatable.WidthPercentage = 100; // percentage
datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
datatable.DefaultCell.BorderWidth = 1;
datatable.DefaultCell.GrayFill = 0.7f;
foreach (DataColumn column in dt.Columns)
{
string columnName = column.ColumnName;
Phrase phrase = new Phrase(columnName, FontFactory.GetFont("Arial", 8, Font.BOLD));
datatable.AddCell(phrase);
}
datatable.HeaderRows = 1;
foreach (DataRow row in dt.Rows)
{
foreach (DataColumn column in dt.Columns)
{
string columnName = column.ColumnName;
datatable.DefaultCell.BackgroundColor = Color.WHITE;
Phrase phrase = new Phrase(row[columnName].ToString(), FontFactory.GetFont("Arial", 8));
datatable.AddCell(phrase);
}
}
document.Add(datatable);
document.Close();
}
-- modified at 7:54 Saturday 6th October, 2007
People often say that motivation doesn't last. Well, neither does bathing - that's why we recommend it daily
Akhilesh Singh
|
|
|
|
|
How to make a msgbox in asp.net? Thanks
|
|
|
|
|
You need to do it in javascript, with an alert statement
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
U can easily do it using JavaScript .....
<script language="javascript" type="text/javascript">
function Button1_onclick()
{
alert("Hi This is a message box");
}
</script>
-------------
<input id="Button1" style="z-index: 100; left: 128px; position: absolute; top: 112px"
type="button" value="button" language="javascript" <b>onclick="return Button1_onclick()</b>" />
u can also use VB Script ..... for the same, but on that case u have use Msgbox("Your message" instaed of alert!!!
Good luck !!!
Happy Programming
-----
Abhijit
|
|
|
|
|
Abhijit@CodeProject wrote: u can also use VB Script ..... for the same, but on that case u have use Msgbox("Your message" instaed of alert!!!
And of course, this only works in IE
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Nine Tails wrote: How to make a msgbox in asp.net?
Private sub MsgBox(ByVal Msg As String)
Dim strScript As String = ""
strScript += "<script language=JavaScript>"
strScript += "alert('" & Msg & "');"
strScript += "</script>"
Response.Write(strScript)
End sub
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
|
|
Abhijit@CodeProject wrote: just confirm me one thing that weather it can be called by a html control or not ????
HTML controls run on the client-side and Server Controls runs on the Server-Side. The VB.NET function which I gave to alert a message will run on the server-side. But the Statement Response.Write will write the script to the Client and it alerts a message.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
That i got!!! i just want to know,,,, i have a button,
can we call that function from click on this button ???
Happy Programming
-----
Abhijit
|
|
|
|
|
why do you want to complicate the things?
To alert a message on the click of HTML button...
<.input type="button" value="MsgBox" 0nclick="alert('This is a MsgBox Sample.');">
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Thanks
Happy Programming
-----
Abhijit
|
|
|
|
|
From any control, you can call it from any client side event you like, but the code is simple enough that you'd do better IMO to just inline it, so add the alert call to the event, instead of calling such a simple function.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: "you'd do better IMO to just inline it, so add the alert call to the event, instead of calling such a simple function "
could u kindly explain me in details ???
And also inform me how can i call that function from a html button control???
Thanks in Advance !!!
Happy Programming
-----
Abhijit
|
|
|
|
|
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks a lot !
Happy Programming
-----
Abhijit
|
|
|
|
|
there is a Use Simple file sharing Recommended (after unchecking this option , i will be given the security tab for every file and folder) in the folder option > view in the window explorer.which is appearing in the drived other then the frived where the operating system is not installed.
Example my operating system is installed in c drive.no i am not getting the security tab for the file or folder in c drive.
Actually i have to access the database which is residing in th c drive , and i am unable to provide the access permission to my database
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
Hi,
Some times any of the webpage does not behave correctly, I was asked to do IISRESET. What does this do actually?
Thanks & Regards,
Rakesh
Rakesh
|
|
|
|
|
stops IIS and starts it again.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I can clearly see in the command prompt that the IIS gets stop and then started when I run the command IISRESET. What I was looking is that what happens internally in the IIS, which fixes lot of issues raised in the webapplications.
How it is a single solution for many problems?
Thanks,
Rakesh
Rakesh
|
|
|
|
|
It will cause your web app to restart, thus solving, for example, issues where your use of session state gets tied in knots.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
It's Strat and Stop the IIS..
WE are deploying our web application to IIS, and it has a link with Framework version also.
Instated of Run command u can reset ur IIS programitacally also accordign to ur requirment !!!!
Good luck !!!
Happy Programming
-----
Abhijit
|
|
|
|
|
type iisreset /h into a command prompt and you'll see all possible commands with (short) explanations.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Hi
i am using two radio buttons in my application.
here one button set as default at page load.the second button selection code results write in javascript.if i select second button and run the code then results display,the checking of second button go to default.because page loaded,i want to checking second button still display results also.plz send answer
regards
venkat
|
|
|
|