You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Carlos Velázquez Luzardo <cg...@yahoo.com.mx> on 2005/06/27 19:42:53 UTC

HPSF: MS Word Page Count Problem

Hi,

I have a problem whit the property "page count" when I try to access a MS Word 
document. I have MS Office 2003.

I have a Word document whith 2 pages, and the result in the "page count" 
is "1" every time.

POI works fine with Office 2003? What's is the version supported?

Thanks for your help.
Carlos Velázquez

I attached the java code:

*******************************************************************

package com.ecm.office;

import java.io.*;
import org.apache.poi.hpsf.*;
import org.apache.poi.poifs.eventfilesystem.*;

/**
 * <p>Title: Librerías de Documentum</p>
 *
 * <p>Description: Librerías de Documentum</p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: Sictel</p>
 *
 * @author Carlos Velázquez Luzardo
 * @version 1.0
 */
public class Office {
    public Office() {
    }


    public static void main(String[] args) throws IOException {
        final String filename = "C:/Documents and Settings/Carlos 
Velázquez/Escritorio/Por Organizar/SCT - Plan de Trabajo (libro blanco).doc";
        POIFSReader r = new POIFSReader();
        r.registerListener(new MyPOIFSReaderListener
(), "\005SummaryInformation");
        r.read(new FileInputStream(filename));
    }
    
    static class MyPOIFSReaderListener implements POIFSReaderListener {
        public void processPOIFSReaderEvent(POIFSReaderEvent event) {
            SummaryInformation si = null;
            try {
                si = (SummaryInformation)
                     PropertySetFactory.create(event.getStream());
            } catch (Exception ex) {
                throw new RuntimeException
                        ("Property set stream \"" +
                         event.getPath() + event.getName() + "\": " + ex);
            }
            final String title = si.getTitle();
            final int pageCount = si.getPageCount();
            if (title != null)
                System.out.println("Title: \"" + title + "\"");
            else
                System.out.println("Document has no title.");
            if (pageCount != 0)
                System.out.println("Page Count: \"" + pageCount + "\"");
            else
                System.out.println("Document has no pages.");
        }
    }
}



---------------------------------------------------------------------
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: HPSF: MS Word Page Count Problem

Posted by ac...@apache.org.
Rainer Klute wrote:
> Am Montag, den 27.06.2005, 17:42 +0000 schrieb Carlos Vel?zquez Luzardo:
> 
>>I have a problem whit the property "page count" when I try to access a MS Word 
>>document. I have MS Office 2003.
>>
>>I have a Word document whith 2 pages, and the result in the "page count" 
>>is "1" every time.
> 
> 
> HPSF does nothing more than just retrieving a property's value, here the
> page count. *Why* this value is 1 and not 2 HPSF does not and cannot
> care about. Which value is displayed by the Windows explorer?
> 

Actually, I believe it says "estimated" in the GUI.  Also the number of 
pages is related to the printer selected among other things.  Docs are 
actually repaginated dynamically, IIRC.

> 
> 
>>POI works fine with Office 2003? What's is the version supported?
> 
> 
> POI does not support particular Office versions.
> 

97+

> 
> 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
> 
> Inhibit software patents: http://www.nosoftwarepatents.com/
> 
> 
> ---------------------------------------------------------------------
> 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/
> 


-- 
Andrew C. Oliver
SuperLink Software, Inc.

Java to Excel using POI
http://www.superlinksoftware.com/services/poi
Commercial support including features added/implemented, bugs fixed.

---------------------------------------------------------------------
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: HPSF: MS Word Page Count Problem

Posted by Rainer Klute <kl...@rainer-klute.de>.
Am Montag, den 27.06.2005, 17:42 +0000 schrieb Carlos Velázquez Luzardo:
> I have a problem whit the property "page count" when I try to access a MS Word 
> document. I have MS Office 2003.
> 
> I have a Word document whith 2 pages, and the result in the "page count" 
> is "1" every time.

HPSF does nothing more than just retrieving a property's value, here the
page count. *Why* this value is 1 and not 2 HPSF does not and cannot
care about. Which value is displayed by the Windows explorer?


> POI works fine with Office 2003? What's is the version supported?

POI does not support particular Office versions.


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

Inhibit software patents: http://www.nosoftwarepatents.com/


---------------------------------------------------------------------
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/