Menu

j2docx / Blog: Recent posts

Sample Program 2

Sample Program:2
import java.io.FileNotFoundException;
import java.io.IOException;

import org.jdom.JDOMException;

import com.j2docx.operations.DOCXHandler;
import com.j2docx.spray.BookmarkSprayer;
import com.j2docx.util.DocxHandlerException;

/*
* @author j2docx
* Demo for spraying image
/
public class ImageSpray {
public static void main(String[] args) {

    try{
        //for extraction
        String docPath= "C:/demo/sample.docx";
        String targetDirPath="C:/demo";

        //for archiving
        String extractedPath= "C:/demo/sample";

        //Bookmark name
        String bookmarkName="bm1";

        DOCXHandler docxHandler= new DOCXHandler();
        BookmarkSprayer BMSprayer= new BookmarkSprayer();

        //Extracting docx to the targeted directory path
        docxHandler.doExtract(docPath, targetDirPath);

        //Spraying Image

BMSprayer.sprayImage(extractedPath, bookmarkName,70,180, "C:/images/sample_image.jpg");

        //Archiving back to get docx file
        docxHandler.doZip(extractedPath, docPath);
    }
    catch(DocxHandlerException dhe){
        dhe.printStackTrace();
    }
    catch(FileNotFoundException fnf){
        fnf.printStackTrace();
    }
    catch(IOException ioe){
        ioe.printStackTrace();
    }
    catch(JDOMException jdome){
        jdome.printStackTrace();
    }
}

}

Posted by Vinothkumar PT 2012-10-28

Sample Program 2

Sample Program:2
import java.io.FileNotFoundException;
import java.io.IOException;

import org.jdom.JDOMException;

import com.j2docx.operations.DOCXHandler;
import com.j2docx.spray.BookmarkSprayer;
import com.j2docx.util.DocxHandlerException;

/*
* @author j2docx
* Demo for spraying image
/
public class ImageSpray {
public static void main(String[] args) {

    try{
        //for extraction
        String docPath= "C:/demo/sample.docx";
        String targetDirPath="C:/demo";

        //for archiving
        String extractedPath= "C:/demo/sample";

        //Bookmark name
        String bookmarkName="bm1";

        DOCXHandler docxHandler= new DOCXHandler();
        BookmarkSprayer BMSprayer= new BookmarkSprayer();

        //Extracting docx to the targeted directory path
        docxHandler.doExtract(docPath, targetDirPath);

        //Spraying Image
                    BMSprayer.sprayImage(extractedPath, bookmarkName,70,180, "C:/images        /sample_image.jpg");

        //Archiving back to get docx file
        docxHandler.doZip(extractedPath, docPath);
    }
    catch(DocxHandlerException dhe){
        dhe.printStackTrace();
    }
    catch(FileNotFoundException fnf){
        fnf.printStackTrace();
    }
    catch(IOException ioe){
        ioe.printStackTrace();
    }
    catch(JDOMException jdome){
        jdome.printStackTrace();
    }
}

}

Posted by Vinothkumar PT 2012-10-28
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.