Sunday, May 1, 2011

Hey ye...how are you guys? i hope in a pink of health :)

I just wanted to start out writing stuff that comes to my mind....rough thoughts, drafts that are hopelessly put out, but yet i need to cover up these thoughts as they might haunt me afterwards.
so, what should i start off with? i don't know exactly....lets c....ammm..hmmm......ahhhh!!!!!
i MAN should always stand up for the statements he makes(i'll say MAN as philosophers say for human beings :) ) ...sometimes we feel like not giving response to a comment which is hard to swallow. that is the time when you show ur exact nature by responding to the comment...and if a MAN responds in a respectfull way..that is the true sign of a mannered MAN. There are very few people i have seen that makes such gestures, but such people makes a good life out the tiny things of life.

Currently i am reading 'parava' of G.A KUlkarni...it is not his books that i am interested in than more in HIM itself...you see its hard to decipher a person from his work than actually reading his work which is not intended of audience(more than one person) like in this case i would surely like to read his letters which other authors or his contemporary writers of his period.

now there is another concept i want to discuss..is there really a concept like "I am in a wrong field!!!" i never thought there is such thing...i seriously feel that there is nothing different in any field in this world. all field have some un-recognised/un-deciphered concept that just cant be unfurled by many peoples who..... is there any way that we can collage the current field with the interest-of-field? i really don't know but i always feel that there is a lot of intersection between any two aspects of life. say like if there is a intersection of computers and mathematics.....there is a lot of ....rest for next time

Saturday, January 2, 2010

Invoking COM word object in Php script and using COM

Use COM object in PHP using WORD.APPLICATION to convert or saveas() file(doc/docx) to word, html, txt, UTF-8,Unicode,RTF.

Invoking COM word object in Php script and using COM.

  • OK. It’s way old technology but it’s important to understand how it’s used with new technologies or emerging technologies like Php. So here is the basic and some walk through about COM & DCOM.
  • The very basic question comes to mind, why we need com object to invoke word application… cant php do it all by itself ?
  • NO, MS doesn’t provide such functionality to invoke objects without COM. As these applications are developed using com technology they must be invoked by COM (best to my belief and understanding , I’ve not came across any other alternative technique). Com is Language independent.

COM is used to communicate with objects (e.g. word or excel or faxing application). COM will set rules about how objects need to be invoked as well as how to send messages between objects in a particular way, which makes it easier for objects written in different languages to communicate with each other.

OBJECT: it is combination of properties (attributes, data) and methods (functions, code ). Properties : top, left, width, etc and methods: onChange, onExit, onClick, etc. c++ programmers can imagine object diagram.

Diagram of object

.

COMPONENT: reusable piece of executable code that can be used with other applications with minimum efforts; could be .EXE, .DLL or .OCX .

INTERFACE – set of functions grouped together under one name.COM uses Vtables to define Virtual functions(basically functions) in memory, so any language that supports calling functions via pointers can be used to write components.it provides programming language independency

E.g. in php : $word->Documents->Open('C:/test1.doc');

Diagram of interface,component,object.

  • To develop a application(website also considered) which uses word for finding solution to problem you can interact with Microsoft office word objects. Word objects has two main classes they are the Application and Document classes.
  • The Application object represents the entire application, each Document object represents a single Word document.This will be useful while declaring or invoing word functions.
  • Once the document is invoked we can open any file format which is permissible in word application and saveas() it into any other format.

COM Type Libraries…

It is basically documentation about collections, objects, methods (with their parameters), and properties (with their data types) that are exposed for use by COM client applications.

Eg. com_load_typelib('Word.Application');

Distributed COM….

COM can be used as Distributed component, which is not bound by any one process nor it can be stopped by another process at remote m/c (any other computer connected to yours, apart from your's) is DCOM.

Two types of processes occupy memory in Windows: OS processes and User (other)

Processes. All (user or ) other processes have a separate process space in which they keep their variables, and the OS grants a place which is shared by all, this is where shared code is written.

Server – a piece of code that implements component (reusable code E.g. exe, dll) object.

In-process – the server code executes in the same process space as the client (as DLL)

Out-of-process or remote – the server code runs in another process on the same machine

or in another process on a remote machine (as an EXE).

Local process – the code runs in the same process space on the same machine

DCOM uses surrogate process (you cannot run in-proc server on a remote machine. You need a surrogate process to do that.)

GUID: Every COM component is registered in the Windows registry and has a unique 16-byte number. This number is unique for every COM component of this

world. Whenever the COM component or a library is called,it is checked by its GUID in the registry.

E.g. The type library GUID, followed by its version number, for example {00000200-0000-0010-8000-00AA006D2EA4},2,0.

COM component or library looks for supplied GUID, whether it is registered or not if it is registered then server is loaded into memory server will run the component that is located and services of the component are utilized.

Marshalling – Case I

If another process, P2 requests reference to the same COM component, then instead of calling it again in P2, P2 is given a hypothetical object of the COM component. Even though P2 interacts with the object in some other process but it functions as if it has its own copy of the object.

Marshalling – Case II

If the component is registered but the server that is required to run the component is located on a remote computer then the process defined in Case I is repeated.The only difference being it is done for a remote computer, and consequently, has greater overhead.

Creating a COM Object

//invoke word application

$word = new COM("word.application") or die("Unable to instantiate Word");

//This will open up one Word Instances.

$word->ActiveDocument->Close(false)

The document that has the focus is called the active document and is represented by theActiveDocument property of the Application object.

COM Execution is done in its client Machine where DCOM Run on selected server

This is a code to embed COM object in php to invoke word application as a part of your solution where input is doc file and ssaveas() function will convert the doc file into other mentioned formats(txt,html,Unicode,RTF).

Firstly I’ll provide with the code …test it ..run it..execute it.Then look into the working.

// this piece of code takes “test1.doc” and saveas it into “aa.txt”

com_load_typelib('Word.Application');

// create instance of word file

$word = new COM("word.application") or die("Unable to instantiate Word");

// use like this. Place yours word file in C drive

$word->Documents->Open('C:/original_doc_file.doc');

// create text file with name as “converted_text_file.txt”

$new_text_file = "c:/converted_text_file.txt";

// word Document = 0; word Template = 1; Text file = 2; Text file with Line Breaks = 3; Text with DOS encoding = 4; Text file with Line Breaks DOS encoding = 5; RTF file= 6; Unicode Text file = 7;

// documents[1] is used to “saveas” file for different functions different array elements are used.

$word->Documents[1]->SaveAs($new_text_file,2);

// The document that has the focus is called the active document

$word->ActiveDocument->Close(false);

$word->Quit();

$word = null;

?>

Saturday, January 10, 2009

A person to look upon

After many years i found a musician to hear. First i was (still i am dont know why i wrote 'was')
influenced by Emin3m his style of writing, the flow he has had in his lyrics, the impeccable words, the free authentic dialect, unstoppable childish-voice(ya,really i find it child-like).he has a harsh way of telling the truth. but sometimes, people need such ways to tell the truth.
simply great,outstandingly awesome.
Now, its John mayer oh boy his lyrics are real super-cool,the way he explains in 4-word sentence the whole meaning of the moment it's really commendable. He just sets free the listener,gives him wings to fly.he has a great sport of lyrics, uses a daily routine words and puts it magic boxes of pleasure, sucked the 'moments air' for living the lyrics.
'When you're dreaming with a broken heart

The waking up is the hardest part '
so very true as it is what a way of saying things so easily without wasting one energy by complicated words.

i think both have in common that really pushes me to like their work : simplicity, explicit (in a way to express the right moment) . both are the extremities of 'the way life is seen' yet both been in same position not have had girlfriends in their school years,both wanted to drop-out of school(john wanted to and emi failed 3 years in 9th grade). so may be they understands what a girls wants or what a boy wants without actually experiencing it first hand.
good bye..
going quiet

Wednesday, December 10, 2008

my exam times

today i realised that during exam times i tend to get a bit more self-cocerned.this is the time when people start to hate me and i am like "hey ,yaar whaat have i done to deserve this?". the self-concerned i mean is,see , i don't study regularly so at the elevnth hour i make a point that i will clear the subject with atmost sincerity. but in this process i tend to become more of serious guy who doesn't speak to anyone or make any jokes nothing, nothing at all. people start thinking this guy is sick such a moody bastard and i still sit quiet.u see i have this feeling of doing things as multi-tasking i know this is not a good habbit but i feel it is the time to work on it so i follow such agendas.
secondly,i think that my concentration is poor so i try to read lines loudly with concentration, in meanwhile if someone asks me a favour i just dont make a eye contact and give responses.again a cause of agitation against me.these are the harsh realities that i face every exams and i have realised yet this things keep happening to me. i know i am the sole responsible person to it and i woundn't like to blame anyone for it too but this is sad reality that i need to consider and work on it.
other than exam times i am as cool as mist never making things complicated just taking things as they are. such great days i need to cope with make studies quite simple and behave as a normal person even in hard times.