TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vikas
NA
22
0
printout() function problem
Aug 25 2010 7:06 AM
i m using below code..by using it i able to write asp data into word file n format it.but i m facing problen in print out..
please hav a look to below code....
view plaincopy to clipboardprint?
.................div data...................
<div id="printdiv" runat="server">
<table style="border: 5px solid #FF00FF; width:100%">
<tr>
<th align="left" style="background-color: #00FFFF">Vikas:Ji</th>
</tr>
<tr>
<th align="right" style="background-color: #800000">Vikas:Ji</th>
</tr>
<tr>
<th>Vikas:</th>
</tr>
<tr>
<th>Vikas:</th>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</div>
..............to write dive data into word file
public void PrintControl()
{
try
{
String strr = printdiv.InnerHtml;
string strPath = "C:\\Documents and Settings\\hgtech\\Desktop\\WordForm\\abc.doc";
FileStream fStream = File.Create(strPath);
fStream.Close();
StreamWriter sWriter = new StreamWriter(strPath);
sWriter.Write(strr);
sWriter.Close();
edit_changes();
}
catch (Exception err)
{
//error.Text = err.Message;
}
}
.........................To format the word file...set left and top margin.........................
private void edit_changes()
{
Object missing = System.Reflection.Missing.Value;
Object fileName = "C:\\Documents and Settings\\hgtech\\Desktop\\WordForm\\abc.doc";
Word.Application wordApp = new Word.ApplicationClass();
Word.Document oDoc = new Word.Document(); ;
Object;
// oDoc.Close(ref missing, ref missing, ref missing);
if (File.Exists((String)fileName))
{
DateTime today = DateTime.Now;
Object isVisible = false;
wordApp.Visible = false;
oDoc = wordApp.Documents.Open(ref fileName, ref missing, ref
missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref
isVisible, ref missing, ref missing, ref missing, ref missing);
oDoc.Activate();
oDoc.PageSetup.TopMargin = 150.0f;
oDoc.PageSetup.BottomMargin = 200.0f;
}
object Background = true;
object Range = Word.WdPrintOutRange.wdPrintAllDocument;
object Copies = 2;
object PageType = Word.WdPrintOutPages.wdPrintAllPages;
object PrintToFile = false;
object Collate = false;
object ActivePrinterMacGX = missing;
object ManualDuplexPrint = false;
object PrintZoomColumn = 1;
object PrintZoomRow = 1;
oDoc.Close(ref missing, ref missing, ref missing);
oDoc.PrintOut(ref Background, ref missing, ref Range, ref missing,
ref missing, ref missing, ref missing, ref Copies,
ref missing, ref PageType, ref PrintToFile, ref Collate,
ref missing, ref ManualDuplexPrint, ref PrintZoomColumn,
ref PrintZoomRow, ref missing, ref missing);
Reply
Answers (
1
)
stegnography using images
Reading and writing Word documents