Visit Map

Sunday, July 17, 2005

Creating word to PDF

Hi,

I had opportunity to convert the word document to PDF. The word document is passed to a procedure. The procedure parseS the word document to create a PDF. The code is given below
I have used ITextDotnet which is converted from Java to J#.
You can download the ITEXTDOTNET code from Sourceforge.net
http://sourceforge.net/projects/itextdotnet/

using System;
using Word;
//use the ITextDotnet
using ds=com.lowagie.text;
//include the pdf libary
using com.lowagie.text.pdf;
using System.IO;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
namespace WindowsApplication3
{
///
/// Summary description for WordDoc.
///

public class WordDoc
{
public WordDoc()
{
//
// TODO: Add constructor logic here
//
}
public void ProccessWordDoc(Word.Document doc)
{


// step 1: creation of a document-object
com.lowagie.text.Document document = new ds.Document(ds.PageSize.A5, 36, 72, 108, 180);

// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file

PdfWriter.getInstance(document, new FileStream(doc.Name.Replace(".doc",".pdf"), FileMode.Create));

// step 3: we open the document
document.open();

// step 4: we add a paragraph to the document


//com.lowagie.text.Image img=new com.lowagie.text.Image()

foreach(Word.Paragraph para in doc.Paragraphs)
{
com.lowagie.text.Paragraph paragraph = new ds.Paragraph();
switch(para.Alignment)
{
case WdParagraphAlignment.wdAlignParagraphCenter:
paragraph.setAlignment(ds.ElementConst.ALIGN_CENTER);
break;
case WdParagraphAlignment.wdAlignParagraphJustify:
paragraph.setAlignment(ds.ElementConst.ALIGN_JUSTIFIED);
break;
case WdParagraphAlignment.wdAlignParagraphLeft:
paragraph.setAlignment(ds.ElementConst.ALIGN_LEFT);
break;
case WdParagraphAlignment.wdAlignParagraphRight:
paragraph.setAlignment(ds.ElementConst.ALIGN_RIGHT);
break;
}
paragraph.add(para.Range.Text);

document.add(paragraph);

}


// step 5: we close the document
document.close();
}
}
}
Hope you like my Idea.
This is a basic prelimary version.

Friday, April 22, 2005

Using Microsoft Agent from .NET

Download the microsoft agent from http://www.microsoft.com/msagent/default.asp. If not present at /msagent\chars
Add a reference to Microsoft Agent server using tools - references - Microsoft Agent server 2.0
Here is the code

IAgentCtlCharacterEx Genie;
Keep a textbox on form and a button in the button click keep the following code

IAgentCtlCharacterEx Genie;
if(textBox1.Text!="")
{
Agent1=new AgentClass();
try
{
Agent1.Connected = true;
string strPath=ConfigurationSettings.AppSettings.Get("path").ToString();
//strPath is /msagent\chars
Agent1.Characters.Load("Merlin",strPath);
Genie=Agent1.Characters.Character("Merlin");
Genie.Show(true);
Genie.Speak(textBox1.Text,"");
}
catch(Exception ex)
{
throw ex;
}


This is just an idea to share

Sunday, April 17, 2005

Checklist:ADO.NET Performance

While browsing the Net i came across one book
Improving .NET Application Performance and Scalability called ScaleNet.pdf
You can download the same from www.microsoft.com/practices
The book is very goood. I suggest you to read that book

In that they given a checklist
Here is checklist for ADO.NET Performance

Design your data access layer based on how the data is used.
Cache data to avoid unnecessary work.
Connect by using service accounts.
Acquire late, release early.
Close disposable resources.
Reduce round trips.
Return only the data you need.
Use Windows authentication.
Choose the appropriate transaction type.
Use stored procedures.
Prioritize performance, maintainability, and productivity when you choose how to pass data
across layers.
Consider how to handle exceptions.
Use appropriate normalization
If you follow the above checklist you can increase the performence of a .NET Application

Thursday, April 07, 2005

Session State

Recently i had doubt on a session is handled between Classic ASP and Classic ASP.NET.The session management between ASP and ASP.NET is sticky issues. An article from Egghead Café cleared by doubts.
http://www.eggheadcafe.com/articles/20021207.asp
I also went through the article in MSDN how a session is managed in ASP.NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconsessionstate.asp

Microsoft User Group Hyderabad is conducting a session on Existing and Emerging technologies the session in Cyber towers, Chip Auditorium Madhapur Hyderabad.
One can register at www.mugh.net/devcon.htm.

Saturday, March 12, 2005

Error Registering ComPlus Components

I have solved the problem of Com + Registration problem on Windows 2003. "Type Library cannot be loaded".
The problem is with the path.The path C:\WINNT\Microsoft.NET\Framework\v1.1.4322 is not specified in the path string, Environment Variables.
Before ten days it was working so to know this we have downloaded the FileMon from www.SysInternals.com monitored the dllhost.exe.
The dllhost.exe is shown in the FileMon saying "mscorlib.tlb" Path Not Found.
Then I searched for the path and found out that C:\WINNT\Microsoft.NET\Framework\v1.1.4322 is not there in the path string
I have kept it there, then components are registered