Embed doc in a generated doc file in java
I need some help regarding this, I used WordprocessingML to generate a Word document..now, I need to embed a file in the generated document..I did some research and found out that it transforms the embedded fle into a 64bit binary stream, but don't have an idea how to do it..I need some insight on this one..thanks
How are you generating the Word documents, manually? I haven't used it, but it looks like docx4j might be good library for building the documents. General documentation can be found [here|http://dev.plutext.org/trac/docx4j/wiki], description of [Java API|http://dev.plutext.org/docx4j/javadoc-2.2.2/] and here's the [download|http://dev.plutext.org/docx4j/].
Cheers, harald
Similar Messages
-
Problem with reading text from .DOC files through java and POI
I have used a jar file "poi-scratchpad-3.2-FINAL-20081019.jar" and "poi-3.2-FINAL.jar" to read text from a .DOC file. I used the "getParagraphText()" function of the class "org.apache.poi.hwpf.extractor.WordExtractor" to get the text.
I am able to get the text in the .DOC file but along with that i am getting the following messages/warnings
Current policy properties
* thread.thread_num_limited: true*
* file.write.state: disabled*
* net.connect_ex_dom_list:*
* mmc.sess_cab_act.block_unsigned: false*
* mmc.sess_cab_act.action: validate*
* mmc.sess_pe_act.block_blacklisted: false*
* mmc.sess_pe_act.block_invalid: true*
* jscan.sess_applet_act.stub_out_blocked_applet: true*
* file.destructive.in_list:*
* jscan.sess_applet_act.block_all: false*
* file.write.in_list:*
* file.nondestructive.in_list:*
* window.num_limited: true*
* file.read.state: disabled*
* jscan.session.origin_uri: http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/poi/poi/3.2-FINAL/poi-3.2-FINAL.jar*
* file.nondestructive.state: disabled*
* jscan.session.user_ipaddr: 10.136.64.153*
* net.connect_other: false*
* thread.thread_num_max: 8*
* file.destructive.ex_list:*
* file.nondestructive.ex_list:*
* file.write.ex_list:*
* jscan.sess_applet_act.sig_invalid: block*
* file.read.in_list:*
* mmc.sess_cab_act.block_invalid: true*
* jscan.session.policyname: TU1DIERlZmF1bHQgUG9saWN5*
* mmc.sess_pe_act.action: validate*
* thread.threadgroup_create: false*
* net.connect_in_dom_list:*
* net.bind_enable: false*
* jscan.sess_applet_act.sig_trusted: pass*
* jscan.session.user_name: 10.166.64.201*
* jscan.session.user_hostname:*
* file.read.ex_list:*
* jscan.sess_applet_act.sig_blacklisted: block*
* jscan.session.daemon_protocol: http*
* net.connect_src: true*
* jscan.sess_applet_act.unsigned: instrument*
* mmc.sess_pe_act.block_unsigned: false*
* file.destructive.state: disabled*
* mmc.sess_cab_act.block_blacklisted: true*
* window.num_max: 5*
Below the above messages/warnings the data is getting printed. Only the text part of the data is retrieved not the fonts, styles and bullets etc.
Can anyone explain me why I am getting above warnings and how can I remove them. Is it possible to fetch the text depending on delimiters.
Thanks in advance,
Tiijnar
Edited by: tiijnar on May 21, 2009 2:45 AMThe jar files which were used are downloaded from http://jarfinder.com. Those jars created the problem of displaying those messages on console. I downloaded APIs from apache.org and used them in my application. Now my application is running good.
Tiijnar -
How to load word .doc-files into java applications?
Hi,
I want to load a word .doc-file (or any other type of document) into a java application, as part of the application.
Is there any java special library to do it?
Any solution or hint?
Thank you.No, there is no existing Java library to do it that I am aware of. You could write your own, however, as the Word 97 binary file format is published. I am not sure that the Word 2000, or XP formats are as well, but since they put out the 97 presumably they'd do the same with the rest -- although I am suprised that Micro$$$oft even published the 97 format.
A library such as this would take quite some time write, due to the extensive format, but here's a link to a copy of it just so you can see what it'd take: http://www.redbrick.dcu.ie/~bob/Tech/wword8.html
Also keep in mind that Micro$$$oft has never remained binary compatable between versions. In short, this means that you'd have to parse each version's documents differently. Not a fun task.
If a Java library to read Micro$$$oft file formats already does exist, I'm willing to bet that it costs $$$ mucho dinero $$$.
Hey, aren't proprietary file formats just wonderful? -
HOW TO SEARCH THE LOCATION OF A PARTICULAR FILE(say a doc file) IN JAVA
JAVA CODE FOR FINDING THE LOCATION OF A PARTICULAR FILE(say a doc file)
Well you can write a recursive/iterative code using methods provided by
java.io.File class.
However,there are few customized frameworks coming up which can to job for you please have a look at.
https://filesearch.dev.java.net/
else where if you wanna build up your own solution the below POST could be useful.
http://en.allexperts.com/q/Java-1046/desktop-file-search-1.htm
or you might go ahead and use source of file search utility where an implementation is provided in the below article
http://jdj.sys-con.com/read/36412.htm
Hope this might help :)
REGARDS,
RaHuL -
Open .doc file in java on Windows 98/2000
Hi all,
I need to open a .doc file on Windows 98/2000 PC thriugh java.I have used the command
Runtime.getRuntime().exec(new String[] {"cmd", "/C", "start", "\"\"", filename});
This command works fine on Window 2000 but gives IO Exception: CreateProcess: start <filename> error=2
So I tried the command
Runtime.getRuntime().exec("start"+filename);
Now this command works fine on Windows 98 but gives the same error on Win2000.
Someone please suggest a command which will work fine on all Windows OS.
Thanks in advanceHave a look at the Java Desktop Integration Components Project https://jdic.dev.java.net/documentation/index.html
especially look at
https://jdic.dev.java.net/nonav/documentation/javadoc/jdic/org/jdesktop/jdic/desktop/Desktop.html#open(java.io.File)
which opens a File using the default application associated with this kind of file. -
The nicest way to generate xml-files by Java???
I have to generate huge and quite complex xml files by Java. I have to fetch the data from a Oracle database. What I really don't know is a proper and reliable way to this? I could of course create a String and concatenate all the tags, attributes and data but it doesn't feel right. I guess this is a quite common task and there are many established ways to this by Java. My question is what is the best way to this? What is your suggestion?
Thank you for any clues...Hi,
Since you have access to the database, I think one of the best way is to create stored procedures that will generate those files for you (using SQL/XML functions preferably) and return the content to the Java caller. -
Do i required to generate XML file for JAVA upgrade.
Dear frnds,
I am in process of upgrading EP 6.0 to EP 7.0 EHP1 for SR1.
I am following document Upgrade Guide SAP NetWeaver 7.0 Java Including Enhancement Package 1
As of media list guide i have selected .
51036889_1/2 for UPG MASTER BS7 SR1
51037093_1,2,3 for NW 7.0 EHP1 SR1 java SW components 1/2
51036767_2 for BS7 UC kernel 7.01 AIX 64 bit.
Well, i have a query here when i am doing upgrade on ABAP stack ECC 5.0 to ECC 6.0 EHP4 SR1 i alowed to select required compoenets , which eventually will generate mea XML file in Solution manager system.
But, When i have planned to UPGRADE only JAVA Stack for EP 6.0 to EP 7.0 EHP1 SR1. When i selected my system in Solution manager i am not getting option for UPGRADE.
If it is so how about my XML file during JAVA upgrade is not mandatory or not .. Please advice me on this.
regards,
rahulHi Rahul,
Yes, for Java Upgrade to EHP1 you need xml file. Normally you should be able to download xml file from solution manager from MOPZ.
If you are not able to download it from solman then you can also download the xml file from service market place and this is only for EHP1. Follow below procedure to download xml file from SMP for EHP1:
Go to https://websmp205.sap-ag.de/sp-stacks
Click on SP Stack download.
Select SP Stack Netweaver 7.0 (New window will open)
Then on New Window Select Source Stack, Target Stack and usgae type. Then Click Next.
On Next screen Select Kernel and IGS. Then Go Next.
On that screen you will get a option to Save as File. Then save as xml.
This is the xml file that you can use in upgrade.
For EHP4 you cannot download it from service market place.
Thanks
Sunny -
Generate Excel File using Java
Hi,
could any one tell me how can I create an Excel file using java. I can create the file using PrintWriter and other IO classes. But how do I insert the data in to different cells and rows.
Any help would be greatly appreciated. Thanks in advance for your help,
-MSDear All,
There are three ways for achiving excel operations using java including excel to xml etc.
1. There is a very effective tool available for this operation is "jexcel". You can find it at http://www.andykhan.com/jexcelapi/index.html
2. Jakarta site has provided a very good tool by name jakarta poifs. one can find at jakarta site.
3. One can develop a very effective tool by combining these above tools togather.
The operations that can be performed are read, write, convert etc for excel. The major attraction of Jexcel is excel to xml conversion.
Regards,
Nishant Kulkarni
Software Engineer
[email protected] -
Opening .doc files from Java
Ok, here's my problem.
I'm using Java to create an autorun program for a little thing I'm putting together.
One of the options should be "Read documentation" . However, to do that, I need to make my program open a Microsoft Word (.doc) document. What is the command/how can I do this? By open, I mean open the file in MS Word for viewing.When you say "where filename is the path" do you mean
type in "\documentation\file.doc" or is it a variable?It's a variable in the example. It doesn't matter -- just as long as the resulting string passed to exec will contain the correct file name so the OS will see it. -
Printing txt/doc files using Java
Hi, i need to take in info from a GUI and format it nicely, then print it. Ive never done any printing from Java before so to get started im just trying to read in some text from a '.txt' file and send it to the printer.
I can detect the printer correctly and it seems to send the job to it because the printers own 'print dialog' thing pops up saying that its printing. When that dialog progress bar gets to 100% it disappears as it usaually does. The problem is, the printer doesnt actually do anything. Heres the code im using:
public class Printer
public Printer()
PrintService pservices = PrintServiceLookup.lookupDefaultPrintService();
System.out.println("Selected Printer: " + pservices.getName());
try
InputStream is = new BufferedInputStream(new FileInputStream("C:/j2sdk1.4.2_04/eclipse/workspace/MyProgram/mainPackage/example.txt"));
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
DocPrintJob pj = pservices.createPrintJob();
Doc doc = new SimpleDoc(is, flavor, null);
pj.print(doc, null);
is.close();
catch (IOException ie)
System.out.println("ERROR (IOException): "+ie);
catch (PrintException e)
System.out.println("ERROR (PrintException): "+e);
catch(Exception ex)
System.out.println("ERROR: "+ex);
public static void main(String args[])
Printer ps = new Printer();
}So if anyone knows whats going wrong, or if u have a nice simple code sample that deos what i want, id appreciate it.
Thanks.mmm strange... ive since moved on to a different approach and its printing fine now, thanks for your replies :) But now im having probs setting the printable region of the page.
As standard, theres a border around the page that u cant print to. When i print the PageFormat's width/height and the imageable width/height i get this;
(before) pageFormat.getWidth(): 595.19
(before) pageFormat.getHeight(): 841.80
(before) pageFormat.getImageableWidth(): 451.19
(before) pageFormat.getImageableHeight(): 697.80So as u can see, theres a boarder that u cant render to. So then i try setup a page like this;
Paper page = new Paper();
page.setSize(f.getWidth(), pageFormat.getHeight());
page.setImageableArea(0, 0, pageFormat.getWidth(), pageFormat.getHeight());
pageFormat.setPaper(page);Then, after setting the PageFormat's page to be the newly setup page, i reprint the PageFormat's width/height and the imageable width/height and i get this;
(after) pageFormat.getWidth(): 595.19
(after) pageFormat.getHeight(): 841.80
(after) pageFormat.getImageableWidth(): 595.19
(after) pageFormat.getImageableHeight(): 841.80So now u can see that i looks like the boarder is gone. The problem is, i still cant print in that margin so im obviously missing something.
Anyone able to help me? -
Crystal report - generate CSV file through Java interface
Hi,
I need to generate a Character Seperated File through Crystal Report 10 using Java.
What constant stands for CSV Format and what value of SI_PROGID we can provide to pull the CSV format.
Eg. SI_PROGID = ceProgID.EXCEL or SI_PROGID = ceProgID.PDF .....
Currentlly we are crystalLibs.jar to connect the Crystal server.
Thanks In AdvanceIn BusinessObjects Enterprise installations, the following ProgIDs are valid.
CrystalEnterprise.Analytic
CrystalEnterprise.AppFoundation
CrystalEnterprise.Calendar
CrystalEnterprise.Category
CrystalEnterprise.Connection
CrystalEnterprise.Designer
CrystalEnterprise.Destination
CrystalEnterprise.DiskUnmanaged
CrystalEnterprise.Event
CrystalEnterprise.Excel
CrystalEnterprise.Folder
CrystalEnterprise.FavoritesFolder
CrystalEnterprise.Ftp
CrystalEnterprise.Hyperlink
CrystalEnterprise.Inbox
CrystalEnterprise.InfoView
CrystalEnterprise.LicenseKey
CrystalEnterprise.Managed
CrystalEnterprise.MyInfoView
CrystalEnterprise.ObjectPackage
CrystalEnterprise.Overload
CrystalEnterprise.Pdf
CrystalEnterprise.PersonalCategory
CrystalEnterprise.Powerpoint
CrystalEnterprise.Program
CrystalEnterprise.Report
CrystalEnterprise.Rtf
secEnterprise
secLDAP
CrystalEnterprise.Server
CrystalEnterprise.ServerGroup
CrystalEnterprise.Shortcut
CrystalEnterprise.Smtp
CrystalEnterprise.Txt
CrystalEnterprise.Universe
CrystalEnterprise.User
CrystalEnterprise.UserGroup
CrystalEnterprise.Webi
CrystalEnterprise.Word -
How to Read and Generate XML file from java code.
hi guys,
how to read the xml file (Condition :we know only DTD or Shema only).
How to Generate the new xml file ?(using Shema )
And one more how directly Generate the xml from DB?
Pleas with code or any URLUsing XMLbeans you can generate Java objects from an XSD schema (perhaps DTDs aswell)
Then you can create an instance of the Document object and ask it to write itself.
This will create an XML document complient to the schema.
XMLBeans generates a "type" safe DOM where you can only ever have a structure compilent to you schema.
matfud -
How to Generate XML File from Java Code.
I want to generate the xml file from the java code.
Could you plz suggest any webSite address with example?Here is the code
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class CreateXML {
private DocumentBuilderFactory factory = null;
private DocumentBuilder builder = null;
private Document document = null;
public CreateXML() {
try {
factory = DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
document = builder.newDocument();
} catch (FactoryConfigurationError e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
/** Creates the document for xml. */
public Document createDocument(){
try{
Element root = document.createElement("Root");
Element child = document.createElement("child");
root.appendChild(child);
document.appendChild(root);
}catch(RuntimeException e){
e.printStackTrace();
return document;
/** Saves the document as xml. */
public void saveDocument(Document document){
try{
TransformerFactory transFactory = TransformerFactory.newInstance();
Transformer transformer = transFactory.newTransformer();
DOMSource source = new DOMSource(document);
StreamResult stream = new StreamResult(new File("sample.xml"));
transformer.transform(source, stream);
System.out.println("XML Created !!");
}catch(TransformerConfigurationException e){
e.printStackTrace();
} catch (TransformerException e) {
e.printStackTrace();
public static void main(String args[]){
CreateXML createXML = new CreateXML();
Document document = createXML.createDocument();
createXML.saveDocument(document);
} -
Generating CSV file using java/ stored proc
Hi Folks,
I am using Oracle 11g DB
My requirement is that I have to generate a CSV file which has customer details. Each value that is comma separated comes from different set of SQL queries. I want to write a stored procedure along with java code to acieve this. How do I go about it? Should I return multiple cursors from my stored proc and iterate from the java side to create the CSV file? Any other suggestions?
Thanks
Vishal>
I am using Oracle 11g DB
My requirement is that I have to generate a CSV file which has customer details. Each value that is comma separated comes from different set of SQL queries. I want to write a stored procedure along with java code to acieve this. How do I go about it? Should I return multiple cursors from my stored proc and iterate from the java side to create the CSV file? Any other suggestions?
>
Other suggestions? Yes - don't reinvent the wheel - it has already been created.
1. Tom already wrote such a proc and published it many years ago. See this AskTom thread
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:235814350980
2. See BluShadow's link from the '5. How do I read or write an Excel file?' question in the FAQ at the top of the sql and pl/sql forum
SQL and PL/SQL FAQ
3. Use a sql developer query like 'select /*csv*/ * from emp
4. Search the sql and pl/sql forum for csv and use of the many threads that already answer this. -
How to embed a signature in the PDF file with Java?
Hello All!
There is no problem to sign a PDF with Java for me. But how to embed this signature in the PDF. I really don't know. I've found the PdfSignature class in the iText lib. But it is poor.
I've read on the another forum: "If you want to do server-based signatures, there is only one option - SecurSign http://www.appligent.com)."How to sign a PDF using iText
Maybe you are looking for
-
Pages don't reflect changes in their master page
I'm using InDesign CS5.5 (v. 7.5.3) with Mac OSX 10.8.4. I found one old question about this problem in another forum (with no submitted answer): Assume you have a simple document with one master which simply features a text frame. Well, now if you a
-
Hello Gurus, I am having an issue with query output.Please find below the details of it Unsold claims: Total---> 200 Dispatch: Total--->118,086 Unsold claims/dispatch--->0.001694 This should be the output but its coming --.0033120 because itu2019s di
-
HOST function does not redirect de output (result)
Hi, I am trying to use HOST to run the Findstr (or find) command, it executes the command but if I use '>' to send the result to a File it doesn´t create the file. Instead if I use 'Dir' command or if I run 'findstr' directly from the DOS prompt, it
-
Getting pdf's with pics on my touch
Hi there, I have downloaded to my PC a magazine with pictures in it. I want to be able to move it to my I-touch so i can read it as and when. I have e used Discover with limited results. Some PDF's with images have worked.... this was an instruction
-
Hi I have faced a problem in the CRM Order when it is saved and transfered to SAP R/3 it showing one error in SMQ1 as StatusSYFAIL messageScreen does not exist. I just to know the <b>detailed procedure for debugging</b> so that i will check both in