Getting the page count of a PDF document
am 11.10.2007 11:24:34 von Tim
Hi,
I try to get the page count of a PDF document. I know how to do this in VB
but not in ASP. I have tried several options but none of them work properly.
I have search the internet but nothing that will help me.
Does anyone can help me with a sample?
Regards
Tim
Re: Getting the page count of a PDF document
am 11.10.2007 22:24:02 von McKirahan
"tim" wrote in message
news:470dec40$0$228$e4fe514c@news.xs4all.nl...
> Hi,
>
> I try to get the page count of a PDF document. I know how to do this in VB
> but not in ASP. I have tried several options but none of them work
properly.
>
> I have search the internet but nothing that will help me.
>
> Does anyone can help me with a sample?
Google "page count of a PDF document VBScript" found:
Count number of pages in PDF file
http://www.tek-tips.com/viewthread.cfm?qid=1405799&page=5
Re: Getting the page count of a PDF document
am 11.10.2007 23:11:03 von McKirahan
"McKirahan" wrote in message
news:F_-dnSUfz-3-GJPanZ2dnUVZ_h-vnZ2d@comcast.com...
> "tim" wrote in message
> news:470dec40$0$228$e4fe514c@news.xs4all.nl...
> > Hi,
> >
> > I try to get the page count of a PDF document. I know how to do this in
VB
> > but not in ASP. I have tried several options but none of them work
> properly.
> >
> > I have search the internet but nothing that will help me.
> >
> > Does anyone can help me with a sample?
>
> Google "page count of a PDF document VBScript" found:
>
> Count number of pages in PDF file
> http://www.tek-tips.com/viewthread.cfm?qid=1405799&page=5
Will this help?
Option Explicit
'****
'* Adapted from: "Read Binary Data in Scripting"
'* http://www.ericphelps.com/q193998/index.htm
'****
'*
Const cPDF = "C:\your_path\your_file.pdf"
'*
Dim strTXT
strTXT = ByteArray2Text(ReadByteArray(cPDF))
Dim strTMP
strTMP = Mid(strTXT,InStr(strTXT,"/Count ")+7,5)
Dim intFOR
For intFOR = 1 To Len(strPAG)
If Not IsNumeric(Mid(strTMP,intFOR,1)) Then Exit For
Next
Dim intPAG
intPAG = CInt(Left(strPAG,intFOR-1))
'*
WScript.Echo cPDF & " = " & intPAG & " pages."
Function ReadByteArray(strFileName)
Const adTypeBinary = 1
Dim bin
Set bin = CreateObject("ADODB.Stream")
bin.Type = adTypeBinary
bin.Open
bin.LoadFromFile strFileName
ReadByteArray = bin.Read
End Function
Function ByteArray2Text(varByteArray)
Const adTypeText = 2
Const adTypeBinary = 1
Dim byt
Set byt = CreateObject("ADODB.Stream")
byt.Type = adTypeBinary
byt.Open
byt.Write varByteArray
byt.Position = 0
byt.Type = adTypeText
byt.CharSet = "us-ascii"
ByteArray2Text = byt.ReadText
byt.Close
Set byt = Nothing
End Function
Re: Getting the page count of a PDF document
am 17.10.2007 08:36:20 von Tim
This mite work but a was expecting something the same way a you can do in
VB with the Adobe objects. I will look in to this. Thanks
"McKirahan" schreef in bericht
news:F_-dnSUfz-3-GJPanZ2dnUVZ_h-vnZ2d@comcast.com...
> "tim" wrote in message
> news:470dec40$0$228$e4fe514c@news.xs4all.nl...
>> Hi,
>>
>> I try to get the page count of a PDF document. I know how to do this in
>> VB
>> but not in ASP. I have tried several options but none of them work
> properly.
>>
>> I have search the internet but nothing that will help me.
>>
>> Does anyone can help me with a sample?
>
> Google "page count of a PDF document VBScript" found:
>
> Count number of pages in PDF file
> http://www.tek-tips.com/viewthread.cfm?qid=1405799&page=5
>
>