-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclsPDF.cls
3021 lines (2358 loc) · 91.6 KB
/
clsPDF.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsPDF"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_HelpID = 2005
Option Explicit
Private Const clsPDF = "1.3"
Private Const clsPDFVersion = "clsPDF 1.0"
Private wsPathConfig As String
Private wsPathAdobe As String
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function PostMessage Lib "user32" _
Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal szClass$, ByVal szTitle$) As Long
Private Const WM_CLOSE = &H10
Private Declare Function PDFReadFile Lib "Kernel32" Alias "ReadFile" _
(ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function PDFCreateFile Lib "Kernel32" Alias "CreateFileA" _
(ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, _
ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function PDFGetFileSize Lib "Kernel32" Alias "GetFileSize" _
(ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Private Declare Function PDFCloseHandle Lib "Kernel32" Alias "CloseHandle" _
(ByVal hObject As Long) As Long
Private Type oOutlines
sText As String
iLevel As Integer
yPos As Double
iPageNb As Integer
bPrev As Boolean
bNext As Boolean
bFirst As Boolean
bLast As Boolean
iFirst As Integer
iNext As Integer
iPrev As Integer
iLast As Integer
iParent As Integer
End Type
Private aOutlines() As oOutlines
Private iOutlines As Integer
Private aPage() As Variant
Private Type PDFRGB
in_r As Integer
in_g As Integer
in_b As Integer
End Type
Private Fso As Object
Private Strm As Object
Private sPDFName As String
Private Arr_Font() As Variant
Private in_offset As Integer
Private in_FontNum As Integer
Private in_PagesNum As Integer
Private in_Ech As Double
Private in_Canvas As Integer
Private iWidthStr As Double
Private in_xCurrent As Double
Private in_yCurrent As Double
Private ImgWidth As Double
Private ImgHeight As Double
Private xlink As Double
Private yLink As Double
Private strTLink As String
Private strTyLink As String
Private wRect As Long
Private str_TmpFont As String
Private PDFTextColor As String
Private PDFLineColor As String
Private PDFDrawColor As String
Private PDFstrTextColor As String
Private PDFstrLineColor As String
Private PDFstrDrawColor As String
Private PDFstrTempColor As String
Private PDFstrTempAlign As String
Private PDFstrTempBorder As String
Private pTempAngle As Double
Private PDFboTempFill As Boolean
Private bPageBreak As Boolean
Private PDFLnStyle As String
Private PDFLnWidth As Double
Private PDFDrawMode As String
Private PDFZoomMode
Private PDFLayoutMode
Private PDFViewerPref
Private bPDFViewerPref As Boolean
Private bPDFWatermark As Boolean
Private sPDFWatermark As String
Private PDFAngle As Double
Private bAngle As Double
Private PDFFontName As String
Private PDFFontSize As Integer
Private PDFFontNum As Integer
Private boPDFUnderline As Boolean
Private boPDFItalic As Boolean
Private boPDFBold As Boolean
Private boPDFConfirm As Boolean
Private boPDFView As Boolean
Private PDFboThumbs As Boolean
Private PDFboOutlines As Boolean
Private PDFboImage As Boolean
Private PDFlMargin As Integer ' Left Margin
Private PDFtMargin As Integer ' Top Margin
Private PDFrMargin As Integer ' Right Margin
Private PDFbMargin As Integer ' Bottom Margin
Private PDFcMargin As Integer ' Center Margin
Private PDFMargin As Integer
Private FFileName As String
Private FTitle As String
Private FPageNumber As Integer
Private FPageLink As Integer
Private FOrientation As String
Private FAuthor As String
Private FCreator As String
Private FKeywords As String
Private FSubject As String
Private FProducer As String
Private FFileCompress As Boolean
Private ParentNum, ContentNum, ResourceNum, FontNum, CatalogNum, _
FontNumber, CurrentPDFSetPageObject, NumberofImages, iOutlineRoot As Integer
Private PDFCanvasWidth()
Private PDFCanvasHeight()
Private PDFCanvasOrientation()
Private CurrentObjectNum As Integer
Private ObjectOffset As Long
Private ObjectOffsetList As Variant
Private PageNumberList As Variant
Private PageLinksList(1 To 1000, 1 To 1000) As Variant
Private LinksList As Variant
Private PageCanvasWidth As Variant
Private PageCanvasHeight As Variant
Private FontNumberList As Variant
Private Type aIMG
in_1 As Variant
in_2 As Variant
in_3 As Variant
in_4 As Variant
in_5 As Variant
in_6 As Variant
in_7 As Variant
in_8 As Variant
End Type
Private ArrIMG() As aIMG
Private boPageLinksList As Variant
Private NbPageLinksList As Variant
Private CRCounter As Long
Private ColorSpace As String
Private ColorCount As Byte
Private ImageStream As String
Private TempStream As String
Private pTempStream As String
Private sTempStream As String
Private cTempStream As String
Private dTempStream As String
Private StreamSize1, StreamSize2 As Integer
Private bScanAdobe As Boolean
Enum PDFStyleLgn
pPDF_SOLID = 0
pPDF_DASH = 1
pPDF_DASHDOT = 2
pPDF_DASHDOTDOT = 3
End Enum
Enum PDFFontStl
FONT_NORMAL = 0
FONT_ITALIC = 1
FONT_BOLD = 2
FONT_UNDERLINE = 3
End Enum
Enum PDFFontNme
FONT_ARIAL = 0
FONT_COURIER = 1
FONT_TIMES = 2
FONT_SYMBOL = 3
FONT_ZAPFDINGBATS = 4
End Enum
Enum PDFZoomMd
ZOOM_FULLPAGE = 0
ZOOM_FULLWIDTH = 1
ZOOM_REAL = 2
ZOOM_DEFAULT = 3
End Enum
Enum PDFLayoutMd
LAYOUT_SINGLE = 0
LAYOUT_CONTINOUS = 1
LAYOUT_TWO = 2
LAYOUT_DEFAULT = 3
End Enum
Enum PDFUnitStr
UNIT_PT = 0
UNIT_MM = 1
UNIT_CM = 2
End Enum
Enum PDFOrientationStr
ORIENT_PAYSAGE = 0
ORIENT_PORTRAIT = 1
End Enum
Enum PDFFormatPgStr
FORMAT_A4 = 0
FORMAT_A3 = 1
FORMAT_A5 = 2
FORMAT_LETTER = 3
FORMAT_LEGAL = 4
End Enum
Enum PDFDrawMd
DRAW_NORMAL = 0
DRAW_DRAW = 1
DRAW_DRAWBORDER = 2
End Enum
Enum PDFAlignValue
ALIGN_CENTER = 0
ALIGN_LEFT = 1
ALIGN_RIGHT = 2
ALIGN_FJUSTIFY = 3
End Enum
Enum PDFBorderValue
BORDER_NONE = 0
BORDER_ALL = 1
BORDER_TOP = 2
BORDER_BOTTOM = 3
BORDER_LEFT = 4
BORDER_RIGHT = 5
End Enum
Enum PDFViewerCst
VIEW_HIDETOOLBAR = 1
VIEW_HIDEMENUBAR = 2
VIEW_HIDEWINDOWUI = 3
VIEW_FITWINDOW = 4
VIEW_CENTERWINDOW = 5
VIEW_DISPLAYDOCTITLE = 6
End Enum
Property Let PDFPathConfiguration(sPathConfig As String)
wsPathConfig = sPathConfig
End Property
Property Let PDFSetViewerPreferences(pViewerPref As PDFViewerCst)
bPDFViewerPref = True
PDFViewerPref = pViewerPref
End Property
Property Let PDFWatermark(sWatermark As String)
bPDFWatermark = True
sPDFWatermark = sWatermark
End Property
Private Sub PDFRotationText(x As Double, y As Double, sText As String, pAngle As Integer)
PDFSetRotation = pAngle
PDFTextOut sText, x, y
PDFSetRotation = 0
End Sub
Private Sub PDFHeader()
Dim dH As Double
Dim dL As Double
If bPDFWatermark Then
PDFSetFont FONT_ARIAL, 50, FONT_BOLD
PDFSetTextColor = Array(255, 192, 203)
dH = (PDFGetPageHeight + PDFGetStringWidth(sPDFWatermark, "", 50) * Sin(45)) / 2.15
dL = (PDFGetPageWidth - PDFGetStringWidth(sPDFWatermark, "", 50) * Cos(45)) / 2.75
PDFRotationText dL, dH, sPDFWatermark, 45
End If
End Sub
Property Let PDFSetZoomMode(pZoomMode As PDFZoomMd)
Attribute PDFSetZoomMode.VB_HelpID = 2009
If pZoomMode = ZOOM_FULLPAGE Or pZoomMode = ZOOM_FULLWIDTH Or _
pZoomMode = ZOOM_REAL Or pZoomMode = ZOOM_DEFAULT Or _
(IsNumeric(pZoomMode) And (pZoomMode <> ZOOM_FULLPAGE Or _
pZoomMode <> ZOOM_FULLWIDTH Or _
pZoomMode <> ZOOM_REAL Or _
pZoomMode <> ZOOM_DEFAULT)) Then
If IsNumeric(pZoomMode) Then
PDFZoomMode = Int(pZoomMode)
Else
PDFZoomMode = pZoomMode
End If
Else
MsgBox "Incorrect Zoom Mode : " & pZoomMode & "." & _
vbNewLine & _
"Focus will be set to full-page zoom", vbCritical, "Zoom Mode - " & clsPDFVersion
PDFZoomMode = ZOOM_FULLPAGE
End If
End Property
Property Get PDFGetZoomMode() As Variant
Attribute PDFGetZoomMode.VB_HelpID = 2010
PDFGetZoomMode = PDFZoomMode
End Property
Property Let PDFUseThumbs(boThumbs As Boolean)
Attribute PDFUseThumbs.VB_HelpID = 2011
PDFboThumbs = boThumbs
End Property
Property Let PDFUseOutlines(boOutlines As Boolean)
Attribute PDFUseOutlines.VB_HelpID = 2012
PDFboOutlines = boOutlines
End Property
Property Let PDFSetLayoutMode(pLayoutMode As PDFLayoutMd)
Attribute PDFSetLayoutMode.VB_HelpID = 2013
If pLayoutMode = LAYOUT_SINGLE Or pLayoutMode = LAYOUT_CONTINOUS Or _
pLayoutMode = LAYOUT_TWO Or pLayoutMode = LAYOUT_DEFAULT Then
PDFLayoutMode = pLayoutMode
Else
MsgBox "Layout incorrect : " & pLayoutMode & "." & _
vbNewLine & _
"Layout will be set to simple single page.", vbCritical, "Layout Mode - " & clsPDFVersion
PDFLayoutMode = LAYOUT_SINGLE
End If
End Property
Property Get PDFGetLayoutMode() As Variant
Attribute PDFGetLayoutMode.VB_HelpID = 2014
PDFGetLayoutMode = PDFLayoutMode
End Property
Property Let PDFSetUnit(str_Unite As PDFUnitStr)
Attribute PDFSetUnit.VB_HelpID = 2015
Select Case str_Unite
Case UNIT_PT
in_Ech = 1
Case UNIT_MM
in_Ech = 72 / 25.4
Case UNIT_CM
in_Ech = 72 / 2.54
Case Else
MsgBox "Incorrect Unit of Measure : " & str_Unite & "." & _
vbNewLine & _
"Using centimeter ", vbCritical, "Error in measurement unit - " & clsPDFVersion
in_Ech = 72 / 2.54
End Select
End Property
Property Get PDFGetUnit() As String
Attribute PDFGetUnit.VB_HelpID = 2016
Select Case in_Ech
Case 1
PDFGetUnit = "pt"
Case 72 / 25.4
PDFGetUnit = "mm"
Case 72 / 2.54
PDFGetUnit = "cm"
End Select
End Property
Property Let PDFOrientation(str_Orientation As PDFOrientationStr)
Attribute PDFOrientation.VB_HelpID = 2017
Dim tmp_PDFCanvasWidth As Integer
Dim tmp_PDFCanvasHeight As Integer
ReDim Preserve PDFCanvasWidth(1 To in_Canvas)
ReDim Preserve PDFCanvasHeight(1 To in_Canvas)
ReDim Preserve PDFCanvasOrientation(1 To in_Canvas)
tmp_PDFCanvasWidth = PDFCanvasWidth(in_Canvas)
tmp_PDFCanvasHeight = PDFCanvasHeight(in_Canvas)
Select Case str_Orientation
Case ORIENT_PORTRAIT
PDFCanvasWidth(in_Canvas) = tmp_PDFCanvasWidth
PDFCanvasHeight(in_Canvas) = tmp_PDFCanvasHeight
PDFCanvasOrientation(in_Canvas) = "p"
Case ORIENT_PAYSAGE
PDFCanvasWidth(in_Canvas) = tmp_PDFCanvasHeight
PDFCanvasHeight(in_Canvas) = tmp_PDFCanvasWidth
PDFCanvasOrientation(in_Canvas) = "l"
Case Else
MsgBox "Orientation set incorrectly: " & str_Orientation & "." & _
vbNewLine & _
"Orientation set to portrait.", vbCritical, "Error in orientation - " & clsPDFVersion
PDFCanvasWidth(in_Canvas) = tmp_PDFCanvasWidth
PDFCanvasHeight(in_Canvas) = tmp_PDFCanvasHeight
PDFCanvasOrientation(in_Canvas) = "p"
End Select
ReDim Preserve PDFCanvasWidth(1 To in_Canvas)
ReDim Preserve PDFCanvasHeight(1 To in_Canvas)
ReDim Preserve PDFCanvasOrientation(1 To in_Canvas)
End Property
Property Let PDFFormatPage(str_FormatPage As Variant)
Attribute PDFFormatPage.VB_HelpID = 2018
ReDim Preserve PDFCanvasWidth(1 To in_Canvas)
ReDim Preserve PDFCanvasHeight(1 To in_Canvas)
ReDim Preserve PDFCanvasOrientation(1 To in_Canvas)
Select Case TypeName(str_FormatPage)
Case "Long"
Select Case str_FormatPage
Case FORMAT_A4
PDFCanvasWidth(in_Canvas) = 595.28
PDFCanvasHeight(in_Canvas) = 841.89
Case FORMAT_A3
PDFCanvasWidth(in_Canvas) = 841.89
PDFCanvasHeight(in_Canvas) = 1190.55
Case FORMAT_A5
PDFCanvasWidth(in_Canvas) = 420.94
PDFCanvasHeight(in_Canvas) = 595.28
Case FORMAT_LETTER
PDFCanvasWidth(in_Canvas) = 612
PDFCanvasHeight(in_Canvas) = 792
Case FORMAT_LEGAL
PDFCanvasWidth(in_Canvas) = 612
PDFCanvasHeight(in_Canvas) = 1008
Case Else
MsgBox "Format page set incorrectly : " & str_FormatPage & "." & _
vbNewLine & _
"Format page set to A4.", vbCritical, "Format Page - " & clsPDFVersion
PDFCanvasWidth(in_Canvas) = 595.28
PDFCanvasHeight(in_Canvas) = 841.89
End Select
Case "Double()"
PDFCanvasWidth(in_Canvas) = str_FormatPage(0)
PDFCanvasHeight(in_Canvas) = str_FormatPage(1)
Case Else
MsgBox "Format page set incorrectly : " & str_FormatPage & "." & _
vbNewLine & _
"Format page set to A4", vbCritical, "Format Page - " & clsPDFVersion
PDFCanvasWidth(in_Canvas) = 595.28
PDFCanvasHeight(in_Canvas) = 841.89
End Select
End Property
Property Get PDFPageNumber() As Integer
Attribute PDFPageNumber.VB_HelpID = 2019
PDFPageNumber = FPageNumber
End Property
Property Get PDFNbPage() As Integer
Attribute PDFNbPage.VB_HelpID = 2020
PDFNbPage = UBound(PageNumberList)
End Property
Property Let PDFProducer(str_Producer As String)
Attribute PDFProducer.VB_HelpID = 2021
FProducer = str_Producer
End Property
Property Let PDFSubject(str_Subject As String)
Attribute PDFSubject.VB_HelpID = 2022
FSubject = str_Subject
End Property
Property Let PDFKeywords(str_Keywords As String)
Attribute PDFKeywords.VB_HelpID = 2023
FKeywords = str_Keywords
End Property
Property Let PDFCreator(str_Creator As String)
Attribute PDFCreator.VB_HelpID = 2024
FCreator = str_Creator
End Property
Property Let PDFAuthor(str_Author As String)
Attribute PDFAuthor.VB_HelpID = 2025
FAuthor = str_Author
End Property
Property Let PDFTitle(str_Title As String)
Attribute PDFTitle.VB_HelpID = 2027
FTitle = str_Title
End Property
Property Let PDFFileName(str_FileName As String)
Attribute PDFFileName.VB_HelpID = 2028
Dim Items() As String
Dim sFilePath As String
Dim sFileName As String
Dim hwnd As Long
Dim retval As Long
Dim in_i As Long
On Error GoTo Err_File
FFileName = str_FileName
Items = Split(str_FileName, "\")
If UBound(Items) = -1 Then Exit Property
sFileName = Items(UBound(Items))
sFilePath = Left(str_FileName, Len(str_FileName) - Len(Items(UBound(Items))))
sPDFName = Fso.BuildPath(sFilePath, sFileName)
Set Strm = Fso.CreateTextFile(sPDFName, True)
Exit Property
Err_File:
If Err = 70 Then
hwnd = FindWindow(vbNullString, "Adobe Reader - [" & sFileName & "]")
retval = PostMessage(hwnd, WM_CLOSE, 0&, 0&)
Sleep 17
Set Strm = Fso.CreateTextFile(sPDFName, True)
Resume Next
End If
End Property
Property Get PDFGetFileName() As String
PDFGetFileName = FFileName
End Property
Property Let PDFConfirm(boConfirm As Boolean)
Attribute PDFConfirm.VB_HelpID = 2029
boPDFConfirm = boConfirm
End Property
Property Let PDFView(boView As Boolean)
boPDFView = boView
End Property
Property Let PDFPageHeight(in_PageHeight As Double)
Attribute PDFPageHeight.VB_HelpID = 2030
PDFCanvasHeight(in_Canvas) = in_PageHeight
End Property
Property Get PDFGetPageHeight() As Double
Attribute PDFGetPageHeight.VB_HelpID = 2031
PDFGetPageHeight = PDFCanvasHeight(in_Canvas)
End Property
Property Let PDFPageWidth(in_PageWidth As Double)
Attribute PDFPageWidth.VB_HelpID = 2032
PDFCanvasWidth(in_Canvas) = in_PageWidth
End Property
Property Get PDFGetPageWidth() As Double
Attribute PDFGetPageWidth.VB_HelpID = 2033
PDFGetPageWidth = PDFCanvasWidth(in_Canvas)
End Property
Property Let PDFSetLeftMargin(in_left As Double)
Attribute PDFSetLeftMargin.VB_HelpID = 2034
PDFlMargin = in_left
End Property
Property Get PDFGetLeftMargin() As Double
Attribute PDFGetLeftMargin.VB_HelpID = 2035
PDFGetLeftMargin = PDFlMargin
End Property
Property Let PDFSetRightMargin(in_right As Double)
Attribute PDFSetRightMargin.VB_HelpID = 2036
PDFrMargin = in_right
End Property
Property Get PDFGetRightMargin() As Double
Attribute PDFGetRightMargin.VB_HelpID = 2037
PDFGetRightMargin = PDFrMargin
End Property
Property Let PDFSetTopMargin(in_top As Double)
Attribute PDFSetTopMargin.VB_HelpID = 2038
PDFtMargin = in_top
End Property
Property Get PDFGetTopMargin() As Double
Attribute PDFGetTopMargin.VB_HelpID = 2039
PDFGetTopMargin = PDFtMargin
End Property
Property Let PDFSetBottomMargin(in_bottom As Double)
Attribute PDFSetBottomMargin.VB_HelpID = 2040
PDFbMargin = in_bottom
End Property
Property Get PDFGetBottomMargin() As Double
Attribute PDFGetBottomMargin.VB_HelpID = 2041
PDFGetBottomMargin = PDFbMargin
End Property
Property Let PDFSetCellMargin(in_cell As Double)
Attribute PDFSetCellMargin.VB_HelpID = 2042
PDFcMargin = in_cell
End Property
Property Get PDFGetCellMargin() As Double
Attribute PDFGetCellMargin.VB_HelpID = 2043
PDFGetCellMargin = PDFcMargin
End Property
Public Sub PDFSetMargins(in_left As Integer, in_top As Integer, Optional in_right As Integer = -1, Optional in_bottom As Integer = -1)
Attribute PDFSetMargins.VB_HelpID = 2044
PDFlMargin = in_left
PDFtMargin = in_top
If in_right = -1 Then in_right = in_left
If in_bottom = -1 Then in_bottom = in_top
PDFrMargin = in_right
PDFbMargin = in_bottom
End Sub
Property Get PDFGetX() As Integer
Attribute PDFGetX.VB_HelpID = 2045
PDFGetX = in_xCurrent
End Property
Property Get PDFGetY() As Integer
Attribute PDFGetY.VB_HelpID = 2046
PDFGetY = in_yCurrent
End Property
Property Let PDFSetLineStyle(pLineStyle As PDFStyleLgn)
Attribute PDFSetLineStyle.VB_HelpID = 2047
PDFLnStyle = PDFLineStyle(pLineStyle)
End Property
Property Let PDFSetLineWidth(pLineWidth As Double)
Attribute PDFSetLineWidth.VB_HelpID = 2048
PDFLnWidth = pLineWidth
End Property
Property Let PDFSetDrawMode(pDrawMode As PDFDrawMd)
Attribute PDFSetDrawMode.VB_HelpID = 2049
Dim pTmpDrawMode As String
pTmpDrawMode = LCase(pDrawMode)
Select Case pTmpDrawMode
Case DRAW_NORMAL
PDFDrawMode = ""
Case DRAW_DRAW
PDFDrawMode = "D"
Case DRAW_DRAWBORDER
PDFDrawMode = "DB"
Case Else
MsgBox "Draw Mode set incorrectly : " & pDrawMode & "." & _
vbNewLine & _
"Draw mode set to normal", vbCritical, "Object Rectangle - " & clsPDFVersion
PDFDrawMode = ""
End Select
End Property
Private Function PDFLineStyle(pLineStyle As PDFStyleLgn) As String
Attribute PDFLineStyle.VB_HelpID = 2050
Dim pTmpLineStyle As PDFStyleLgn
PDFLineStyle = ""
pTmpLineStyle = pLineStyle
Select Case pTmpLineStyle
Case pPDF_SOLID
PDFLineStyle = "[] 0 d"
Case pPDF_DASH
PDFLineStyle = "[" & Int(16 * in_Ech) & " " & Int(8 * in_Ech) & " ] 0 d"
Case pPDF_DASHDOT
PDFLineStyle = "[" & Int(8 * in_Ech) & " " & Int(7 * in_Ech) & " " & _
Int(2 * in_Ech) & " " & Int(7 * in_Ech) & " ] 0 d"
Case pPDF_DASHDOTDOT
PDFLineStyle = "[" & Int(8 * in_Ech) & " " & Int(4 * in_Ech) & " " & _
Int(2 * in_Ech) & " " & Int(4 * in_Ech) & " " & _
Int(2 * in_Ech) & " " & Int(4 * in_Ech) & " ] 0 d"
Case Else
MsgBox "Line style set incorrectly : " & pLineStyle & "." & _
vbNewLine & _
"Line style set to solid.", vbCritical, "Line Style - " & clsPDFVersion
PDFLineStyle = "[] 0 d"
End Select
End Function
Public Sub PDFSetFont(str_Fontname As PDFFontNme, in_FontSize As Integer, Optional str_Style As PDFFontStl)
Attribute PDFSetFont.VB_HelpID = 2051
Dim str_TmpFontName As String
Dim str_TmpFontNm As String
If str_Fontname <> FONT_ARIAL And _
str_Fontname <> FONT_COURIER And _
str_Fontname <> FONT_SYMBOL And _
str_Fontname <> FONT_TIMES And _
str_Fontname <> FONT_ZAPFDINGBATS Then
MsgBox "Font name set incorrectly : " & str_Style & "." & _
vbNewLine & _
"Font set to Times New Roman.", vbCritical, "Font name - " & clsPDFVersion
str_TmpFontName = "TimesRoman"
boPDFItalic = False
boPDFBold = False
PDFFontName = str_TmpFontName
PDFFontNum = FontNum
PDFFontSize = in_FontSize
FontNum = FontNum + 1
Exit Sub
End If
Select Case str_Fontname
Case FONT_ARIAL
str_TmpFontNm = "Arial"
Case FONT_COURIER
str_TmpFontNm = "Courier"
Case FONT_TIMES
str_TmpFontNm = "Times"
Case FONT_SYMBOL
str_TmpFontNm = "Symbol"
Case FONT_ZAPFDINGBATS
str_TmpFontNm = "ZapfDingbats"
End Select
If str_TmpFontNm = "Arial" Then
str_TmpFontName = "Helvetica"
Else
str_TmpFontName = str_TmpFontNm
End If
boPDFItalic = False
boPDFBold = False
str_TmpFont = str_TmpFontName
If InStr(1, str_Style, FONT_ITALIC) <> 0 Then boPDFItalic = True
If InStr(1, str_Style, FONT_BOLD) <> 0 Then boPDFBold = True
If InStr(1, str_Style, FONT_UNDERLINE) <> 0 Then boPDFUnderline = True
If boPDFItalic = True And boPDFBold = False Then
Select Case str_TmpFontName
Case "Times"
str_TmpFontName = "TimesItalic"
Case Else
str_TmpFontName = str_TmpFontName & "-Oblique"
End Select
End If
If boPDFItalic = True And boPDFBold = True Then
Select Case str_TmpFontName
Case "Times"
str_TmpFontName = str_TmpFontName & "-BoldItalic"
Case Else
str_TmpFontName = str_TmpFontName & "-BoldOblique"
End Select
End If
If boPDFItalic = False And boPDFBold = True Then
str_TmpFontName = str_TmpFontName & "-Bold"
End If
If boPDFItalic = False And boPDFBold = False Then
Select Case str_TmpFontName
Case "Times"
str_TmpFontName = str_TmpFontName & "-Roman"
Case Else
str_TmpFontName = str_TmpFontName
End Select
End If
PDFFontName = str_TmpFontName
PDFFontNum = FontNum
PDFFontSize = in_FontSize
FontNum = FontNum + 1
End Sub
Public Sub PDFDrawEllipse(x As Double, y As Double, rx As Double, Optional ry As Double = 0, Optional URLLink As String = "")
Attribute PDFDrawEllipse.VB_HelpID = 2056
Dim sTempDrawMode As String
If ry = 0 Then ry = rx
Select Case PDFDrawMode
Case "D"
PDFOutStream sTempStream, PDFDrawColor
sTempDrawMode = "h f"
Case "DB"
PDFOutStream sTempStream, PDFDrawColor
PDFOutStream sTempStream, PDFLineColor
sTempDrawMode = "B"
Case ""
PDFOutStream sTempStream, PDFLineColor
sTempDrawMode = "s"
End Select
PDFOutStream sTempStream, PDFLnStyle
PDFOutStream sTempStream, PDFFormatDouble(x * in_Ech) & " " & PDFFormatDouble(PDFCanvasHeight(in_Canvas) - (y + ry / 2) * in_Ech) & " m"
PDFOutStream sTempStream, PDFCurve(x * in_Ech, _
PDFCanvasHeight(in_Canvas) - (y + ry / 2 - ry / 2 * 11 / 20) * in_Ech, _
(x + rx / 2 - rx / 2 * 11 / 20) * in_Ech, _
PDFCanvasHeight(in_Canvas) - y * in_Ech, _
(x + rx / 2) * in_Ech, _
PDFCanvasHeight(in_Canvas) - y * in_Ech)
PDFOutStream sTempStream, PDFCurve((x + rx / 2 + rx / 2 * 11 / 20) * in_Ech, _
PDFCanvasHeight(in_Canvas) - y * in_Ech, _
(x + rx) * in_Ech, _
PDFCanvasHeight(in_Canvas) - (y + ry / 2 - ry / 2 * 11 / 20) * in_Ech, _
(x + rx) * in_Ech, _
PDFCanvasHeight(in_Canvas) - (y + ry / 2) * in_Ech)
PDFOutStream sTempStream, PDFCurve((x + rx) * in_Ech, _
PDFCanvasHeight(in_Canvas) - (y + ry / 2 + ry / 2 * 11 / 20) * in_Ech, _
(x + rx / 2 + rx / 2 * 11 / 20) * in_Ech, _
PDFCanvasHeight(in_Canvas) - (y + ry) * in_Ech, _
(x + rx / 2) * in_Ech, _
PDFCanvasHeight(in_Canvas) - (y + ry) * in_Ech)
PDFOutStream sTempStream, PDFCurve((x + rx / 2 - rx / 2 * 11 / 20) * in_Ech, _
PDFCanvasHeight(in_Canvas) - (y + ry) * in_Ech, _
x * in_Ech, _
PDFCanvasHeight(in_Canvas) - (y + ry / 2 + ry / 2 * 11 / 20) * in_Ech, _
x * in_Ech, _
PDFCanvasHeight(in_Canvas) - (y + ry / 2) * in_Ech)
PDFOutStream sTempStream, PDFFormatDouble(PDFLnWidth * in_Ech) & " w " & sTempDrawMode
PDFSetTextColor = vbWhite
strTLink = "LINK"
strTyLink = "ELLIPSE"
PDFSetLink URLLink, "ELLIPSE", Int((x - rx / 2)), Int((y + ry / 2 - ry / 2 * 11 / 20))
strTyLink = ""
in_xCurrent = x
in_yCurrent = y + ry / 2
End Sub
Private Function PDFCurve(X1, Y1, X2, Y2, X3, Y3 As Double) As String
Attribute PDFCurve.VB_HelpID = 2057
PDFCurve = PDFFormatDouble(X1) & " " & _
PDFFormatDouble(Y1) & " " & _
PDFFormatDouble(X2) & " " & _
PDFFormatDouble(Y2) & " " & _
PDFFormatDouble(X3) & " " & _
PDFFormatDouble(Y3) & " c"
End Function
Public Sub PDFDrawPolygon(ParamArray pParam() As Variant)
Dim sTempDrawMode As String
Dim nbP As Double
Dim in_i As Integer
nbP = (UBound(pParam(0), 1) + 1) / 2
Select Case PDFDrawMode
Case "D"
PDFOutStream sTempStream, PDFDrawColor
sTempDrawMode = "h f"
Case "DB"
PDFOutStream sTempStream, PDFDrawColor
PDFOutStream sTempStream, PDFLineColor
sTempDrawMode = "B"
Case ""
PDFOutStream sTempStream, PDFLineColor
sTempDrawMode = "s"
End Select
PDFOutStream sTempStream, "%DEBUT_POLY/%"
PDFOutStream sTempStream, PDFLnStyle
PDFPoint CDbl(pParam(0)(0)), CDbl(pParam(0)(1))
For in_i = 2 To nbP * 2 - 1
If in_i Mod 2 = 0 Then
PDFLine CDbl(pParam(0)(in_i)), CDbl(pParam(0)(in_i + 1))
End If
Next in_i
PDFLine CDbl(pParam(0)(0)), CDbl(pParam(0)(1))
PDFOutStream sTempStream, PDFFormatDouble(PDFLnWidth * in_Ech) & " w " & sTempDrawMode
PDFOutStream sTempStream, "%FIN_POLY/%"
End Sub
Private Function PDFPoint(x As Double, y As Double)
PDFOutStream sTempStream, PDFFormatDouble(x * in_Ech) & " " & _
PDFFormatDouble(PDFCanvasHeight(in_Canvas) - y * in_Ech) & " m"
End Function
Private Function PDFLine(x As Double, y As Double)
PDFOutStream sTempStream, PDFFormatDouble(x * in_Ech) & " " & _
PDFFormatDouble(PDFCanvasHeight(in_Canvas) - y * in_Ech) & " l"
End Function
Public Sub PDFDrawLineHor(x As Double, y As Double, W As Double)
Attribute PDFDrawLineHor.VB_HelpID = 2059
If Right(PDFLineColor, 2) = "RG" Then
PDFDrawColor = Left(PDFLineColor, Len(PDFLineColor) - 2) & "rg"
Else
PDFDrawColor = Left(PDFLineColor, Len(PDFLineColor) - 1) & "g"
End If
PDFOutStream sTempStream, "%DEBUT_LNH/%"
PDFOutStream sTempStream, PDFLnStyle
PDFOutStream sTempStream, PDFFormatDouble(x * in_Ech) & " " & PDFFormatDouble(PDFCanvasHeight(in_Canvas) - y * in_Ech) & " m"
PDFOutStream sTempStream, PDFFormatDouble((x + W) * in_Ech) & " " & PDFFormatDouble(PDFCanvasHeight(in_Canvas) - y * in_Ech) & " l"
PDFOutStream sTempStream, PDFLineColor