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

Wednesday, November 24, 2004

Showing a Excel report in a Web Page by using Response.Content Type

When showing Excel in a Webpage using a dataset and binding the dataset to a datagrid. Make sure that you keep EnableViewState=false.This is because State is getting lost when you bind the data to the datagrid.This is to maitain state accross the webpage.



Monday, October 11, 2004

Using XML Serialization

I have started my code for a bigger module. Which contains Lots a new stuff. I have lots of new things to explore. I need to learn a lot. Till now i have a learnt a Very little bit. It was said "Known is a drop and Unknown is a ocean." I have used XML Serialization for loading data into a dataset. This goes likes this I will get all the data in a array list The array list contains objects of a class (which is a model class which contains only properties) I will loop through the array list and get the xml strings. All the xml strings will be loaded to into string builder. After that i will load the xml to a dataset. But this approach has some issues. The xml is loaded into different tables i.e. all the elements in the xml file are loading into different tables. That’s why i looked for some other work around for this. I will make the model class as a data table. All the properties will become columns in the datatable. After getting the datatable i will attach this datatable to dataset. The dataset will be loaded into a data grid. I need to see how this goes.
I have known that the above approach is very useful.
But we can load the arraylist directly to the data grid.
The arraylist contains a bunch of Model class which contains property values.
We have to assign the data source of the data grid to the array list and we need to assign the specific property names to the data grid.


Monday, September 27, 2004

I have made a dession

Now I have made decision that I will concentrate more on design. I have to learn more about class design and use case design the things what i have learnt are not enough. Today i have learnt about association, abstraction, composition, aggregation and specialization.
Definitions
Association:- kind of relationship or link between classes. Associations are further documented by stereotypes + roles + multiplicities + constraints + descriptive names + aggregation indicators + navigability indicators. [ uml.coll0.gif ] [ uml.coll1.jpg ] [ uml.game.gif ] [ uml.association.gif ] [ uml.link.gif ]
Composition:- composition::= a strong form of the 'has_a' or APO relation so that deleting the whole automatically removes the parts as well. Composition fits when objects of one class are made up of parts that are objects of other classes, for example when they are implemented using fields in structures, items in records, columns in a data base, or pieces of a document. However, in some cases, the responsibility for keeping an object alive changes during that objects life, and so that objects class would be shown as being parts of several different compositions. [ clock2.gif ] [ uml.period.gif ] [ uml.link.gif ]
Aggregation: - aggregation::=a way that one class can refer to another class without having possession of it + a weak form of 'has-a' / APO link + if the whole object is an aggregation then deleting it does not effect the existence of the aggregated part. An open diamond at one end of a link shows this relationship. The other end may have an arrowhead indicating the link can be navigated in one direction only.
Specialization:- When we derive a class from an existing class and add some functionality to it becomes a specialization

Wednesday, September 22, 2004

Chalenging Phase

This year i had great achievements in this year. I worked with VB3 to VB6 porting and FORTRAN to digital FORTRAN. In the December of 2000 i had a trip to US. Which I worked on cad package written in VC++ and written some Com components in VB6.0. I had a very good experience while working with that. I enjoyed my stayed in the US.
After that i have worked on JAVA. I have learnt java and brought a computer at home.
In may 2000 i worked a big project which is a Unix to NT porting which i had written relevant C-Win32 sdk code for UNIX Shell scripts got a very good exposure with SDK commands of WIN32.
This went on 6 months. Then i was put into another project form which i got very good exposure on Datawarehosing concepts and started working on Business objects.
This went on one year.
This time my focus is shifted to Visio automation and the relevant add-ins which help in editing the Visio map. I explored to Visio automation to maximum extent.




The days when i joined Infotech 1st May 1997

My Project at InfoTech was a VB 3 Project and MS access Project. Which i was working on Windows 3.1.I used to spend upto 1 'o' clock in the night at office when i started my career. That was my initial step towards learning process.