Java example code to get total page count and page width/height of pdf file

979 views
Skip to first unread message

climberjack

unread,
May 9, 2008, 7:22:34 PM5/9/08
to Adobe LiveCycle Developers
We're implementing some functionality with Adobe LifeCycle and we need
to get the total number of pages for a given pdf file. We also need to
get the width and height for a given page. I can't figure out ow to do
this.

I found some PHP code that 'kind of' does this, but I need to use Java
(pojo).

The best I could come up with was some sample code at
http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=sdkHelp&file=pdfUtilityIntroduction.107.1.html

Any help would be appreciated.

LiveCycle Lifeline

unread,
May 10, 2008, 11:40:05 AM5/10/08
to Adobe LiveCycle Developers
Are you using LiveCycle server, if yes there is a easy way to do this.
Let me know if you need it

On May 9, 4:22 pm, climberjack <climberj...@gmail.com> wrote:
> We're implementing some functionality with Adobe LifeCycle and we need
> to get the total number of pages for a given pdf file. We also need to
> get the width and height for a given page. I can't figure out ow to do
> this.
>
> I found some PHP code that 'kind of' does this, but I need to use Java
> (pojo).
>
> The best I could come up with was some sample code athttp://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/wwh...

fred.pantalone

unread,
May 11, 2008, 1:27:46 PM5/11/08
to Adobe LiveCycle Developers
If you need to do this in JavaScript then look up the absPageCount()
or pageCount() function in the Adobe Designer help.

Fred





On May 10, 11:40 am, LiveCycle Lifeline <mergeandf...@gmail.com>
wrote:

climberjack

unread,
May 12, 2008, 7:50:32 PM5/12/08
to Adobe LiveCycle Developers
We're actually running JBoss/Tomcat (as a container) and using the
Adobe LifeCycle jar files. In general, we're creating a web service
that will provide the required service of converting files to pdf.

I would really appreciate any information on how to get the page count
for a pdf file and the page with/height of a given pdf file.

Thanks.

- Jack -

fred.pantalone

unread,
May 13, 2008, 10:02:47 AM5/13/08
to Adobe LiveCycle Developers
It sounds like you want to do this outside of the form so the
JavaScript functions that suggested will not help you. For this type
of PDF file access I usually use a third party PDF library like Big
Faceless or ceTe's DynamicPDF Generator/Merger. Both are pure Java
libraries that give you very straightforward access to your documents.
If you don't want to purchase one of these then check this out:

http://www.pdfbox.org/
http://www.pdfbox.org/javadoc/index.html

You should have no problem implementing a solution using PDFBox.

Fred

Duane Nickull

unread,
May 13, 2008, 2:19:25 PM5/13/08
to live...@googlegroups.com
Page Margins:

http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/ddxRefMain.163.79.html

    See the Document Description XML Reference for detailed information about this schema.
    The data returned by the DocumentInformation element contains the following information about the document:
    •
        
    Metadata from the PDF document properties: title, author, subject, keywords, date created, date modified, creator application, PDF producer
    •
        
    PDF version
    •
        
    Number of pages in the document
   •
        
    Page sizes, rotation angles, and page labels for all pages in the document

        
                
        Related Topics             
                
        
        Popup         
        
    Popup     
        
                
        See Also             
                
        
        Popup         

        









On 13/05/08 7:02 AM, "fred.pantalone" <fred.pa...@gmail.com> wrote:

On May 12, 7:50 pm, climberjack <climberj...@gmail.com> wrote:
> We're actually running JBoss/Tomcat (as a container) and using the
> Adobe LifeCycle jar files. In general, we're creating a web service
> that will provide the required service of converting files to pdf.
>
> I would really appreciate any information on how to get the page count
> for a pdf file and the page with/height of a given pdf file.
>
> Thanks.
>
> - Jack -
>
> On May 10, 8:40 am, LiveCycle Lifeline <mergeandf...@gmail.com> wrote:
>
> > Are you using LiveCycle server, if yes there is a easy way to do this.
> > Let me know if you need it
>
> > On May 9, 4:22 pm, climberjack <climberj...@gmail.com> wrote:
>
> > > We're implementing some functionality with Adobe LifeCycle and we need
> > > to get the total number of pages for a given pdf file. We also need to
> > > get the width and height for a given page. I can't figure out ow to do
> > > this.
>

--
**********************************************************************
"Speaking only for myself"
Senior Technical Evangelist - Adobe Systems, Inc.
Blog - http://technoracle.blogspot.com
Community Music - http://www.mix2r.com
My Band - http://www.myspace.com/22ndcentury
Adobe MAX 2008 - http://technoracle.blogspot.com/2007/08/adobe-max-2008.html
**********************************************************************

Prasad

unread,
May 13, 2008, 9:19:02 PM5/13/08
to Adobe LiveCycle Developers
Jack,
When you generate your PDF use Linearlized = true. This will force
formserver to write number of pages on the 3rd line of PDF. Then open
PDF in binary mode and read first line that has word Linearized. This
line will have /N <NUM Pages/.

I don't know about page size. Look up adobe PDF spec. One of the
headers may contain page size details.


Prasad
> > > Any help would be appreciated.- Hide quoted text -
>
> - Show quoted text -

Duane Nickull

unread,
May 13, 2008, 10:02:42 PM5/13/08
to live...@googlegroups.com
I think it is in the DDX file.

D

LiveCycle Lifeline

unread,
May 14, 2008, 12:50:20 AM5/14/08
to Adobe LiveCycle Developers
I have used DDX to get the number of pages
Reply all
Reply to author
Forward
0 new messages