Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Count pages of PDF document (Except pdfs 1.3 ver)
Author:
krishna
E-mail:
Click to e-mail author
Submitted:
8/16/2006
Version:
VB6
Compatibility:
VB6
Category:
Miscellaneous
Views:
23259
Counting the exact number of pages in any PDF document.
Declarations:
IF you have ability then for PDF 1.3 version also ' Open file pdf in binarymode ' Read last 50 lines of that file ' In between somewhere u will find a line ' "/count xx" pages the xx is # of pages
Code:
'MADE ON 14TH AUG 06----------------------------------------------------------------------- ' open the PDF in binary mode & count the pages ' search for "/N xx" ' or "/Count xx" Public Sub pagecount(sfilename As String) On Error GoTo a Dim nFileNum As Integer Dim s As String Dim c As Integer Dim pos, pos1 As Integer pos = 0 pos1 = 0 c = 0 ' Get an available file number from the system nFileNum = FreeFile 'OPEN the PDF file in Binary mode Open sfilename For Binary Lock Read Write As #nFileNum ' Get the data from the file Do Until EOF(nFileNum) Input #1, s c = c + 1 If c <= 10 Then pos = InStr(s, "/N") End If pos1 = InStr(s, "/count") If pos > 0 Or pos1 > 0 Then Close #nFileNum s = Trim(Mid(s, pos, 10)) s = Replace(s, "/N", "") s = Replace(s, "/count", "") s = Replace(s, " ", "") s = Replace(s, "/", "") For i = 65 To 125 s = Replace(s, Chr(i), "") Next pages = Val(Trim(s)) If pages < 0 Then pages = 1 End If Close #nFileNum Exit Sub End If 'imp only 1000 lines searches If c >= 1000 Then GoTo a End If Loop Close #nFileNum Exit Sub a: Close #nFileNum pages = 1 Exit Sub End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement