' Page 5
CallBox NewPage(hBox)
CallBox DrawPageCounter(hBox, 0, 100, PW, taCenter, "[第", pgPageNumber, " 页 共 ", pgPageCount, "页]")
CallBox TextOut(hBox, 100, 300, "Page counters are useful to manage chapter-based page numbering or to produce a series of independant documents.")
CallBox EndDoc(hBox)
SetNum hBox, Box_WantPageCount, 0 ' Don"t keep this option for future runs
End Sub
Private Declare Function ShellExecute Lib _
"shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Public Function FileExists(aFileName As String) As Boolean
FileExists = False
On Error Resume Next
FileExists = ((GetAttr(aFileName) And vbDirectory) = 0)
End Function
Private Sub WriteFormTitle(aTitle As String, aY As Integer)
SetNum hBox, Box_FontSize, 20
SetNum hBox, Box_FontBold, 1
SetNum hBox, Box_FontColor, vbBlue
CallBox TextOut(hBox, 200, aY, aTitle)
SetNum hBox, Box_FontSize, 10
SetNum hBox, Box_FontBold, 0
SetNum hBox, Box_FontColor, vbBlack
End Sub
'10: 页面计数
Private Sub btExample10_Click()
Dim PW As Long
PW = GetNum(hBox, Box_PageWidth)
SetStr hBox, Box_Title, "Page count"
SetNum hBox, Box_WantPageCount, 1 ' Activates pre-calculation
CallBox BeginDoc(hBox)
' Page 1
SetStr hBox, Box_FontName, "宋体" '定义字体
CallBox DrawPageCounter(hBox, 0, 100, PW, taCenter, "[第", pgPageNumber, " 页 共 ", pgPageCount, "页]")
SetNum hBox, Box_FontSize, 12
SetNum hBox, Box_FontBold, 1
SetStr hBox, Box_FontName, "宋体" '定义字体
CallBox TextOut(hBox, 100, 200, "页面计数")
SetNum hBox, Box_FontSize, 10
SetNum hBox, Box_FontBold, 0
CallBox TextOut(hBox, 100, 300, "This example shows how to use page counters to manage sophisticated page numbering.")
CallBox TextOut(hBox, 100, 350, "If you want to show the number of pages, assign WantPageCount to 1 before start.")
CallBox TextOut(hBox, 100, 400, "This will activate a preliminary stage destinated to compute the number of pages.")
CallBox TextOut(hBox, 100, 450, "Then, you can use the DrawPageCounter method in several ways.")
CallBox TextOut(hBox, 100, 500, "At the top of this page you can read the page number and the total number of pages of the document.")
' Page 2
CallBox NewPage(hBox)
CallBox DrawPageCounter(hBox, 0, 100, PW, taCenter, "[第", pgPageNumber, " 页 共 ", pgPageCount, "页]")
CallBox TextOut(hBox, 100, 250, "Most often, DrawPageCounter is called in the OnNewPage event. This is not so here.")
' Page 3
CallBox NewSection(hBox, poPortrait, 1) ' Starts new chapter
CallBox DrawPageCounter(hBox, 0, 100, PW, taCenter, "[", _
pgPageNumber, " of ", pgPageCount, "]")
CallBox TextOut(hBox, 100, 200, "Here, we start a new chapter.")
CallBox DrawPageCounter(hBox, 100, 300, 0, taLeftJustify, "There are ", _
pgChapterCount, "", pgNone, " chapters in the document.")
CallBox DrawPageCounter(hBox, 100, 350, 0, taLeftJustify, "There are ", _
pgPageCountInChapter, "", pgNone, " pages in current chapter.")
CallBox DrawPageCounter(hBox, 100, 400, 0, taLeftJustify, "This is page ", _
pgPageNumber, " in the document, or page ", pgPageNumberInChapter, _
" in current chapter.")
CallBox DrawPageCounter(hBox, 100, 500, 0, taLeftJustify, _
"If you use a chapter-based page numbering system, this page can be identified as ", _
pgChapterNumber, "-", pgPageNumberInChapter, ".")
CallBox TextOut(hBox, 100, 600, _
"Depending on formatting options, you can number this page in various ways:")
CallBox TextOut(hBox, 200, 650, "Using fixed-length numbers:")
CallBox SetPageNumberFormat(hBox, pf001, pf01)
CallBox DrawPageCounter(hBox, 900, 650, 0, taLeftJustify, "", _
pgChapterNumber, " - ", pgPageNumberInChapter, "")
CallBox TextOut(hBox, 200, 700, "Numbering chapters with letters:")
CallBox SetPageNumberFormat(hBox, pf1, pfUpcaseLetters)
CallBox DrawPageCounter(hBox, 900, 700, 0, taLeftJustify, "", _
pgChapterNumber, ".", pgPageNumberInChapter, "")
CallBox TextOut(hBox, 200, 750, "Numbering chapters with Roman numerals:")
CallBox SetPageNumberFormat(hBox, pf1, pfUpcaseRoman)
CallBox DrawPageCounter(hBox, 900, 750, 0, taLeftJustify, "", _
pgChapterNumber, "-", pgPageNumberInChapter, "")
CallBox SetPageNumberFormat(hBox, pf1, pf1)
枕善居的示例是可用的,只是需要将乱码处理一下,论坛不支持上传附件,不好传文件,只能贴代码了
VERSION 5.00
Begin VB.Form DemoForm
BorderStyle = 1 'Fixed Single
Caption = "PDF盒子---一个全功能操作PDF文件DLL(特别版)"
ClientHeight = 3615
ClientLeft = 5040
ClientTop = 4350
ClientWidth = 8760
Icon = "Main.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 3615
ScaleWidth = 8760
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton btExample8
Caption = "8: 样式表"
Height = 375
Left = 6840
TabIndex = 12
Top = 1095
Width = 1700
End
Begin VB.CommandButton btExample2
Caption = "2: 写入文本"
Height = 375
Left = 4800
TabIndex = 11
Top = 675
Width = 1700
End
Begin VB.CommandButton btExample10
Caption = "10: 页面计数"
Height = 375
Left = 6840
TabIndex = 10
Top = 1965
Width = 1695
End
Begin VB.CommandButton btExample9
Caption = "9:交互表单"
Height = 375
Left = 6840
TabIndex = 9
Top = 1530
Width = 1695
End
Begin VB.CommandButton btExample7
Caption = "7: 文件加密"
Height = 375
Left = 6840
TabIndex = 8
Top = 675
Width = 1700
End
Begin VB.CommandButton btExample6
Caption = "6: 完整演示"
Height = 390
Left = 6840
TabIndex = 7
Top = 225
Width = 1695
End
Begin VB.CommandButton btExample5
Caption = "5: 绘制表格"
Height = 375
Left = 4800
TabIndex = 6
Top = 1965
Width = 1695
End
Begin VB.CommandButton btExample4
Caption = "4: 自定义图形"
Height = 375
Left = 4800
TabIndex = 5
Top = 1530
Width = 1695
End
Begin VB.CommandButton btExample3
Caption = "3: 插入图片"
Height = 375
Left = 4800
TabIndex = 4
Top = 1095
Width = 1695
End
Begin VB.CommandButton btExample1
Caption = "1: 最简单示例"
Height = 375
Left = 4800
TabIndex = 3
Top = 240
Width = 1700
End
Begin VB.Image Image1
Height = 465
Left = 4545
Picture = "Main.frx":08CA
Top = 2655
Width = 1320
End
Begin VB.Label Label2
Caption = "欢迎光临枕善居VB及.NET源码博客,支持本站获取更好的PDF文件操作控件(包括读取、显示、打印PDF文件)."
Height = 735
Left = 120
TabIndex = 14
Top = 1800
Width = 4095
End
Begin VB.Label Label1
Caption = "该示例是使用PDF盒子Dll生成PDF格式的文件."
Height = 375
Left = 120
TabIndex = 13
Top = 1320
Width = 4335
End
Begin VB.Label laEmailSynactis
Caption = "http://www.mndsoft.com"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Left = 120
MousePointer = 10 'Up Arrow
TabIndex = 2
Top = 2520
Width = 2160
End
Begin VB.Image imCompanyLogo
Appearance = 0 'Flat
Height = 600
Left = 6720
MousePointer = 10 'Up Arrow
Picture = "Main.frx":12D0
Top = 2640
Width = 1800
End
Begin VB.Label Label4
Alignment = 2 'Center
Caption = "PDF文件读写操作DLL示例"
BeginProperty Font
Name = "Arial"
Size = 14.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00800000&
Height = 615
Left = 1920
TabIndex = 1
Top = 240
Width = 2055
End
Begin VB.Label laSynactis
Caption = "http://www.synactis.com"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Left = 6720
MousePointer = 10 'Up Arrow
TabIndex = 0
Top = 3240
Width = 1935
End
Begin VB.Image imProductLogo
BorderStyle = 1 'Fixed Single
Height = 1005
Left = 120
Picture = "Main.frx":1CB2
Stretch = -1 'True
Top = 120
Width = 1455
End
End
Attribute VB_Name = "DemoForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'****************************************************************************
'人人为我,我为人人
'枕善居汉化收藏整理
'发布日期:2008/08/20
'描 述:PDF盒子---一个全功能操作PDF文件DLL(特别版)
'网 站:http://www.Mndsoft.com/ (VB6源码博客)
'网 站:http://www.VbDnet.com/ (VB.NET源码博客,主要基于.NET2005)
'e-mail :Mndsoft@163.com
'e-mail :Mndsoft@126.com
'OICQ :88382850
' 如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************
Dim hBox As Long
Private Declare Function GetPrivateProfileSectionNames Lib _
"kernel32" Alias "GetPrivateProfileSectionNamesA" _
(ByVal lpReturnedString As String, _
ByVal nSize As Long, ByVal _
lpFileName As String) As Long
Private Declare Function GetPrivateProfileString Lib _
"kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long, ByVal _
lpFileName As String) As Long