Showing posts with label Open Office. Show all posts
Showing posts with label Open Office. Show all posts

Tuesday, July 12, 2011

Editing PDF files on linux, Two solutions

Since most our meetings and seminars are presented as PDF files. I finally realised that I need some way to edit them on Linux. Something as simple as adding comments and such would do. couple of research attempts lead me to the following link:
http://www.cyberciti.biz/tips/open-source-linux-pdf-writer.html


I tried PDFedit instantly and it did deliver what it promised. the only problem is the limited selection of arrow shapes (hard to use for Feynman diagrams).


To install and run:
$ sudo apt-get install pdfedit
$ pdfedit /path/to/pdf.file & 

The code runs smoothly but has it's limits; If the document had symbols unrecognised by it (Say Japanese characters or Math symbols). It will open but with many of it's functions missing. 

Another option is Open office! They new release (3.0 and after) has a package that is able to open PDF files on a drawing pad. you will even get to stick comments and such. This approach also suffers when opening some unrecognised set of fonts or objects. It will still be fully functional but the locations will be misset up as well as missing some symbols. 

We conclude this note with Images. Where your best bed is with GIMP. Which is a standard release in UBUNTU. Once you do the changes make sure to save as xcf. then using the command:
$  convert file.xcf file.pdf

You will get he new file in the required form.

Monday, January 17, 2011

Starting Open Office from shell

I ran across this excellent reference on how to start OO from shell. instead of that silly file name I just opened it on my desktop and dumped the code. What it worth mentioning is that it opens whatever release you currently have. for completion the code it below:

################
import com.sun.star.bridge.XUnoUrlResolver;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;

import java.io.IOException;
import java.io.InputStream;

/**
 *
 * @author bobohead2
 */
public class StartOpenOffice {
   
    private String unoUrl =
            "uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager";
   
    /** Creates a new instance of StartOpenOffice */
    public StartOpenOffice() {
    }
   
    public boolean startOpenOffice(String p_scriptpfad){
        boolean loaded = false;
        try {
          // loads the script
            String cmd = p_scriptpfad     //home/bobohead2/OpenOffice.org1.1/ListenOffice.sh";
            Process process = Runtime.getRuntime().exec(cmd);
            InputStream processOut = process.getInputStream();
            InputStream processErr = process.getErrorStream();
           
        } catch (IOException ioe) {
            ioe.printStackTrace(System.out);
        }
        while(loaded == false){
            try{
               // open Office may take a while to open
                XComponentContext xLocalContext =
                       com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
               
                XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
               
                Object urlResolver  = xLocalServiceManager.createInstanceWithContext(
                        "com.sun.star.bridge.UnoUrlResolver", xLocalContext );
                // query XUnoUrlResolver interface from urlResolver object
                XUnoUrlResolver xUnoUrlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface(
                        XUnoUrlResolver.class, urlResolver );
               
                // Second step: use xUrlResolver interface to import the remote StarOffice.ServiceManager,
                // retrieve its property DefaultContext and get the remote servicemanager
                Object initialObject = xUnoUrlResolver.resolve( unoUrl );
                loaded = true;
            }catch(Exception e){
                // open office is not ready yet
                loaded = false;
                // wait a liitle bit and try again
                for(int i=0;i< 10000;i++){
                   
                }
            }
        }
        return loaded;
    }
}
##########################

and to run it just type:
#!/bin/sh
/opt/openoffice.org2.0/program/soffice "-accept=socket,port=8100;urp;"