Skip to content

Commit 0eba1e0

Browse files
olivierauverlotjecisc
authored andcommitted
first backup
1 parent 4cbfec7 commit 0eba1e0

7 files changed

+258
-0
lines changed

.project

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
'srcDirectory' : 'src'
3+
}

src/.properties

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
#format : #tonel
3+
}

src/Artefact/PDFComponent.class.st

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Class {
2+
#name : #PDFComponent,
3+
#superclass : #Object,
4+
#category : #Artefact
5+
}

src/Artefact/PDFDocument.class.st

+225
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
Class {
2+
#name : #PDFDocument,
3+
#superclass : #Object,
4+
#instVars : [
5+
'document',
6+
'pages',
7+
'fonts',
8+
'orientation',
9+
'width',
10+
'height',
11+
'scaleFactor',
12+
'lMargin',
13+
'tMargin',
14+
'autoPageBreak',
15+
'pageBreakTrigger'
16+
],
17+
#category : #Artefact
18+
}
19+
20+
{ #category : #action }
21+
PDFDocument >> addPage [
22+
"add a new page in the PDF document"
23+
24+
]
25+
26+
{ #category : #accessing }
27+
PDFDocument >> autoPageBreak [
28+
^autoPageBreak
29+
]
30+
31+
{ #category : #accessing }
32+
PDFDocument >> autoPageBreak: aLogicValue [
33+
autoPageBreak := aLogicValue
34+
]
35+
36+
{ #category : #accessing }
37+
PDFDocument >> document [
38+
^ document ifNil: [ document := '%PDF-1.3' , (String cr) ]
39+
]
40+
41+
{ #category : #accessing }
42+
PDFDocument >> document: bodyOfPDFDocument [
43+
document := bodyOfPDFDocument
44+
]
45+
46+
{ #category : #accessing }
47+
PDFDocument >> fonts [
48+
^ fonts ifNil: [
49+
fonts := #(
50+
'courier'->'Courier' , 'courierB'->'Courier-Bold' , 'courierI' -> 'Courier-Oblique' , 'courierBI'->'Courier-BoldOblique' ,
51+
'helvetica'->'Helvetica', 'helveticaB'->'Helvetica-Bold' , 'helveticaI'->'Helvetica-Oblique' , 'helveticaBI'->'Helvetica-BoldOblique' ,
52+
'times'->'Times-Roman' , 'timesB'->'Times-Bold' , 'timesI'->'Times-Oblique' , 'timesBI'->'Times-BoldItalic' ,
53+
'symbol'->'Symbol' , 'symbolB'->'Symbol' , 'symbolI'->'Symbol' , 'symbolBI'->'Symbol' ,
54+
'zapfdingbats'->'ZapfDingbats' , 'zapfdingbatsB'->'ZapfDingbats' , 'zapfdingbatsI'->'ZapfDingbats' , 'zapfdingbatsBI'->'ZapfDingbats'
55+
)
56+
]
57+
]
58+
59+
{ #category : #action }
60+
PDFDocument >> generate [
61+
" answer the PDF file"
62+
63+
64+
65+
]
66+
67+
{ #category : #accessing }
68+
PDFDocument >> height [
69+
height ifNil: [ self setPortrait ].
70+
^height
71+
]
72+
73+
{ #category : #accessing }
74+
PDFDocument >> height: aValue [
75+
height := aValue
76+
]
77+
78+
{ #category : #'initialize-release' }
79+
PDFDocument >> initialize [
80+
super initialize.
81+
self setAutoPageBreak: true margin: self margin.
82+
83+
84+
]
85+
86+
{ #category : #accessing }
87+
PDFDocument >> lMargin [
88+
lMargin ifNil: [ self setDefaultMargins ].
89+
^lMargin
90+
]
91+
92+
{ #category : #accessing }
93+
PDFDocument >> lMargin: aValue [
94+
lMargin := aValue
95+
]
96+
97+
{ #category : #private }
98+
PDFDocument >> margin [
99+
^(28.35 / self scaleFactor asFloat)
100+
]
101+
102+
{ #category : #accessing }
103+
PDFDocument >> orientation [
104+
^ orientation
105+
]
106+
107+
{ #category : #accessing }
108+
PDFDocument >> orientation: aValue [
109+
orientation := aValue
110+
]
111+
112+
{ #category : #accessing }
113+
PDFDocument >> pageBreakTrigger [
114+
^pageBreakTrigger
115+
]
116+
117+
{ #category : #accessing }
118+
PDFDocument >> pageBreakTrigger: aValue [
119+
pageBreakTrigger := aValue
120+
]
121+
122+
{ #category : #accessing }
123+
PDFDocument >> pages [
124+
^ pages ifNil: [ pages := OrderedCollection new ]
125+
]
126+
127+
{ #category : #accessing }
128+
PDFDocument >> pages: aPDFPage [
129+
pages := aPDFPage
130+
]
131+
132+
{ #category : #accessing }
133+
PDFDocument >> scaleFactor [
134+
scaleFactor ifNil: [ self usePointsAsUnit ].
135+
^scaleFactor
136+
]
137+
138+
{ #category : #accessing }
139+
PDFDocument >> scaleFactor: aValue [
140+
scaleFactor := aValue
141+
]
142+
143+
{ #category : #'page setup' }
144+
PDFDocument >> setAutoPageBreak: mode [
145+
self autoPageBreak: mode.
146+
self pageBreakTrigger: self height / self scaleFactor.
147+
]
148+
149+
{ #category : #'page setup' }
150+
PDFDocument >> setAutoPageBreak: mode margin: aMargin [
151+
self autoPageBreak: mode.
152+
self pageBreakTrigger: (self height / self scaleFactor) - aMargin
153+
]
154+
155+
{ #category : #private }
156+
PDFDocument >> setDefaultMargins [
157+
self tMargin: self margin.
158+
self lMargin: self margin.
159+
]
160+
161+
{ #category : #'page setup' }
162+
PDFDocument >> setLandscape [
163+
"Set the page in landscape orientation"
164+
self width: 841.9.
165+
self height: 595.3.
166+
]
167+
168+
{ #category : #'page setup' }
169+
PDFDocument >> setMargins: leftMargin top: topMargin [
170+
"set the left and top margins"
171+
172+
self lMargin: leftMargin.
173+
self tMargin: topMargin.
174+
175+
]
176+
177+
{ #category : #'page setup' }
178+
PDFDocument >> setPortrait [
179+
"Set the page in portrait orientation"
180+
self width: 595.3.
181+
self height: 841.9.
182+
183+
]
184+
185+
{ #category : #accessing }
186+
PDFDocument >> tMargin [
187+
tMargin ifNil: [ self SetDefaultMargins ].
188+
^tMargin
189+
]
190+
191+
{ #category : #accessing }
192+
PDFDocument >> tMargin: aValue [
193+
tMargin := aValue
194+
]
195+
196+
{ #category : #'page setup' }
197+
PDFDocument >> useCentimetersAsUnit [
198+
self scaleFactor: 72 / 2.54.
199+
]
200+
201+
{ #category : #'page setup' }
202+
PDFDocument >> useInchsAsUnit [
203+
self scaleFactor: 72.
204+
]
205+
206+
{ #category : #'page setup' }
207+
PDFDocument >> useMillimetersAsUnit [
208+
self scaleFactor: 72 / 25.4.
209+
]
210+
211+
{ #category : #'page setup' }
212+
PDFDocument >> usePointsAsUnit [
213+
self scaleFactor: 1.
214+
]
215+
216+
{ #category : #accessing }
217+
PDFDocument >> width [
218+
width ifNil: [ self setPortrait ].
219+
^width
220+
]
221+
222+
{ #category : #accessing }
223+
PDFDocument >> width: aValue [
224+
width := aValue
225+
]

src/Artefact/PDFPage.class.st

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Class {
2+
#name : #PDFPage,
3+
#superclass : #Object,
4+
#instVars : [
5+
'components'
6+
],
7+
#category : #Artefact
8+
}

src/Artefact/PDFTest.class.st

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Class {
2+
#name : #PDFTest,
3+
#superclass : #Object,
4+
#category : #Artefact
5+
}
6+
7+
{ #category : #'as yet unclassified' }
8+
PDFTest class >> ex1 [
9+
"generate a sample document"
10+
11+
| pdfdoc |
12+
pdfdoc := PDFDocument new.
13+
]

src/Artefact/package.st

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Package { #name : #Artefact }

0 commit comments

Comments
 (0)