OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

(<?xml:namespace prefix=o ns="urn:schemas-microsoft-

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
visa_integro
General User
General User


Joined: 11 Jul 2006
Posts: 10

PostPosted: Tue Jul 18, 2006 2:02 am    Post subject: (<?xml:namespace prefix=o ns="urn:schemas-microsoft- Reply with quote

Dear all
I'm using openoffice to render the pdf from html... in my pdf oftenly i can see the following line which is not in my output.

(<?xml:namespace prefix=o ns="urn:schemas-microsoft-office:office:office"/>)

Where ever table is appeared this line also appear together with the table... Pls do support to avoid this line...

Here is my coding

public static ByteArrayInputStream generatePDF(String htmlcontent){
String content = htmlcontent;
try{
String unoUrl = "uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager";
XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null);
XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
System.out.println("success ammabhagavan1");

Object urlResolver = xLocalServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", xLocalContext);
XUnoUrlResolver xUnoUrlResolver = (XUnoUrlResolver)UnoRuntime.queryInterface(XUnoUrlResolver.class, urlResolver);
System.out.println("success ammabhagavan2");

Object initialObject = xUnoUrlResolver.resolve(unoUrl);
XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, initialObject);
System.out.println("success ammabhagavan3");

Object context = xPropertySet.getPropertyValue("DefaultContext");
XComponentContext xRemoteContext = (XComponentContext)UnoRuntime.queryInterface(XComponentContext.class, context);
System.out.println("success ammabhagavan4");

XMultiComponentFactory xRemoteServiceManager = xRemoteContext.getServiceManager();
System.out.println("success ammabhagavan5");

Object desktop = xRemoteServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", xRemoteContext);
XComponentLoader compLoader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, desktop);
System.out.println("success ammabhagavan6");

PropertyValue[] loadProps = new PropertyValue[3];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "Hidden";
loadProps[0].Value = new Boolean(true);
loadProps[1] = new PropertyValue();
loadProps[1].Name = "FilterName";
loadProps[1].Value = "HTML (StarWriter)";
loadProps[2] = new PropertyValue();
loadProps[2].Name = "InputStream";
loadProps[2].Value = new OOInputStream(content.getBytes()); //private class, see below
System.out.println("success ammabhagavan7");
XComponent oDoc = compLoader.loadComponentFromURL("private:stream", "_blank", 0, loadProps); //load html
// System.out.println()
PropertyValue[] filterProps = new PropertyValue[2];
filterProps[0] = new PropertyValue();
filterProps[0].Name = "CompressMode";
filterProps[0].Value = "1";
filterProps[1] = new PropertyValue();
filterProps[1].Name = "PageRange";
filterProps[1].Value = "1-";

PropertyValue apropertyvalue[] = new PropertyValue[3];
apropertyvalue[0] = new PropertyValue();
apropertyvalue[0].Name = "FilterName";
apropertyvalue[0].Value = "writer_pdf_Export";
apropertyvalue[1] = new PropertyValue();
apropertyvalue[1].Name = "Overwrite";
apropertyvalue[1].Value = new Boolean(true);
apropertyvalue[2] = new PropertyValue();
apropertyvalue[2].Name = "FilterData";
apropertyvalue[2].Value = filterProps;
System.out.println("success ammabhagavan8");
XStorable xStorable = (XStorable)UnoRuntime.queryInterface(com.sun.star.frame.XStorable.class, oDoc);
System.out.println("success ammabhagavan8A");
xStorable.storeToURL("file:///c:/visa" + ".pdf", apropertyvalue); //write to file
RandomAccessFile out = new RandomAccessFile("C:\\visa.pdf","r");
long datalength = out.length();
byte [] bytearray=new byte[(int)datalength];
out.read(bytearray);

bis=new ByteArrayInputStream(bytearray);
System.out.println("success ammabhagavan9");
XCloseable xCloseable = (XCloseable)UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class, oDoc);
System.out.println("success ammabhagavan");
xCloseable.close(true); //close document
return bis;
}
catch(Exception e){
e.printStackTrace();
return bis;

}
}


Pls do advise

Thanks

With Regs
Visa
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group