You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Rainer Klute <kl...@rainer-klute.de> on 2005/08/02 08:39:50 UTC

Re: Problem adding custom information to documents

Hi Sven,

can you see your special properties in other programs, e.g. the Windows
Explorer?

When writing a section with a dictionary, HPSF checks whether the
dictionary's codepage has been set. If it is not set, it sets it to
Unicode. This might cause problems if you have non-Unicode strings as
property values.

You should try the set the codepage explicitly like this:
mySection.setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2, new Integer(1252));

Please tell me whether this solves your problem! If it does, I'll add a
setCodepage() method to MutableSection.

Am Freitag, den 29.07.2005, 15:43 +0200 schrieb Sven Billen:
> Hi,
> 
> I'm trying to add some custom properties to a word document using HPSF.
> It seems to work fine, besides that the information is not displayed in
> the properties of the document when I open it using MS Word. Also the
> information will be removed from the document when saving it in Word.
> (I used a hex-editor to be sure, that everything is stored in the doc)
> 
> This is what I do in detail:
> 
> I create a new Section within the DocumentSummaryInformation and add a 
> dictionary and a tag "info".
> 
> (I used the WriteAuthorAndTitle example from the HowTo)
> 
> --- begin of code ---
> 
> MutablePropertySet mps = new MutablePropertySet(si);
> MutableSection s = null;
> Map hm = new HashMap();
> 
> // If there is already a second section, then write to it.	
> // Works fine and the information stays within the document
> // even after saving it with MS Word
> if (mps.getSectionCount() > 1){
>    s = (MutableSection) mps.getSections().get(1);
>    hm = s.getDictionary();
> } // if not, create a new one
> else {
>    s = new MutableSection();
>    s.setDictionary(hm);
>    s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID);
>    mps.addSection(s);
> }
> 
> [...]
> 
> String info = "Hello World";
> 
> // size +2, becaus position 0 is the dictionary
> // and 1 is the codepage
> long posInfo = hm.size() + 2;
> 
> hm.put(new Long(posInfo), "info");
> 
> // creating a new property
> MutableProperty p = new MutableProperty();
> p.setType(Variant.VT_LPSTR);
> p.setValue(info);
> p.setID(posInfo);
> 
> s.setProperty(p);
> 
> // write to file etc.
> InputStream pss = mps.toInputStream();
> de.createDocument(name, pss);
> 
> --- end of code ---
> 
> I compared the output of POI to a document I created in MS Word using
> the ReadCustomPropertySets example and the only difference I found was
> the codepage set to 1200 by POI and 1252 by MS Word.
> 
> Any hints what I am doing wrong?
> 
> Thanks in advance,
> 
> Sven
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Best regards
Rainer Klute

                           Rainer Klute IT-Consulting GmbH
  Dipl.-Inform.
  Rainer Klute             E-Mail:  klute@rainer-klute.de
  Körner Grund 24          Telefon: +49 172 2324824
D-44143 Dortmund           Telefax: +49 231 5349423

Public key fingerprint: E4E4386515EE0BED5C162FBB5343461584B5A42E

European Parliament rejects software patent bill: http://news.bbc.co.uk/1/hi/technology/4655955.stm

Re: Problem adding custom information to documents

Posted by Rainer Klute <kl...@rainer-klute.de>.
This is quite mysterious, because the property type -2147483648 (hex
0x80000000) is not one of the standard types. Well, I cannot exclude the
possibility of an error in HPSF, so could you please create a new bug in
Bugzilla <http://issues.apache.org/bugzilla/> and attach your Word file
to it? Thanks!

Am Dienstag, den 09.08.2005, 13:48 +0200 schrieb Sven Billen:
> Rainer Klute schrieb:
> > Am Mittwoch, den 03.08.2005, 10:12 +0200 schrieb Sven Billen:
> > 
> >> No, it didn't work. I guess something is missing. I compared two 
> >> documents with the same properties. The first one created with MS 
> >> Word, the second with POI. The section created with MS Word 
> >> contains four properties, the other one just three. The fourth 
> >> property is displayed as
> >> 
> >> Property ID: -2147483648, type: 19, value: [B@b6ece5
> > 
> > That's not a valid property ID or at least not a usual one. How did 
> > you create that property?
> > 
> 
> I opened MS Word 2000, created a new document, saved it to disk and then
> used the Windows Explorer to add the property (File -> Properties ->
> Custom. Name of the property is "info" and value is "Hello World".
> ReadCustomPropertySet displays
> 
> Section 1:
>        Format ID: 00000000 D5 CD D5 05 2E 9C 10 1B 93 97 08 00 2B 2C F9
> AE ............+,..
> 
>        No. of properties: 4
>        Property ID: 0, type: 0, value: {2=info}
>        Property ID: 1, type: 2, value: 65001
>        Property ID: -2147483648, type: 19, value: [B@b6ece5
>        Property ID: 2, type: 30, value: Hello World
> 
> 
> When I create the property with HPFS I get
> 
>     Section 1:
>        Format ID: 00000000 D5 CD D5 02 2E 9C 10 1B 93 97 08 00 2B 2C F9 
> AE ............+,..
> 
>        No. of properties: 3
>        Property ID: 0, type: 0, value: {2=info}
>        Property ID: 1, type: 2, value: 1252
>        Property ID: 2, type: 30, value: Hello Welt

Best regards
Rainer Klute

                           Rainer Klute IT-Consulting GmbH
  Dipl.-Inform.
  Rainer Klute             E-Mail:  klute@rainer-klute.de
  Körner Grund 24          Telefon: +49 172 2324824
D-44143 Dortmund           Telefax: +49 231 5349423

Public key fingerprint: E4E4386515EE0BED5C162FBB5343461584B5A42E

European Parliament rejects software patent bill: http://news.bbc.co.uk/1/hi/technology/4655955.stm

Re: Problem adding custom information to documents

Posted by Sven Billen <sb...@mediasec.de>.
Rainer Klute schrieb:
> Am Mittwoch, den 03.08.2005, 10:12 +0200 schrieb Sven Billen:
> 
>> No, it didn't work. I guess something is missing. I compared two 
>> documents with the same properties. The first one created with MS 
>> Word, the second with POI. The section created with MS Word 
>> contains four properties, the other one just three. The fourth 
>> property is displayed as
>> 
>> Property ID: -2147483648, type: 19, value: [B@b6ece5
> 
> That's not a valid property ID or at least not a usual one. How did 
> you create that property?
> 

I opened MS Word 2000, created a new document, saved it to disk and then
used the Windows Explorer to add the property (File -> Properties ->
Custom. Name of the property is "info" and value is "Hello World".
ReadCustomPropertySet displays

Section 1:
       Format ID: 00000000 D5 CD D5 05 2E 9C 10 1B 93 97 08 00 2B 2C F9
AE ............+,..

       No. of properties: 4
       Property ID: 0, type: 0, value: {2=info}
       Property ID: 1, type: 2, value: 65001
       Property ID: -2147483648, type: 19, value: [B@b6ece5
       Property ID: 2, type: 30, value: Hello World


When I create the property with HPFS I get

    Section 1:
       Format ID: 00000000 D5 CD D5 02 2E 9C 10 1B 93 97 08 00 2B 2C F9 
AE ............+,..

       No. of properties: 3
       Property ID: 0, type: 0, value: {2=info}
       Property ID: 1, type: 2, value: 1252
       Property ID: 2, type: 30, value: Hello Welt


Regards,

Sven


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Problem adding custom information to documents

Posted by Rainer Klute <kl...@rainer-klute.de>.
Am Mittwoch, den 03.08.2005, 10:12 +0200 schrieb Sven Billen:
> No, it didn't work. I guess something is missing. I compared two
> documents with the same properties. The first one created with MS
> Word,
> the second with POI. The section created with MS Word contains four
> properties, the other one just three. The fourth property is displayed
> as
> 
> Property ID: -2147483648, type: 19, value: [B@b6ece5
> 
> in the ReadCustomPropertySets example. The version of POI I'm using is
> 3.0 alpha1 20050704.

That's not a valid property ID or at least not a usual one. How did you
create that property?

Best regards
Rainer Klute

                           Rainer Klute IT-Consulting GmbH
  Dipl.-Inform.
  Rainer Klute             E-Mail:  klute@rainer-klute.de
  Körner Grund 24          Telefon: +49 172 2324824
D-44143 Dortmund           Telefax: +49 231 5349423

Public key fingerprint: E4E4386515EE0BED5C162FBB5343461584B5A42E

European Parliament rejects software patent bill: http://news.bbc.co.uk/1/hi/technology/4655955.stm

Re: Problem adding custom information to documents

Posted by Sven Billen <sb...@mediasec.de>.
Hi Rainer,

Rainer Klute schrieb:
> Hi Sven,
> 
> can you see your special properties in other programs, e.g. the
> Windows Explorer?

No, I can only see them in the POIBrowser or a Hexeditor. Word,
OpenOffice or Windows Explorer don't display anything.

> 
> When writing a section with a dictionary, HPSF checks whether the 
> dictionary's codepage has been set. If it is not set, it sets it to 
> Unicode. This might cause problems if you have non-Unicode strings as
>  property values.


> 
> You should try the set the codepage explicitly like this: 
> mySection.setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2, new
> Integer(1252));
> 
> Please tell me whether this solves your problem! If it does, I'll add
> a setCodepage() method to MutableSection.
> 

No, it didn't work. I guess something is missing. I compared two
documents with the same properties. The first one created with MS Word,
the second with POI. The section created with MS Word contains four
properties, the other one just three. The fourth property is displayed as

Property ID: -2147483648, type: 19, value: [B@b6ece5

in the ReadCustomPropertySets example. The version of POI I'm using is
3.0 alpha1 20050704.

HTH

Sven


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


request.getinputstream() to POI/HSSF

Posted by vinod kaky <ka...@yahoo.com>.
I am new to POI, and I am trying to upload a excel
from excel, my requirement is, to use the uploaded
stream directly with POI/HSSF, can anyone suggest me
how that is done, or any suggestions in this regard
will be quite helpfull.

thanks,
Vinod

--- Rainer Klute <kl...@rainer-klute.de> wrote:

> Hi Sven,
> 
> can you see your special properties in other
> programs, e.g. the Windows
> Explorer?
> 
> When writing a section with a dictionary, HPSF
> checks whether the
> dictionary's codepage has been set. If it is not
> set, it sets it to
> Unicode. This might cause problems if you have
> non-Unicode strings as
> property values.
> 
> You should try the set the codepage explicitly like
> this:
> mySection.setProperty(PropertyIDMap.PID_CODEPAGE,
> Variant.VT_I2, new Integer(1252));
> 
> Please tell me whether this solves your problem! If
> it does, I'll add a
> setCodepage() method to MutableSection.
> 
> Am Freitag, den 29.07.2005, 15:43 +0200 schrieb Sven
> Billen:
> > Hi,
> > 
> > I'm trying to add some custom properties to a word
> document using HPSF.
> > It seems to work fine, besides that the
> information is not displayed in
> > the properties of the document when I open it
> using MS Word. Also the
> > information will be removed from the document when
> saving it in Word.
> > (I used a hex-editor to be sure, that everything
> is stored in the doc)
> > 
> > This is what I do in detail:
> > 
> > I create a new Section within the
> DocumentSummaryInformation and add a 
> > dictionary and a tag "info".
> > 
> > (I used the WriteAuthorAndTitle example from the
> HowTo)
> > 
> > --- begin of code ---
> > 
> > MutablePropertySet mps = new
> MutablePropertySet(si);
> > MutableSection s = null;
> > Map hm = new HashMap();
> > 
> > // If there is already a second section, then
> write to it.	
> > // Works fine and the information stays within the
> document
> > // even after saving it with MS Word
> > if (mps.getSectionCount() > 1){
> >    s = (MutableSection) mps.getSections().get(1);
> >    hm = s.getDictionary();
> > } // if not, create a new one
> > else {
> >    s = new MutableSection();
> >    s.setDictionary(hm);
> >   
>
s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID);
> >    mps.addSection(s);
> > }
> > 
> > [...]
> > 
> > String info = "Hello World";
> > 
> > // size +2, becaus position 0 is the dictionary
> > // and 1 is the codepage
> > long posInfo = hm.size() + 2;
> > 
> > hm.put(new Long(posInfo), "info");
> > 
> > // creating a new property
> > MutableProperty p = new MutableProperty();
> > p.setType(Variant.VT_LPSTR);
> > p.setValue(info);
> > p.setID(posInfo);
> > 
> > s.setProperty(p);
> > 
> > // write to file etc.
> > InputStream pss = mps.toInputStream();
> > de.createDocument(name, pss);
> > 
> > --- end of code ---
> > 
> > I compared the output of POI to a document I
> created in MS Word using
> > the ReadCustomPropertySets example and the only
> difference I found was
> > the codepage set to 1200 by POI and 1252 by MS
> Word.
> > 
> > Any hints what I am doing wrong?
> > 
> > Thanks in advance,
> > 
> > Sven
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> > Mailing List:    
> http://jakarta.apache.org/site/mail2.html#poi
> > The Apache Jakarta Poi Project: 
> http://jakarta.apache.org/poi/
> 
> 
> Best regards
> Rainer Klute
> 
>                            Rainer Klute
> IT-Consulting GmbH
>   Dipl.-Inform.
>   Rainer Klute             E-Mail: 
> klute@rainer-klute.de
>   Körner Grund 24          Telefon: +49 172 2324824
> D-44143 Dortmund           Telefax: +49 231 5349423
> 
> Public key fingerprint:
> E4E4386515EE0BED5C162FBB5343461584B5A42E
> 
> European Parliament rejects software patent bill:
> http://news.bbc.co.uk/1/hi/technology/4655955.stm
> 



		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/