This commit is contained in:
csh 2024-06-25 15:52:29 +08:00
parent 7cfb53a9e0
commit c3937ff7fd
76 changed files with 11874 additions and 1 deletions

View File

@ -1,3 +1,24 @@
# Pdf
使用tsl生成你的pdf文件
使用tsl生成你的pdf文件
## 部署
### funcext
将`TSPdfEnumerations.tsf`文件部署到tsl安装路径下的`funcext`
### plugin
将`plugin`目录下对应动态库部署到tsl安装目录的`plugin`
## Demo
demo目录是使用参考的demo若要执行demo下的tsl生成对应的pdf则需要部署`demo\InitCmdParams.tsf`到`funcext`
```c
tsl demo\xxx.tsl --path=D:/code/pdf --alias=""
--path是控制生成对应pdf的路径
--alias是别名
```

714
TSPdfEnumerations.tsf Normal file
View File

@ -0,0 +1,714 @@
unit TSPdfEnumerations;
interface
// HPDF_PageLayout
function PAGE_LAYOUT_SINGLE();
function PAGE_LAYOUT_ONE_COLUMN();
function PAGE_LAYOUT_TWO_COLUMN_LEFT();
function PAGE_LAYOUT_TWO_COLUMN_RIGHT();
function PAGE_LAYOUT_TWO_PAGE_LEFT();
function PAGE_LAYOUT_TWO_PAGE_RIGHT();
function PAGE_LAYOUT_EOF();
// HPDF_PageMode
function PAGE_MODE_USE_NODE();
function PAGE_MODE_USE_OUTLINE();
function PAGE_MODE_USE_THUMBS();
function PAGE_MODE_USE_SCREEN();
function PAGE_MODE_EOF();
// HPDF_ColorSpace
function CS_DEVICE_GRAY();
function CS_DEVICE_RGB();
function CS_DEVICE_CMYK();
function CS_CAL_GRAY();
function CS_CAL_RGB();
function CS_LAB();
function CS_ICC_BASED();
function CS_SEPARATION();
function CS_DEVICE_N();
function CS_INDEXED();
function CS_PATTERN();
function CS_EOF();
// HPDF_InfoType
function INFO_AUTHOR();
function INFO_CREATOR();
function INFO_TITLE();
function INFO_SUBJECT();
function INFO_KEYWORDS();
function INFO_CREATION_DATE();
function INFO_MOD_DATE();
// Permission
function ENABLE_READ();
function ENABLE_PRINT();
function ENABLE_EDIT_ALL();
function ENABLE_COPY();
function ENABLE_EDIT();
// HPDF_PageSizes
function PAGE_SIZE_LETTER();
function PAGE_SIZE_LEGAL();
function PAGE_SIZE_A3();
function PAGE_SIZE_A4();
function PAGE_SIZE_A5();
function PAGE_SIZE_B4();
function PAGE_SIZE_B5();
function PAGE_SIZE_EXECUTIVE();
function PAGE_SIZE_US4x6();
function PAGE_SIZE_US4x8();
function PAGE_SIZE_US5x7();
function PAGE_SIZE_COMM10();
function PAGE_SIZE_EOF();
// HPDF_PageDirection
function PAGE_PORTRAIT();
function PAGE_LANDSCAPE();
// HPDF_LineCap
function BUTT_END();
function ROUND_END();
function PROJECTING_SQUARE_END();
function LINECAP_EOF();
// HPDF_LineJoin
function MITER_JOIN();
function ROUND_JOIN();
function BEVEL_JOIN();
function LINEJOIN_EOF();
// HPDF_TextRenderingMode
function FILL();
function STROKE();
function FILL_THEN_STROKE();
function INVISIBLE();
function FILL_CLIPPING();
function STROKE_CLIPPING();
function FILL_STROKE_CLIPPING();
function CLIPPING();
function RENDERING_MODE_EOF();
// HPDF_CompressionMode
function COMP_NONE();
function COMP_TEXT();
function COMP_IMAGE();
function COMP_METADATA();
function COMP_ALL();
// HPDF_EncryptMode
function ENCRYPT_R2();
function ENCRYPT_R3();
// HPDF_TextAlignment
function TALIGN_LEFT();
function TALIGN_RIGHT();
function TALIGN_CENTER();
function TALIGN_JUSTIFY();
// HPDF_EncoderType
function ENCODER_TYPE_SINGLE_BYTE();
function ENCODER_TYPE_DOUBLE_BYTE();
function ENCODER_TYPE_UNINITIALIZED();
function ENCODER_UNKNOWN();
// HPDF_ByteType
function BYTE_TYPE_SINGLE();
function BYTE_TYPE_LEAD();
function BYTE_TYPE_TRAIL();
function BYTE_TYPE_UNKNOWN();
// HPDF_WritingMode
function WMODE_HORIZONTAL();
function WMODE_VERTICAL();
function WMODE_EOF();
// HPDF_AnnotHighlightMode
function ANNOT_NO_HIGHTLIGHT();
function ANNOT_INVERT_BOX();
function ANNOT_INVERT_BORDER();
function ANNOT_DOWN_APPEARANCE();
function ANNOT_HIGHTLIGHT_MODE_EOF();
// HPDF_AnnotIcon
function ANNOT_ICON_COMMENT();
function ANNOT_ICON_KEY();
function ANNOT_ICON_NOTE();
function ANNOT_ICON_HELP();
function ANNOT_ICON_NEW_PARAGRAPH();
function ANNOT_ICON_PARAGRAPH();
function ANNOT_ICON_INSERT();
function ANNOT_ICON_EOF();
// HPDF_BSSubtype
function BS_SOLID();
function BS_DASHED();
function BS_BEVELED();
function BS_INSET();
function BS_UNDERLINED();
// HPDF_TransitionStyle
function TS_WIPE_RIGHT();
function TS_WIPE_UP();
function TS_WIPE_LEFT();
function TS_WIPE_DOWN();
function TS_BARN_DOORS_HORIZONTAL_OUT();
function TS_BARN_DOORS_HORIZONTAL_IN();
function TS_BARN_DOORS_VERTICAL_OUT();
function TS_BARN_DOORS_VERTICAL_IN();
function TS_BOX_OUT();
function TS_BOX_IN();
function TS_BLINDS_HORIZONTAL();
function TS_BLINDS_VERTICAL();
function TS_DISSOLVE();
function TS_GLITTER_RIGHT();
function TS_GLITTER_DOWN();
function TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT();
function TS_REPLACE();
function TS_EOF();
implementation
// HPDF_PageLayout
function PAGE_LAYOUT_SINGLE();
begin
return 0;
end;
function PAGE_LAYOUT_ONE_COLUMN();
begin
return 1;
end;
function PAGE_LAYOUT_TWO_COLUMN_LEFT();
begin
return 2;
end;
function PAGE_LAYOUT_TWO_COLUMN_RIGHT();
begin
return 3;
end;
function PAGE_LAYOUT_TWO_PAGE_LEFT();
begin
return 4;
end;
function PAGE_LAYOUT_TWO_PAGE_RIGHT();
begin
return 5;
end;
function PAGE_LAYOUT_EOF();
begin
return 6;
end;
// HPDF_PageMode
function PAGE_MODE_USE_NODE();
begin
return 0;
end;
function PAGE_MODE_USE_OUTLINE();
begin
return 1;
end;
function PAGE_MODE_USE_THUMBS();
begin
return 2;
end;
function PAGE_MODE_USE_SCREEN();
begin
return 3;
end;
function PAGE_MODE_EOF();
begin
return 4;
end;
// HPDF_ColorSpace
function CS_DEVICE_GRAY();
begin
return 0;
end;
function CS_DEVICE_RGB();
begin
return 1;
end;
function CS_DEVICE_CMYK();
begin
return 2;
end;
function CS_CAL_GRAY();
begin
return 3;
end;
function CS_CAL_RGB();
begin
return 4;
end;
function CS_LAB();
begin
return 5;
end;
function CS_ICC_BASED();
begin
return 6;
end;
function CS_SEPARATION();
begin
return 7;
end;
function CS_DEVICE_N();
begin
return 8;
end;
function CS_INDEXED();
begin
return 9;
end;
function CS_PATTERN();
begin
return 10;
end;
function CS_EOF();
begin
return 11;
end;
// HPDF_InfoType
function INFO_AUTHOR();
begin
return "AUTHOR";
end;
function INFO_CREATOR();
begin
return "CREATOR";
end;
function INFO_TITLE();
begin
return "TITLE";
end;
function INFO_SUBJECT();
begin
return "SUBJECT";
end;
function INFO_KEYWORDS();
begin
return "KEYWORDS";
end;
function INFO_CREATION_DATE();
begin
return "CREATION_DATE";
end;
function INFO_MOD_DATE();
begin
return "MOD_DATE";
end;
// Permission
function ENABLE_READ();
begin
return 0;
end;
function ENABLE_PRINT();
begin
return 4;
end;
function ENABLE_EDIT_ALL();
begin
return 8;
end;
function ENABLE_COPY();
begin
return 16;
end;
function ENABLE_EDIT();
begin
return 32;
end;
// HPDF_PageSizes
function PAGE_SIZE_LETTER();
begin
return 0;
end;
function PAGE_SIZE_LEGAL();
begin
return 1;
end;
function PAGE_SIZE_A3();
begin
return 2;
end;
function PAGE_SIZE_A4();
begin
return 3;
end;
function PAGE_SIZE_A5();
begin
return 4;
end;
function PAGE_SIZE_B4();
begin
return 5;
end;
function PAGE_SIZE_B5();
begin
return 6;
end;
function PAGE_SIZE_EXECUTIVE();
begin
return 7;
end;
function PAGE_SIZE_US4x6();
begin
return 8;
end;
function PAGE_SIZE_US4x8();
begin
return 9;
end;
function PAGE_SIZE_US5x7();
begin
return 10;
end;
function PAGE_SIZE_COMM10();
begin
return 11;
end;
function PAGE_SIZE_EOF();
begin
return 12;
end;
// HPDF_PageDirection
function PAGE_PORTRAIT();
begin
return 0;
end;
function PAGE_LANDSCAPE();
begin
return 1;
end;
// HPDF_LineCap
function BUTT_END();
begin
return 0;
end;
function ROUND_END();
begin
return 1;
end;
function PROJECTING_SQUARE_END();
begin
return 2;
end;
function LINECAP_EOF();
begin
return 3;
end;
// HPDF_LineJoin
function MITER_JOIN();
begin
return 0;
end;
function ROUND_JOIN();
begin
return 1;
end;
function BEVEL_JOIN();
begin
return 2;
end;
function LINEJOIN_EOF();
begin
return 3;
end;
// HPDF_TextRenderingMode
function FILL();
begin
return 0;
end;
function STROKE();
begin
return 1;
end;
function FILL_THEN_STROKE();
begin
return 2;
end;
function INVISIBLE();
begin
return 3;
end;
function FILL_CLIPPING();
begin
return 4;
end;
function STROKE_CLIPPING();
begin
return 5;
end;
function FILL_STROKE_CLIPPING();
begin
return 6;
end;
function CLIPPING();
begin
return 7;
end;
function RENDERING_MODE_EOF();
begin
return 8;
end;
// HPDF_CompressionMode
function COMP_NONE();
begin
return 0x00;
end;
function COMP_TEXT();
begin
return 0x01;
end;
function COMP_IMAGE();
begin
return 0x02;
end;
function COMP_METADATA();
begin
return 0x04;
end;
function COMP_ALL();
begin
return 0x0F;
end;
// HPDF_EncryptMode
function ENCRYPT_R2();
begin
return 2;
end;
function ENCRYPT_R3();
begin
return 3;
end;
// HPDF_TextAlignment
function TALIGN_LEFT();
begin
return 0;
end;
function TALIGN_RIGHT();
begin
return 1;
end;
function TALIGN_CENTER();
begin
return 2;
end;
function TALIGN_JUSTIFY();
begin
return 3;
end;
// HPDF_EncoderType
function ENCODER_TYPE_SINGLE_BYTE();
begin
return 0;
end;
function ENCODER_TYPE_DOUBLE_BYTE();
begin
return 1;
end;
function ENCODER_TYPE_UNINITIALIZED();
begin
return 2;
end;
function ENCODER_UNKNOWN();
begin
return 3;
end;
// HPDF_ByteType
function BYTE_TYPE_SINGLE();
begin
return 0;
end;
function BYTE_TYPE_LEAD();
begin
return 1;
end;
function BYTE_TYPE_TRAIL();
begin
return 2;
end;
function BYTE_TYPE_UNKNOWN();
begin
return 3;
end;
// HPDF_WritingMode
function WMODE_HORIZONTAL();
begin
return 0;
end;
function WMODE_VERTICAL();
begin
return 1;
end;
function WMODE_EOF();
begin
return 2;
end;
// HPDF_AnnotHighlightMode
function ANNOT_NO_HIGHTLIGHT();
begin
return 0;
end;
function ANNOT_INVERT_BOX();
begin
return 1;
end;
function ANNOT_INVERT_BORDER();
begin
return 2;
end;
function ANNOT_DOWN_APPEARANCE();
begin
return 3;
end;
function ANNOT_HIGHTLIGHT_MODE_EOF();
begin
return 4;
end;
// HPDF_AnnotIcon
function ANNOT_ICON_COMMENT();
begin
return 0;
end;
function ANNOT_ICON_KEY();
begin
return 1;
end;
function ANNOT_ICON_NOTE();
begin
return 2;
end;
function ANNOT_ICON_HELP();
begin
return 3;
end;
function ANNOT_ICON_NEW_PARAGRAPH();
begin
return 4;
end;
function ANNOT_ICON_PARAGRAPH();
begin
return 5;
end;
function ANNOT_ICON_INSERT();
begin
return 6;
end;
function ANNOT_ICON_EOF();
begin
return 7;
end;
// HPDF_BSSubtype
function BS_SOLID();
begin
return 0;
end;
function BS_DASHED();
begin
return 1;
end;
function BS_BEVELED();
begin
return 2;
end;
function BS_INSET();
begin
return 3;
end;
function BS_UNDERLINED();
begin
return 4;
end;
// HPDF_TransitionStyle
function TS_WIPE_RIGHT();
begin
return 0;
end;
function TS_WIPE_UP();
begin
return 1;
end;
function TS_WIPE_LEFT();
begin
return 2;
end;
function TS_WIPE_DOWN();
begin
return 3;
end;
function TS_BARN_DOORS_HORIZONTAL_OUT();
begin
return 4;
end;
function TS_BARN_DOORS_HORIZONTAL_IN();
begin
return 5;
end;
function TS_BARN_DOORS_VERTICAL_OUT();
begin
return 6;
end;
function TS_BARN_DOORS_VERTICAL_IN();
begin
return 7;
end;
function TS_BOX_OUT();
begin
return 8;
end;
function TS_BOX_IN();
begin
return 9;
end;
function TS_BLINDS_HORIZONTAL();
begin
return 10;
end;
function TS_BLINDS_VERTICAL();
begin
return 11;
end;
function TS_DISSOLVE();
begin
return 12;
end;
function TS_GLITTER_RIGHT();
begin
return 13;
end;
function TS_GLITTER_DOWN();
begin
return 14;
end;
function TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT();
begin
return 15;
end;
function TS_REPLACE();
begin
return 16;
end;
function TS_EOF();
begin
return 17;
end;
end.

12
cp.ps1 Normal file
View File

@ -0,0 +1,12 @@
$sourcedir = "D:\code\tinysoft\Pdf-dev"
$destdir = "D:\code\tinysoft\Pdf"
# 复制动态库
Copy-Item -Path "D:\code\tinysoft\output_libs\Release\TSPDF.dll" ($destdir + "\plugin\windows-x64\") -Force
Copy-Item -Path "D:\code\tinysoft\output_libs\libTSPDF.so" ($destdir + "\plugin\ubuntu-18.04\") -Force
# 复制tsf脚本
Remove-Item -Path ($destdir + "\demo\") -Recurse -Force
Remove-Item -Path ($destdir + "\TSPdfEnumerations.tsf") -Force
Copy-Item -Path ($sourcedir + "\demo\") ($destdir + "\demo\") -Recurse -Force
Copy-Item -Path ($sourcedir + "\funcext\Pdf\TSPdfEnumerations.tsf") ($destdir + "\TSPdfEnumerations.tsf") -Force

17
demo/InitCmdParams.tsf Normal file
View File

@ -0,0 +1,17 @@
Function InitCmdParams(alias, path)
Begin
// path := ExtractFileDir(SysparamStr(0));
for i:=0 to SysParamCount() do
begin
param := Trim(SysparamStr(i));
arr := Str2Array(param, "=");
if length(arr) = 2 then
begin
if arr[0] = "--path" then
path := arr[1];
else if arr[0] = '--alias' then
alias := arr[1];
end
end
End;

687
demo/arc_demo.pdf Normal file
View File

@ -0,0 +1,687 @@
%PDF-1.3
%·¾­ª
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 4 0 R ]
/Count 1
>>
endobj
3 0 obj
<<
/Producer (Haru Free PDF Library 2.4.4)
>>
endobj
4 0 obj
<<
/Type /Page
/MediaBox [ 0 0 200 220 ]
/Contents 5 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 7 0 R
>>
>>
/Parent 2 0 R
>>
endobj
5 0 obj
<<
/Length 6 0 R
>>
stream
/F1 5 Tf
0.5 g
0.8 G
0.5 w
0 0 m
200 0 l
S
0.25 w
0 5 m
200 5 l
S
0.5 w
0 10 m
200 10 l
S
0.5 G
0 10 m
5 10 l
S
0.8 G
0.25 w
0 15 m
200 15 l
S
0.5 w
0 20 m
200 20 l
S
0.5 G
0 20 m
5 20 l
S
0.8 G
0.25 w
0 25 m
200 25 l
S
0.5 w
0 30 m
200 30 l
S
0.5 G
0 30 m
5 30 l
S
0.8 G
0.25 w
0 35 m
200 35 l
S
0.5 w
0 40 m
200 40 l
S
0.5 G
0 40 m
5 40 l
S
0.8 G
0.25 w
0 45 m
200 45 l
S
0.5 w
0 50 m
200 50 l
S
0.5 G
0 50 m
5 50 l
S
0.8 G
0.25 w
0 55 m
200 55 l
S
0.5 w
0 60 m
200 60 l
S
0.5 G
0 60 m
5 60 l
S
0.8 G
0.25 w
0 65 m
200 65 l
S
0.5 w
0 70 m
200 70 l
S
0.5 G
0 70 m
5 70 l
S
0.8 G
0.25 w
0 75 m
200 75 l
S
0.5 w
0 80 m
200 80 l
S
0.5 G
0 80 m
5 80 l
S
0.8 G
0.25 w
0 85 m
200 85 l
S
0.5 w
0 90 m
200 90 l
S
0.5 G
0 90 m
5 90 l
S
0.8 G
0.25 w
0 95 m
200 95 l
S
0.5 w
0 100 m
200 100 l
S
0.5 G
0 100 m
5 100 l
S
0.8 G
0.25 w
0 105 m
200 105 l
S
0.5 w
0 110 m
200 110 l
S
0.5 G
0 110 m
5 110 l
S
0.8 G
0.25 w
0 115 m
200 115 l
S
0.5 w
0 120 m
200 120 l
S
0.5 G
0 120 m
5 120 l
S
0.8 G
0.25 w
0 125 m
200 125 l
S
0.5 w
0 130 m
200 130 l
S
0.5 G
0 130 m
5 130 l
S
0.8 G
0.25 w
0 135 m
200 135 l
S
0.5 w
0 140 m
200 140 l
S
0.5 G
0 140 m
5 140 l
S
0.8 G
0.25 w
0 145 m
200 145 l
S
0.5 w
0 150 m
200 150 l
S
0.5 G
0 150 m
5 150 l
S
0.8 G
0.25 w
0 155 m
200 155 l
S
0.5 w
0 160 m
200 160 l
S
0.5 G
0 160 m
5 160 l
S
0.8 G
0.25 w
0 165 m
200 165 l
S
0.5 w
0 170 m
200 170 l
S
0.5 G
0 170 m
5 170 l
S
0.8 G
0.25 w
0 175 m
200 175 l
S
0.5 w
0 180 m
200 180 l
S
0.5 G
0 180 m
5 180 l
S
0.8 G
0.25 w
0 185 m
200 185 l
S
0.5 w
0 190 m
200 190 l
S
0.5 G
0 190 m
5 190 l
S
0.8 G
0.25 w
0 195 m
200 195 l
S
0.5 w
0 200 m
200 200 l
S
0.5 G
0 200 m
5 200 l
S
0.8 G
0.25 w
0 205 m
200 205 l
S
0.5 w
0 210 m
200 210 l
S
0.5 G
0 210 m
5 210 l
S
0.8 G
0.25 w
0 215 m
200 215 l
S
0.5 w
0 0 m
0 220 l
S
0.25 w
5 0 m
5 220 l
S
0.5 w
10 0 m
10 220 l
S
0.25 w
15 0 m
15 220 l
S
0.5 w
20 0 m
20 220 l
S
0.25 w
25 0 m
25 220 l
S
0.5 w
30 0 m
30 220 l
S
0.25 w
35 0 m
35 220 l
S
0.5 w
40 0 m
40 220 l
S
0.25 w
45 0 m
45 220 l
S
0.5 w
50 0 m
50 220 l
S
0.5 G
50 0 m
50 5 l
S
50 220 m
50 215 l
S
0.8 G
0.25 w
55 0 m
55 220 l
S
0.5 w
60 0 m
60 220 l
S
0.25 w
65 0 m
65 220 l
S
0.5 w
70 0 m
70 220 l
S
0.25 w
75 0 m
75 220 l
S
0.5 w
80 0 m
80 220 l
S
0.25 w
85 0 m
85 220 l
S
0.5 w
90 0 m
90 220 l
S
0.25 w
95 0 m
95 220 l
S
0.5 w
100 0 m
100 220 l
S
0.5 G
100 0 m
100 5 l
S
100 220 m
100 215 l
S
0.8 G
0.25 w
105 0 m
105 220 l
S
0.5 w
110 0 m
110 220 l
S
0.25 w
115 0 m
115 220 l
S
0.5 w
120 0 m
120 220 l
S
0.25 w
125 0 m
125 220 l
S
0.5 w
130 0 m
130 220 l
S
0.25 w
135 0 m
135 220 l
S
0.5 w
140 0 m
140 220 l
S
0.25 w
145 0 m
145 220 l
S
0.5 w
150 0 m
150 220 l
S
0.5 G
150 0 m
150 5 l
S
150 220 m
150 215 l
S
0.8 G
0.25 w
155 0 m
155 220 l
S
0.5 w
160 0 m
160 220 l
S
0.25 w
165 0 m
165 220 l
S
0.5 w
170 0 m
170 220 l
S
0.25 w
175 0 m
175 220 l
S
0.5 w
180 0 m
180 220 l
S
0.25 w
185 0 m
185 220 l
S
0.5 w
190 0 m
190 220 l
S
0.25 w
195 0 m
195 220 l
S
BT
5 8 Td
(10) Tj
ET
BT
5 18 Td
(20) Tj
ET
BT
5 28 Td
(30) Tj
ET
BT
5 38 Td
(40) Tj
ET
BT
5 48 Td
(50) Tj
ET
BT
5 58 Td
(60) Tj
ET
BT
5 68 Td
(70) Tj
ET
BT
5 78 Td
(80) Tj
ET
BT
5 88 Td
(90) Tj
ET
BT
5 98 Td
(100) Tj
ET
BT
5 108 Td
(110) Tj
ET
BT
5 118 Td
(120) Tj
ET
BT
5 128 Td
(130) Tj
ET
BT
5 138 Td
(140) Tj
ET
BT
5 148 Td
(150) Tj
ET
BT
5 158 Td
(160) Tj
ET
BT
5 168 Td
(170) Tj
ET
BT
5 178 Td
(180) Tj
ET
BT
5 188 Td
(190) Tj
ET
BT
5 198 Td
(200) Tj
ET
BT
5 208 Td
(210) Tj
ET
BT
50 5 Td
(50) Tj
ET
BT
50 210 Td
(50) Tj
ET
BT
100 5 Td
(100) Tj
ET
BT
100 210 Td
(100) Tj
ET
BT
150 5 Td
(150) Tj
ET
BT
150 210 Td
(150) Tj
ET
0 g
0 G
1 0 0 rg
100 100 m
100 180 l
100.00009 180 l
144.18284 179.99993 180 144.18273 180 100 c
180 65.34192 157.68321 34.62546 124.72143 23.9155 c
100 100 l
f
0 0 1 rg
100 100 m
124.72143 23.9155 l
124.72143 23.9155 l
82.70116 10.26224 37.56884 33.25821 23.91553 75.27846 c
100 100 l
f
0 1 0 rg
100 100 m
23.91553 75.27846 l
23.91553 75.27846 l
16.00205 99.63346 20.22633 126.30496 35.27849 147.02262 c
100 100 l
f
1 1 0 rg
100 100 m
35.27849 147.02262 l
35.27849 147.02262 l
50.33066 167.74028 74.39131 179.9999 99.99969 180 c
100 100 l
f
0 G
1 g
70 100 m
70 116.55999 83.44 130 100 130 c
116.55999 130 130 116.55999 130 100 c
130 83.44 116.55999 70 100 70 c
83.44 70 70 83.44 70 100 c
f
endstream
endobj
6 0 obj
4244
endobj
7 0 obj
<<
/Type /Font
/BaseFont /Helvetica
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
xref
0 8
0000000000 65535 f
0000000015 00000 n
0000000064 00000 n
0000000123 00000 n
0000000184 00000 n
0000000360 00000 n
0000004658 00000 n
0000004678 00000 n
trailer
<<
/Root 1 0 R
/Info 3 0 R
/Size 8
>>
startxref
4776
%%EOF

190
demo/arc_demo.tsl Normal file
View File

@ -0,0 +1,190 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "arc_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
// add a new page object.
page := pdf.AddPage();
page.SetHeight(220);
page.SetWidth(200);
// draw grid to the page
PrintGrid(pdf, page);
// draw pie chart
//
// A: 45% Red
// B: 25% Blue
// C: 15% green
// D: other yellow
// A
page.SetRGBFill(1.0, 0, 0);
page.MoveTo(100, 100);
page.LineTo(100, 180);
page.Arc(100, 100, 80, 0, 360 * 0.45);
pos := page.GetCurrentPos();
page.LineTo(100, 100);
page.Fill();
// B
page.SetRGBFill(0, 0, 1.0);
page.MoveTo(100, 100);
page.LineTo(pos[0], pos[1]);
page.Arc(100, 100, 80, 360 * 0.45, 360 * 0.7);
pos := page.GetCurrentPos();
page.LineTo(100, 100);
page.Fill();
// C
page.SetRGBFill(0, 1.0, 0);
page.MoveTo(100, 100);
page.LineTo(pos[0], pos[1]);
page.Arc(100, 100, 80, 360 * 0.7, 360 * 0.85);
pos := page.GetCurrentPos();
page.LineTo(100, 100);
page.Fill();
// D
page.SetRGBFill(1.0, 1.0, 0);
page.MoveTo(100, 100);
page.LineTo(pos[0], pos[1]);
page.Arc(100, 100, 80, 360 * 0.85, 360);
pos := page.GetCurrentPos();
page.LineTo(100, 100);
page.Fill();
// draw center circle
page.SetGrayStroke(0);
page.SetGrayFill(1);
page.Circle(100, 100, 30);
page.Fill();
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;
Function PrintGrid(pdf, page)
Begin
height := page.GetHeight();
width := page.GetWidth();
font := pdf.GetFont("Helvetica", "");
page.SetFontAndSize(font, 5);
page.SetGrayFill(0.5);
page.SetGrayStroke(0.8);
// Draw horizontal lines
y := 0;
while y < height do
begin
if y % 10 = 0 then
page.SetLineWidth(0.5);
else begin
wid := page.GetWidth();
if wid <> 0.25 then page.SetLineWidth(0.25);
end
page.MoveTo(0, y);
page.LineTo(width, y);
page.Stroke();
if y % 10 = 0 and y > 0 then
begin
page.SetGrayStroke(0.5);
page.MoveTo(0, y);
page.LineTo(5, y);
page.Stroke();
page.SetGrayStroke(0.8);
end
y += 5;
end
// Draw vertical lines
x := 0;
while x < width do
begin
if x % 10 = 0 then
page.SetLineWidth(0.5);
else begin
wid := page.GetWidth();
if wid <> 0.25 then page.SetLineWidth(0.25);
end
page.MoveTo(x, 0);
page.LineTo(x, height);
page.Stroke();
if x % 50 = 0 and x > 0 then
begin
page.SetGrayStroke(0.5);
page.MoveTo(x, 0);
page.LineTo(x, 5);
page.Stroke();
page.MoveTo(x, height);
page.LineTo(x, height - 5);
page.Stroke();
page.SetGrayStroke(0.8);
end
x += 5;
end
// Draw horizontal text
y := 0;
while y < height do
begin
if y % 10 = 0 and y > 0 then
begin
page.BeginText();
page.MoveTextPos(5, y - 2);
page.ShowText(tostring(y));
page.EndText();
end
y += 5;
end
// Draw vertical text
x := 0;
while x < width do
begin
if x % 50 = 0 and x > 0 then
begin
buf := tostring(x);
page.BeginText();
page.MoveTextPos(x, 5);
page.ShowText(buf);
page.EndText();
page.BeginText();
page.MoveTextPos(x, height - 10);
page.ShowText(buf);
page.EndText();
end
x += 5;
end
page.SetGrayFill(0);
page.SetGrayStroke(0);
End;

793
demo/chinese_font_demo.pdf Normal file
View File

@ -0,0 +1,793 @@
%PDF-1.3
%·¾­ª
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
/PageMode /UseOutlines
/Outlines 28 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 30 0 R 36 0 R 41 0 R 46 0 R 51 0 R 56 0 R 61 0 R 66 0 R ]
/Count 8
>>
endobj
3 0 obj
<<
/Producer (Haru Free PDF Library 2.4.4)
>>
endobj
4 0 obj
<<
/Type /Font
/BaseFont /SimSun
/Subtype /Type0
/Encoding /GBK-EUC-H
/DescendantFonts [ 5 0 R ]
>>
endobj
5 0 obj
<<
/Type /Font
/Subtype /CIDFontType0
/DW 1000
/BaseFont /SimSun
/DW2 [ 880 -1000 ]
/W [ 668 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 696 [ 500 500 500 500 ] 814 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 7716 [ 500 ] ]
/FontDescriptor 6 0 R
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (GB1)
/Supplement 2
>>
>>
endobj
6 0 obj
<<
/Type /FontDescriptor
/FontName /SimSun
/Ascent 859
/Descent -140
/CapHeight 683
/MissingWidth 500
/Flags 7
/FontBBox [ 0 -140 996 855 ]
/ItalicAngle 0
/StemV 78
>>
endobj
7 0 obj
<<
/Type /Font
/BaseFont /SimSun,Bold
/Subtype /Type0
/Encoding /GBK-EUC-H
/DescendantFonts [ 8 0 R ]
>>
endobj
8 0 obj
<<
/Type /Font
/Subtype /CIDFontType0
/DW 1000
/BaseFont /SimSun,Bold
/DW2 [ 880 -1000 ]
/W [ 668 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 696 [ 500 500 500 500 ] 814 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 7716 [ 500 ] ]
/FontDescriptor 9 0 R
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (GB1)
/Supplement 2
>>
>>
endobj
9 0 obj
<<
/Type /FontDescriptor
/FontName /SimSun,Bold
/Ascent 859
/Descent -140
/CapHeight 683
/MissingWidth 500
/Flags 262151
/FontBBox [ 0 -140 996 855 ]
/ItalicAngle 0
/StemV 156
>>
endobj
10 0 obj
<<
/Type /Font
/BaseFont /SimSun,Italic
/Subtype /Type0
/Encoding /GBK-EUC-H
/DescendantFonts [ 11 0 R ]
>>
endobj
11 0 obj
<<
/Type /Font
/Subtype /CIDFontType0
/DW 1000
/BaseFont /SimSun,Italic
/DW2 [ 880 -1000 ]
/W [ 668 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 696 [ 500 500 500 500 ] 814 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 7716 [ 500 ] ]
/FontDescriptor 12 0 R
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (GB1)
/Supplement 2
>>
>>
endobj
12 0 obj
<<
/Type /FontDescriptor
/FontName /SimSun,Italic
/Ascent 859
/Descent -140
/CapHeight 683
/MissingWidth 500
/Flags 71
/FontBBox [ 0 -140 996 855 ]
/ItalicAngle -11
/StemV 78
>>
endobj
13 0 obj
<<
/Type /Font
/BaseFont /SimSun,BoldItalic
/Subtype /Type0
/Encoding /GBK-EUC-H
/DescendantFonts [ 14 0 R ]
>>
endobj
14 0 obj
<<
/Type /Font
/Subtype /CIDFontType0
/DW 1000
/BaseFont /SimSun,BoldItalic
/DW2 [ 880 -1000 ]
/W [ 668 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 696 [ 500 500 500 500 ] 814 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 7716 [ 500 ] ]
/FontDescriptor 15 0 R
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (GB1)
/Supplement 2
>>
>>
endobj
15 0 obj
<<
/Type /FontDescriptor
/FontName /SimSun,BoldItalic
/Ascent 859
/Descent -140
/CapHeight 683
/MissingWidth 500
/Flags 262215
/FontBBox [ 0 -140 996 855 ]
/ItalicAngle -11
/StemV 156
>>
endobj
16 0 obj
<<
/Type /Font
/BaseFont /SimHei
/Subtype /Type0
/Encoding /GBK-EUC-H
/DescendantFonts [ 17 0 R ]
>>
endobj
17 0 obj
<<
/Type /Font
/Subtype /CIDFontType0
/DW 1000
/BaseFont /SimHei
/DW2 [ 880 -1000 ]
/W [ 668 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 696 [ 500 500 500 500 ] 814 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 7716 [ 500 ] ]
/FontDescriptor 18 0 R
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (GB1)
/Supplement 2
>>
>>
endobj
18 0 obj
<<
/Type /FontDescriptor
/FontName /SimHei
/Ascent 859
/Descent -140
/CapHeight 769
/MissingWidth 500
/Flags 5
/FontBBox [ 0 -140 996 855 ]
/ItalicAngle 0
/StemV 78
>>
endobj
19 0 obj
<<
/Type /Font
/BaseFont /SimHei,Bold
/Subtype /Type0
/Encoding /GBK-EUC-H
/DescendantFonts [ 20 0 R ]
>>
endobj
20 0 obj
<<
/Type /Font
/Subtype /CIDFontType0
/DW 1000
/BaseFont /SimHei,Bold
/DW2 [ 880 -1000 ]
/W [ 668 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 696 [ 500 500 500 500 ] 814 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 7716 [ 500 ] ]
/FontDescriptor 21 0 R
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (GB1)
/Supplement 2
>>
>>
endobj
21 0 obj
<<
/Type /FontDescriptor
/FontName /SimHei,Bold
/Ascent 859
/Descent -140
/CapHeight 769
/MissingWidth 500
/Flags 262149
/FontBBox [ 0 -140 996 855 ]
/ItalicAngle 0
/StemV 156
>>
endobj
22 0 obj
<<
/Type /Font
/BaseFont /SimHei,Italic
/Subtype /Type0
/Encoding /GBK-EUC-H
/DescendantFonts [ 23 0 R ]
>>
endobj
23 0 obj
<<
/Type /Font
/Subtype /CIDFontType0
/DW 1000
/BaseFont /SimHei,Italic
/DW2 [ 880 -1000 ]
/W [ 668 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 696 [ 500 500 500 500 ] 814 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 7716 [ 500 ] ]
/FontDescriptor 24 0 R
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (GB1)
/Supplement 2
>>
>>
endobj
24 0 obj
<<
/Type /FontDescriptor
/FontName /SimHei,Italic
/Ascent 859
/Descent -140
/CapHeight 769
/MissingWidth 500
/Flags 69
/FontBBox [ 0 -140 996 855 ]
/ItalicAngle -11
/StemV 78
>>
endobj
25 0 obj
<<
/Type /Font
/BaseFont /SimHei,BoldItalic
/Subtype /Type0
/Encoding /GBK-EUC-H
/DescendantFonts [ 26 0 R ]
>>
endobj
26 0 obj
<<
/Type /Font
/Subtype /CIDFontType0
/DW 1000
/BaseFont /SimHei,BoldItalic
/DW2 [ 880 -1000 ]
/W [ 668 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 696 [ 500 500 500 500 ] 814 [ 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ] 7716 [ 500 ] ]
/FontDescriptor 27 0 R
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (GB1)
/Supplement 2
>>
>>
endobj
27 0 obj
<<
/Type /FontDescriptor
/FontName /SimHei,BoldItalic
/Ascent 859
/Descent -140
/CapHeight 769
/MissingWidth 500
/Flags 262213
/FontBBox [ 0 -140 996 855 ]
/ItalicAngle -11
/StemV 156
>>
endobj
28 0 obj
<<
/Type /Outlines
/First 29 0 R
/Last 29 0 R
/Count 9
>>
endobj
29 0 obj
<<
/Title (Chinese font demo)
/Type /Outlines
/Parent 28 0 R
/First 33 0 R
/Last 69 0 R
/Count 8
>>
endobj
30 0 obj
<<
/Type /Page
/MediaBox [ 0 0 1630 210 ]
/Contents 31 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 35 0 R
/F2 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
31 0 obj
<<
/Length 32 0 R
/Filter [ /FlateDecode ]
>>
stream
xœÝÔKnÛ0€á½N¡e»hCr^$öŠ-’îŠ^¿zxfØÁ ÛÔ/™ò' ü²Å9†ùþcj÷i_IJ|Ÿ>Ý~¾ßþüþ<ßM/[š#—ì翤óü+GN ŒLÌ,œ¹påÆ<C3A5>^y“ Q <E282AC>°ˆd)R¿»ù1! "!£`Æ‚v\pÅ<70>EJ„DÄ$”©ÐÇ- B<06> Âÿ—œ?þô½v\¡Õj u¿‰ôÒ7/}Y—ſѻ¬­ñZYòB ÕX!ÔÖÜÃþ£coW9vi¡¥ëhÁ¥´cËk¿²ß¡¯tìÙÓ*´ýí8jëþJ­ùµ ·Ôs'ݹ,fƒñSÁ(,ÁSÁ€O4Šë}
_iþ;¥ãoc~??e~n=
<EFBFBD>­ÄøHçâÑPzmb-»¥7ÐÞX{+ÚŠ5P¸®e€;PèTºÕ<>2<'{PÞÔAî u<>;HäV»ƒÕÁî`u°;DâQ‡¸CÔ!îÈêÈîÈêÈîÈêÈîÈêÈî(ê(î(ê(î(ê(Ã\¬0LV°Ñ
Ãl®àš} }4‡
Va¨l•‡Z¬º*&e]+­d•†š­60 60 60 646464¶}•éˆç<CB86>íK­Ékò*¯ïÿRfÇ
endstream
endobj
32 0 obj
512
endobj
33 0 obj
<<
/Title (SimSun)
/Type /Outlines
/Parent 29 0 R
/Dest 34 0 R
/Next 39 0 R
>>
endobj
34 0 obj
[ 30 0 R /Fit ]
endobj
35 0 obj
<<
/Type /Font
/BaseFont /Helvetica
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
36 0 obj
<<
/Type /Page
/MediaBox [ 0 0 1630 210 ]
/Contents 37 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 35 0 R
/F2 7 0 R
>>
>>
/Parent 2 0 R
>>
endobj
37 0 obj
<<
/Length 38 0 R
/Filter [ /FlateDecode ]
>>
stream
xœÝÔ]ŠÛ0ÀñwŸÂ<C5B8>-´]Ió%ÁR<C381>ÉB—Ýö©ôúµ<C3BA>ÌŒºGÈCù<>†<mqŽa¾þ˜ÚuÚ±ì/Ó§ËÏ÷ËŸ__Úï·—ÏóõuzÚÒ騷oúšÎMÏ91021³pæÂ•w^xåMDIBÂ"¥Hý~œæG`Ä„€ˆ„Œ‚ VlØqÁ7
)“P¦B<1F> 2ÿo9¿ü‰|î¸êþé¥o^ú².ŠßÑ»¬­ñZYòB ÕX!ÔÖÜÃþ¥co·rœÒBK·«—ÒŽ#oç•ý }¥ãÌž¶P¡íoÇU[÷WjÍ÷6ÜRÏ<52>ôäj°˜ ÆK¢°V<Ð(®×)|£ùÿŽùýü”ùmºLt/d%ßK¶ã=<3D>{CmèM´‰µì‘Þ@xcmì­h+Ö@ àP¸î@u ;PèTÊð;ÙåMäR¹ƒÔAî`u°;XìV»CÔ!îuˆ;D⎬ŽìެŽìެŽìެŽìŽ¢ŽâŽ¢ŽâŽ¢Ž2ÌU°Á
Ãd­0ÌV°á
®ÙÒGs¨`†ÊVy¨Åª«bRÖm¥•¬ÒP³ÕÁfƒÁfƒÁfƒÁ†fÃÁ†fÃÁ†fÃÁ¶¯2ñ²}©5yM^ÅâíþpYÈ»
endstream
endobj
38 0 obj
517
endobj
39 0 obj
<<
/Title (SimSun,Bold)
/Type /Outlines
/Prev 33 0 R
/Parent 29 0 R
/Dest 40 0 R
/Next 44 0 R
>>
endobj
40 0 obj
[ 36 0 R /Fit ]
endobj
41 0 obj
<<
/Type /Page
/MediaBox [ 0 0 1630 210 ]
/Contents 42 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 35 0 R
/F2 10 0 R
>>
>>
/Parent 2 0 R
>>
endobj
42 0 obj
<<
/Length 43 0 R
/Filter [ /FlateDecode ]
>>
stream
xœÝÔÍŽÓ0Àñ{ž"G<>€µ=_¶´<42>Dâ¼}BZ´Ë Ä들<E2809C>³<>ÐC[ç/Çé¯õas óåÇÔ.Ó¾ˆe¿ø>½{z~}úóë×ß__ž¿½Ÿ/?§‡-ÍŽ<E28098>û¶<C3BB>éÜöÈ#3 g.\¹qç…WÞ$H”$ ($,"YŠÔÏÇi~FLˆHÈ(˜±`ņ\q£@!1 e*ôöˆ<><00>€A C<>ðÿóËŸÌÇŽ+´Ú¡B<C2A1>¡î^úæ¥/ëò¦ø½ËÚ¯¡•%/´P<C2B4>BmmÉ=ì_:öv-Ç)-´t½Zp)í8òz^ÙŸÐW:Îìi Úþv\µu¥Ö|oÃ-õÜIO®‹Ù`|W°$
KpW0`…Á<1D>âz™Â'šÿNéø÷˜_ÏO™_¦§‰n…¬ä[ÉVb¼¥sqk¨ ½‰6±h<6F>½(ÜŠW€2À¨tªÝ<>ê@~'û¡¼©ƒÜAê w<>¬v«ƒÝÁê`wˆ¢q‡¨CÜÕÝÕÝÕÝÕÝQÔQÜQÔQÜQÔQ†¹
6Xa˜¬`£†Ù
6\Á5û@úh¬ÂPÙ*µXuULʺ®´Uj¶:ØÀl0ØÀl0ØÀl0ØÐl8ØÐl8ØÐl8ØöU¦#žC¶/µ&¯É«X¼ÞÿqÄÉ<C384>
endstream
endobj
43 0 obj
522
endobj
44 0 obj
<<
/Title (SimSun,Italic)
/Type /Outlines
/Prev 39 0 R
/Parent 29 0 R
/Dest 45 0 R
/Next 49 0 R
>>
endobj
45 0 obj
[ 41 0 R /Fit ]
endobj
46 0 obj
<<
/Type /Page
/MediaBox [ 0 0 1630 210 ]
/Contents 47 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 35 0 R
/F2 13 0 R
>>
>>
/Parent 2 0 R
>>
endobj
47 0 obj
<<
/Length 48 0 R
/Filter [ /FlateDecode ]
>>
stream
xœÝÔÍŽÓ0Àñ{ž"G<>€µ=_¶´<42>Dâܾb…´¨ ¯OÒvfÌ>ÂÚ:9NÕ¨[œc˜Ïß§vžöE,ûÅÓôîôürúóóCûuyúòûëåùÛûùüczØÒ騽oý˜®[9rb`dbfáÌ…+7î¼ðʉ’…„E$Kúù8Í<38>Àˆ  3¬Ø°ã‚+n(R" $"&¡L…^ 0d(þßrýòWêcÇZíP¡ÆP÷‡H/}óÒ—uyUüŽÞem<65>×ÐÊZ¨Æ
¡¶¶äö/{»•ã”Zº]-¸”vy;¯ìOè+´
m;®Úº¿Rk¾·ázî¤'WƒÅl0~S°$
Kð¦`À
ƒ74Šëy
Ÿhþ;¥ãd~¹~Ê|™NÝ YÉ÷­ÄxO׎¡6ô&ÚÄZ
öHo  ¼±6öV´k p(\Êw ¨tª<65>ì‡ò¦r©ƒÜAê w°:جv«ƒÝ!êwˆ¢qGVGvGVGvGVGvGVGvGQGqGQGqGQGæ*Ø`…a²<C2B2>Vf+Øp×ìé£9T°
Ce«<ÔbÕU1)ë¶ÒJVi¨Ùê`³Á`³Á`³Á`C³á`C³á`C³á`ÛW™Žx²}©5yM^Åâíþ"âË
endstream
endobj
48 0 obj
526
endobj
49 0 obj
<<
/Title (SimSun,BoldItalic)
/Type /Outlines
/Prev 44 0 R
/Parent 29 0 R
/Dest 50 0 R
/Next 54 0 R
>>
endobj
50 0 obj
[ 46 0 R /Fit ]
endobj
51 0 obj
<<
/Type /Page
/MediaBox [ 0 0 1630 210 ]
/Contents 52 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 35 0 R
/F2 16 0 R
>>
>>
/Parent 2 0 R
>>
endobj
52 0 obj
<<
/Length 53 0 R
/Filter [ /FlateDecode ]
>>
stream
xœÝÔKnÛ0€á½N¡e»hCr^$ ) ÝÇGh ¤hÖ½~)Ù3ÃæYئ~É”?aà§#®1¬·_K»-cË8ø±|zy}ûþóõózû½<i<>t^2ÎI×ùgŽœ˜Y8sáÊ<C3A1>;o¼ó!A¢$A!aÉR¤~;wó-0bB@DBFÁŒ+6ì¸áŽŠ”ˆI(S¡÷[@„ 
„ÿ/¹~üå{î¸급ôÒ/}Û·wſѻì­ñZÙòFÕX!ÔÖ¶ÜÃøÑ±·{9wi¡¥ûц[iç÷ýʸCßéܳ§#Thãí<jûx¥ÖüÚ†G깓î\ ³ÁøCÁ(,Á‡‚+ >Ð(î·%|¥õïο<C38E>õíú”õÏò²Ð£<C390>•ü(ÙJŒ<4A>t- µ¡7Ñ&ÖR°[z<6D>µ±·¢­X%€@à
P¸Õ<>î@u ;P(Ós²åMäR¹ƒÔAî`u°;XìV»CÔ!îuˆ;D⎬ŽìެŽìެŽìެŽìŽ¢ŽâŽ¢ŽâŽ¢Ž2ÍU°Á
Ód­0ÍV°á
®é£9U°
Se«<ÕbÕU1)ë¾ÒJViªÙêd³Ád³Ád³ÁdC³ádC³ádC³ád«Lg¼†l,µ&¯É«X¼ÿGÆî
endstream
endobj
53 0 obj
511
endobj
54 0 obj
<<
/Title (SimHei)
/Type /Outlines
/Prev 49 0 R
/Parent 29 0 R
/Dest 55 0 R
/Next 59 0 R
>>
endobj
55 0 obj
[ 51 0 R /Fit ]
endobj
56 0 obj
<<
/Type /Page
/MediaBox [ 0 0 1630 210 ]
/Contents 57 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 35 0 R
/F2 19 0 R
>>
>>
/Parent 2 0 R
>>
endobj
57 0 obj
<<
/Length 58 0 R
/Filter [ /FlateDecode ]
>>
stream
xœÝÔKnÛ0€á½N¡e´ Éy@P€¤$t!-<2D>"A—½~$Ù3Ãæ^ئ~P”?càÇ-Î1Ì—ßS»Lû"ýâeúòüúþó×ë×ö÷íåa¾ü™·4G:öí¾¥sÓGN ŒLÌ,œ¹påÆ<C3A5>^y“ Q <E282AC>°ˆd)R§ù1! "!£`Æ‚v\pÅ<70>EJ„DÄ$”©Ðç# B<06> Âÿ[Î/"Ÿ:®Ðj‡
5†º?Dzé—¾¬Ë§âwô.kk¼†V¼ÐB5Vµµ%÷°éØÛµ§´ÐÒõjÁ¥´ãÈëyeB_é8³§-ThûÛqÕÖý•Zó½ ·Ôs'=¹,fƒñ]Á’(,Á]Á€w4Šëe
ßiþ7¥ã¿c~??e~›ž'º²o%[‰ñÎÅ­¡6ô&ÚÄZ
öHo  ¼±6öV´k p(\Êw ¨tª<65>ì‡ò¦r©ƒÜAê w°:جv«ƒÝ!êwˆ¢qGVGvGVGvGVGvGVGvGQGqGQGqGQGæ*Ø`…a²<C2B2>Vf+Øp×ìé£9T°
Ce«<ÔbÕU1)ëºÒJVi¨Ùê`³Á`³Á`³Á`C³á`C³á`C³á`ÛW™ŽxÙ¾Ôš¼&¯bñzÿdäÈ
endstream
endobj
58 0 obj
517
endobj
59 0 obj
<<
/Title (SimHei,Bold)
/Type /Outlines
/Prev 54 0 R
/Parent 29 0 R
/Dest 60 0 R
/Next 64 0 R
>>
endobj
60 0 obj
[ 56 0 R /Fit ]
endobj
61 0 obj
<<
/Type /Page
/MediaBox [ 0 0 1630 210 ]
/Contents 62 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 35 0 R
/F2 22 0 R
>>
>>
/Parent 2 0 R
>>
endobj
62 0 obj
<<
/Length 63 0 R
/Filter [ /FlateDecode ]
>>
stream
xœÝÔÍŠÛ0Àñ»ŸÂÇÚ®¤ù’`)H²M{Þ¼@é¤ìÞ
}ýÚNfFÝGØCù<>†<lqŽa¾üšÚeÚ±ì?¦wO×—/?¯¾þùö|ýþ~¾üž¶4G:vîÛ>¦sÛ#GN ŒLÌ,œ¹påÆ<C3A5>^y“ Q <E282AC>°ˆd)R?§ù1! "!£`Æ‚v\pÅ<70>EJ„DÄ$”©Ðë# B<06> Âÿ[Î/2;®Ðj‡
5†º?Dzé—¾¬Ë«âwô.kk¼†V¼ÐB5Vµµ%÷°éØÛ­§´ÐÒíjÁ¥´ãÈÛyeB_é8³§-ThûÛqÕÖý•Zó½ ·Ôs'=¹,fƒñ%QX7V¼¡Q\/SøDóß)ÿóËù)óóô4ѽ<C391>•|/ÙJŒ÷t.î µ¡7Ñ&ÖR°Gz<6D>µ±·¢­X%€@à
P¸Õ<>î@u ;P(Ãïd?”7u<37>;HäR¹ƒÕÁî`u°;XìQ‡¸CÔ!îuˆ;²:²;²:²;²:²;²:²;Š:Š;Š:Š;Š:Ê0WÁ+ l´Â0[Á†+¸fHÍ¡U*[å¡«®ŠIY·•V²JCÍV˜ ˜ ˜ š š š Û¾ÊtÄsÈö¥Öä5y‹·ûÿfÉp
endstream
endobj
63 0 obj
522
endobj
64 0 obj
<<
/Title (SimHei,Italic)
/Type /Outlines
/Prev 59 0 R
/Parent 29 0 R
/Dest 65 0 R
/Next 69 0 R
>>
endobj
65 0 obj
[ 61 0 R /Fit ]
endobj
66 0 obj
<<
/Type /Page
/MediaBox [ 0 0 1630 210 ]
/Contents 67 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 35 0 R
/F2 25 0 R
>>
>>
/Parent 2 0 R
>>
endobj
67 0 obj
<<
/Length 68 0 R
/Filter [ /FlateDecode ]
>>
stream
xœÝÔÍŽÓ0Àñ{ž"G<>€µ=_¶´<42>DpÞ¾bA*êŠ ¯OÒvfÌ>ÂÚ:9NÕ¨[œc˜O?§všöE,ûÅóôîéüòåÇùCû}yþúçÛåüýý|ú5=liŽtìÞ·~L×­<C397>91021³pæÂ•w^xåMDIBÂ"¥Hý|œæG`Ä„€ˆ„Œ‚ VlØqÁ7
)“P¦B¯<42> 2ÿo¹~ù+õ±ã
­v¨Pc¨ûC¤—¾yé˺¼*~Gï²¶ÆkheÉ -Tc…P[[rû—޽ÝÊqJ -Ý®\J;޼<C5BD>Wö'ô•Ž3{ÚB…¶¿WmÝ_©5ßÛpK=wÒ“«Áb6¿)X…%xS0`…ÁÅõ4…O4ÿ<34>Òñ2¿\?e¾LOÝ YÉ÷­ÄxO׎¡6ô&ÚÄZ
öHo  ¼±6öV´k p(\Êw ¨tª<65>ì‡ò¦r©ƒÜAê w°:جv«ƒÝ!êwˆ¢qGVGvGVGvGVGvGVGvGQGqGQGqGQGæ*Ø`…a²<C2B2>Vf+Øp×ìé£9T°
Ce«<ÔbÕU1)ë¶ÒJVi¨Ùê`³Á`³Á`³Á`C³á`C³á`C³á`ÛW™Žx²}©5yM^Åâíþ­Êñ
endstream
endobj
68 0 obj
526
endobj
69 0 obj
<<
/Title (SimHei,BoldItalic)
/Type /Outlines
/Prev 64 0 R
/Parent 29 0 R
/Dest 70 0 R
>>
endobj
70 0 obj
[ 66 0 R /Fit ]
endobj
xref
0 71
0000000000 65535 f
0000000015 00000 n
0000000104 00000 n
0000000213 00000 n
0000000274 00000 n
0000000389 00000 n
0000001126 00000 n
0000001309 00000 n
0000001429 00000 n
0000002171 00000 n
0000002365 00000 n
0000002489 00000 n
0000003235 00000 n
0000003429 00000 n
0000003557 00000 n
0000004307 00000 n
0000004510 00000 n
0000004627 00000 n
0000005366 00000 n
0000005550 00000 n
0000005672 00000 n
0000006416 00000 n
0000006611 00000 n
0000006735 00000 n
0000007481 00000 n
0000007675 00000 n
0000007803 00000 n
0000008553 00000 n
0000008756 00000 n
0000008830 00000 n
0000008946 00000 n
0000009136 00000 n
0000009729 00000 n
0000009749 00000 n
0000009844 00000 n
0000009876 00000 n
0000009975 00000 n
0000010165 00000 n
0000010763 00000 n
0000010783 00000 n
0000010896 00000 n
0000010928 00000 n
0000011119 00000 n
0000011722 00000 n
0000011742 00000 n
0000011857 00000 n
0000011889 00000 n
0000012080 00000 n
0000012687 00000 n
0000012707 00000 n
0000012826 00000 n
0000012858 00000 n
0000013049 00000 n
0000013641 00000 n
0000013661 00000 n
0000013769 00000 n
0000013801 00000 n
0000013992 00000 n
0000014590 00000 n
0000014610 00000 n
0000014723 00000 n
0000014755 00000 n
0000014946 00000 n
0000015549 00000 n
0000015569 00000 n
0000015684 00000 n
0000015716 00000 n
0000015907 00000 n
0000016514 00000 n
0000016534 00000 n
0000016640 00000 n
trailer
<<
/Root 1 0 R
/Info 3 0 R
/Size 71
>>
startxref
16672
%%EOF

121
demo/chinese_font_demo.tsl Normal file
View File

@ -0,0 +1,121 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "chinese_font_demo.pdf";
output_file := path + separator + output_file;
zw := path + separator + "mbtext" + separator + "cp936.txt";
readfile(rwraw(), alias, zw, 0, 1024*1024, samp_text);
pdf := new PdfFile();
PAGE_HEIGHT := 210;
pdf.SetCompressionMode(TSPdfEnumerations.COMP_ALL);
// declaration for using Japanese font, encoding.
pdf.UseCNSFonts();
pdf.UseCNSEncodings();
detail_font := array();
detail_font[0] := pdf.GetFont("SimSun", "GBK-EUC-H");
detail_font[1] := pdf.GetFont("SimSun,Bold", "GBK-EUC-H");
detail_font[2] := pdf.GetFont("SimSun,Italic", "GBK-EUC-H");
detail_font[3] := pdf.GetFont("SimSun,BoldItalic", "GBK-EUC-H");
detail_font[4] := pdf.GetFont("SimHei", "GBK-EUC-H");
detail_font[5] := pdf.GetFont("SimHei,Bold", "GBK-EUC-H");
detail_font[6] := pdf.GetFont("SimHei,Italic", "GBK-EUC-H");
detail_font[7] := pdf.GetFont("SimHei,BoldItalic", "GBK-EUC-H");
// Set page mode to use outlines.
pdf.SetPageMode(TSPdfEnumerations.PAGE_MODE_USE_OUTLINE);
// create outline root.
root := pdf.CreateOutline(nil, "Chinese font demo", nil);
root.SetOpened(true);
for i := 0 to 7 do
begin
// add a new page object.
page := pdf.AddPage();
// create outline entry
outline := pdf.CreateOutline(root, detail_font[i].GetFontName(), nil);
dst := page.CreateDestination();
outline.SetDestination(dst);
title_font := pdf.GetFont("Helvetica", "");
page.SetFontAndSize(title_font, 10);
page.BeginText();
// move the position of the text to top of the page.
page.MoveTextPos(10, 190);
page.ShowText(detail_font[i].GetFontName());
page.SetFontAndSize(detail_font[i], 15);
page.MoveTextPos(10, -20);
page.ShowText("abcdefghijklmnopqrstuvwxyz");
page.MoveTextPos(0, -20);
page.ShowText("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
page.MoveTextPos(0, -20);
page.ShowText("1234567890");
page.MoveTextPos(0, -20);
page.SetFontAndSize(detail_font[i], 10);
page.ShowText(samp_text);
page.MoveTextPos(0, -18);
page.SetFontAndSize(detail_font[i], 16);
page.ShowText(samp_text);
page.MoveTextPos(0, -27);
page.SetFontAndSize(detail_font[i], 23);
page.ShowText(samp_text);
page.MoveTextPos(0, -36);
page.SetFontAndSize(detail_font[i], 30);
page.ShowText(samp_text);
p := page.GetCurrentTextPos();
// finish to print text.
page.EndText();
page.SetLineWidth(0.5);
x_pos := 20;
for j:=0 to length(samp_text)/2 do
begin
page.MoveTo(x_pos, p[1] - 10);
page.LineTo(x_pos, p[1] - 12);
page.Stroke();
x_pos := x_pos + 30;
end
page.SetWidth(p[0] + 20);
page.SetHeight(PAGE_HEIGHT);
page.MoveTo(10, PAGE_HEIGHT - 25);
page.LineTo(p[0] + 10, PAGE_HEIGHT - 25);
page.Stroke();
page.MoveTo(10, PAGE_HEIGHT - 85);
page.LineTo(p[0] + 10, PAGE_HEIGHT - 85);
page.Stroke();
page.MoveTo(10, p[1] - 12);
page.LineTo(p[0] + 10, p[1] - 12);
page.Stroke();
end
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;

BIN
demo/encoding_list_demo.pdf Normal file

Binary file not shown.

175
demo/encoding_list_demo.tsl Normal file
View File

@ -0,0 +1,175 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "encoding_list_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
// set compression mode
pdf.SetCompressionMode(TSPdfEnumerations.COMP_ALL);
// Set page mode to use outlines.
errcode := pdf.SetPageMode(TSPdfEnumerations.PAGE_MODE_USE_OUTLINE);
// get default font
font := pdf.GetFont("Helvetica", "");
// load font object
afm_file := path + separator + "type1" + separator + "a010013l.afm";
pfb_file := path + separator + "type1" + separator + "a010013l.pfb";
font_name := pdf.LoadType1FontFromFile(alias, afm_file, pfb_file);
// create outline root.
root := pdf.CreateOutline(nil, "Encoding list", nil);
root.SetOpened(true);
encodings := array(
"StandardEncoding",
"MacRomanEncoding",
"WinAnsiEncoding",
"ISO8859-2",
"ISO8859-3",
"ISO8859-4",
"ISO8859-5",
"ISO8859-9",
"ISO8859-10",
"ISO8859-13",
"ISO8859-14",
"ISO8859-15",
"ISO8859-16",
"CP1250",
"CP1251",
"CP1252",
"CP1254",
"CP1257",
"KOI8-R",
"Symbol-Set",
"ZapfDingbats-Set",
// ""
);
page_width := 420;
page_height := 400;
cell_width := 20;
cell_height := 20;
for i:=0 to length(encodings)-1 do
begin
page := pdf.AddPage();
page.SetWidth(page_width);
page.SetHeight(page_height);
outline := pdf.CreateOutline(root, encodings[i], nil);
dst := page.CreateDestination();
dst.SetXYZ(0, page_height, 1);
// pdf.Destination_SetFitB(dst);
outline.SetDestination(dst);
page.SetFontAndSize(font, 15);
DrawGraph(page, page_width, page_height, cell_width, cell_height);
page.BeginText();
page.SetFontAndSize(font, 20);
page.MoveTextPos(40, page_height - 50);
page.ShowText(encodings[i]);
page.ShowText(" Encoding");
page.EndText();
if encodings[i] = "Symbol-Set" then
font2 := pdf.GetFont("Symbol", "");
else if encodings[i] = "ZapfDingbats-Set" then
font2 := pdf.GetFont("ZapfDingbats", "");
else
font2 := pdf.GetFont(font_name, encodings[i]);
page.SetFontAndSize(font2, 14);
DrawFonts(page, page_width, page_height, cell_width, cell_height);
end
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;
Function DrawGraph(page, page_width, page_height, cell_width, cell_height);
Begin
// Draw 16 X 15 cells
// Draw vertical lines.
page.SetLineWidth(0.5);
for i:=0 to 17 do
begin
x := i * cell_width + 40;
page.MoveTo(x, page_height - 60);
page.LineTo(x, 40);
page.Stroke();
if (i > 0 and i <= 16) then
begin
page.BeginText();
page.MoveTextPos(x + 5, page_height - 75);
buf := format("%x", i - 1);
page.ShowText(buf);
page.EndText();
end
end
// Draw horizontal lines.
for i:=0 to 15 do
begin
y := i * cell_height + 40;
page.MoveTo(40, y);
page.LineTo(page_width - 40, y);
page.Stroke();
if (i < 14) then
begin
page.BeginText();
page.MoveTextPos(45, y + 5);
buf := format("%x", 15 - i);
page.ShowText(buf);
page.EndText();
end
end
End;
Function DrawFonts(page, page_width, page_height, cell_width, cell_height);
Begin
page.BeginText();
// Draw all character from 0x20 to 0xFF to the canvas.
for i:=1 to 16 do
begin
for j:=1 to 16 do
begin
y := page_height - 55 - ((i - 1) * cell_height);
x := j * cell_width + 50;
n := (i - 1) * 16 + (j - 1);
if n > 256 then n := n % 256;
buf := chr(n);
if (n >= 32) then
begin
width := page.TextWidth(buf);
d := x - width / 2;
page.TextOut(d, y, buf);
end
end
end
page.EndText();
End;

85
demo/encryption_demo.pdf Normal file
View File

@ -0,0 +1,85 @@
%PDF-1.3
%·¾­ª
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 5 0 R ]
/Count 1
>>
endobj
3 0 obj
<<
/Producer <16E0B3848BC417DE629855C8355DCEAF13E05D63527EAAA96D3EC5>
>>
endobj
4 0 obj
<<
/Type /Font
/BaseFont /Helvetica
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
5 0 obj
<<
/Type /Page
/MediaBox [ 0 0 708.66101 498.89801 ]
/Contents 6 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
6 0 obj
<<
/Length 7 0 R
>>
stream
EŒòfƒÿÌyãZ¢„5Wꪶ·tz÷ãèOa—áë®Ãÿ9pñ_ENˆÝÏN¦ÞpÑÄTeƒZ…,qX$ $¼ã–”6Ò-
endstream
endobj
7 0 obj
79
endobj
8 0 obj
<<
/O <94E809446EA9055A7940156EF5738F0163A1708027C4864F3411C83C0E76A901>
/U <89BC7D9826F5A9515FD3E09DA2E27889DF838F4DE01E53344F8B0A9860F9780A>
/Filter /Standard
/V 1
/R 2
/P -4
>>
endobj
xref
0 9
0000000000 65535 f
0000000015 00000 n
0000000064 00000 n
0000000123 00000 n
0000000211 00000 n
0000000309 00000 n
0000000497 00000 n
0000000630 00000 n
0000000648 00000 n
trailer
<<
/Encrypt 8 0 R
/Root 1 0 R
/Info 3 0 R
/ID [ <9DC8A0D206B4747B6D46A11400186F75> <9DC8A0D206B4747B6D46A11400186F75> ]
/Size 9
>>
startxref
843
%%EOF

41
demo/encryption_demo.tsl Normal file
View File

@ -0,0 +1,41 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "encryption_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
// create default-font
font := pdf.GetFont("Helvetica", "");
// add a new page object.
page := pdf.AddPage();
page.SetSize(TSPdfEnumerations.PAGE_SIZE_B5, TSPdfEnumerations.PAGE_LANDSCAPE);
text := "This is an encrypt document example.";
page.BeginText();
page.SetFontAndSize(font, 20);
tw := page.TextWidth(text);
width := page.GetWidth();
height := page.GetHeight();
page.MoveTextPos((width - tw) / 2, (height - 20) / 2);
page.ShowText(text);
page.EndText();
owner_passwd := "owner";
user_passwd := "user_passwd";
pdf.SetPassword(owner_passwd, user_passwd);
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;

300
demo/font_demo.pdf Normal file
View File

@ -0,0 +1,300 @@
%PDF-1.3
%·¾­ª
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 4 0 R ]
/Count 1
>>
endobj
3 0 obj
<<
/Producer (Haru Free PDF Library 2.4.4)
>>
endobj
4 0 obj
<<
/Type /Page
/MediaBox [ 0 0 595 841 ]
/Contents 5 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 7 0 R
/F2 8 0 R
/F3 9 0 R
/F4 10 0 R
/F5 11 0 R
/F6 12 0 R
/F7 13 0 R
/F8 14 0 R
/F9 15 0 R
/F10 16 0 R
/F11 17 0 R
/F12 18 0 R
/F13 19 0 R
/F14 20 0 R
>>
>>
/Parent 2 0 R
>>
endobj
5 0 obj
<<
/Length 6 0 R
>>
stream
1 w
50 50 495 731 re
S
/F1 24 Tf
BT
238.14799 791 Td
(Font Demo) Tj
ET
BT
/F1 16 Tf
60 761 Td
(\074Standerd Type1 fonts samples\076) Tj
ET
BT
60 736 Td
/F1 9 Tf
(Courier) Tj
0 -18 Td
/F2 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Courier-Bold) Tj
0 -18 Td
/F3 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Courier-Oblique) Tj
0 -18 Td
/F4 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Courier-BoldOblique) Tj
0 -18 Td
/F5 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Helvetica) Tj
0 -18 Td
/F1 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Helvetica-Bold) Tj
0 -18 Td
/F6 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Helvetica-Oblique) Tj
0 -18 Td
/F7 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Helvetica-BoldOblique) Tj
0 -18 Td
/F8 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Times-Roman) Tj
0 -18 Td
/F9 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Times-Bold) Tj
0 -18 Td
/F10 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Times-Italic) Tj
0 -18 Td
/F11 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Times-BoldItalic) Tj
0 -18 Td
/F12 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(Symbol) Tj
0 -18 Td
/F13 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
/F1 9 Tf
(ZapfDingbats) Tj
0 -18 Td
/F14 20 Tf
(abcdefgABCDEFG12345!\043$\045&+-@?) Tj
0 -20 Td
ET
endstream
endobj
6 0 obj
1503
endobj
7 0 obj
<<
/Type /Font
/BaseFont /Helvetica
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
8 0 obj
<<
/Type /Font
/BaseFont /Courier
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
9 0 obj
<<
/Type /Font
/BaseFont /Courier-Bold
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
10 0 obj
<<
/Type /Font
/BaseFont /Courier-Oblique
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
11 0 obj
<<
/Type /Font
/BaseFont /Courier-BoldOblique
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
12 0 obj
<<
/Type /Font
/BaseFont /Helvetica-Bold
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
13 0 obj
<<
/Type /Font
/BaseFont /Helvetica-Oblique
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
14 0 obj
<<
/Type /Font
/BaseFont /Helvetica-BoldOblique
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
15 0 obj
<<
/Type /Font
/BaseFont /Times-Roman
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
16 0 obj
<<
/Type /Font
/BaseFont /Times-Bold
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
17 0 obj
<<
/Type /Font
/BaseFont /Times-Italic
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
18 0 obj
<<
/Type /Font
/BaseFont /Times-BoldItalic
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
19 0 obj
<<
/Type /Font
/BaseFont /Symbol
/Subtype /Type1
>>
endobj
20 0 obj
<<
/Type /Font
/BaseFont /ZapfDingbats
/Subtype /Type1
>>
endobj
xref
0 21
0000000000 65535 f
0000000015 00000 n
0000000064 00000 n
0000000123 00000 n
0000000184 00000 n
0000000506 00000 n
0000002063 00000 n
0000002083 00000 n
0000002181 00000 n
0000002277 00000 n
0000002378 00000 n
0000002483 00000 n
0000002592 00000 n
0000002696 00000 n
0000002803 00000 n
0000002914 00000 n
0000003015 00000 n
0000003115 00000 n
0000003217 00000 n
0000003323 00000 n
0000003391 00000 n
trailer
<<
/Root 1 0 R
/Info 3 0 R
/Size 21
>>
startxref
3465
%%EOF

81
demo/font_demo.tsl Normal file
View File

@ -0,0 +1,81 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
// tsl ./demo/font_demo.tsl --path=/mnt/d/code/tinysoft/Pdf-dev/demo --alias=""
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "font_demo.pdf";
output_file := path + separator + output_file;
page_title := "Font Demo";
pdf := new PdfFile();
// 添加一个页面对象
page := pdf.AddPage();
height := page.GetHeight();
width := page.GetWidth();
// 页面行数
page.SetLineWidth(1);
page.Rectangle(50, 50, width - 100, height - 110);
page.Stroke();
// 页标题
def_font := pdf.GetFont("Helvetica", "");
page.SetFontAndSize(def_font, 24);
tw := page.TextWidth(page_title);
page.BeginText();
page.TextOut((width - tw) / 2, height - 50, page_title);
page.EndText();
// 子标题
page.BeginText();
page.SetFontAndSize(def_font, 16);
page.TextOut(60, height - 80, "<Standerd Type1 fonts samples>");
page.EndText();
page.BeginText();
page.MoveTextPos(60, height - 105);
font_list := array(
"Courier",
"Courier-Bold",
"Courier-Oblique",
"Courier-BoldOblique",
"Helvetica",
"Helvetica-Bold",
"Helvetica-Oblique",
"Helvetica-BoldOblique",
"Times-Roman",
"Times-Bold",
"Times-Italic",
"Times-BoldItalic",
"Symbol",
"ZapfDingbats",
);
samp_text := "abcdefgABCDEFG12345!#$%&+-@?";
for i:=0 to length(font_list)-1 do
begin
page.SetFontAndSize(def_font, 9);
page.ShowText(font_list[i]);
page.MoveTextPos(0, -18);
font := pdf.GetFont(font_list[i], "");
// echo "font = ", font_list[i], "\t err = ", err, "\t font = ", font, "\n";
page.SetFontAndSize(font, 20);
page.ShowText(samp_text);
page.MoveTextPos(0, -20);
end
page.EndText();
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;

1520
demo/grid_sheet_demo.pdf Normal file

File diff suppressed because it is too large Load Diff

136
demo/grid_sheet_demo.tsl Normal file
View File

@ -0,0 +1,136 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "grid_sheet_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
// add a new page object.
page := pdf.AddPage();
page.SetHeight(600);
page.SetWidth(400);
PrintGrid(pdf, page);
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;
Function PrintGrid(pdf, page)
Begin
height := page.GetHeight();
width := page.GetWidth();
font := pdf.GetFont("Helvetica", "");
page.SetFontAndSize(font, 5);
page.SetGrayFill(0.5);
page.SetGrayStroke(0.8);
// Draw horizontal lines
y := 0;
while y < height do
begin
if y % 10 = 0 then
page.SetLineWidth(0.5);
else begin
wid := page.GetWidth();
if wid <> 0.25 then page.SetLineWidth(0.25);
end
page.MoveTo(0, y);
page.LineTo(width, y);
page.Stroke();
if y % 10 = 0 and y > 0 then
begin
page.SetGrayStroke(0.5);
page.MoveTo(0, y);
page.LineTo(5, y);
page.Stroke();
page.SetGrayStroke(0.8);
end
y += 5;
end
// Draw vertical lines
x := 0;
while x < width do
begin
if x % 10 = 0 then
page.SetLineWidth(0.5);
else
if page.GetWidth() <> 0.25 then page.SetLineWidth(0.25);
page.MoveTo(x, 0);
page.LineTo(x, height);
page.Stroke();
if x % 50 = 0 and x > 0 then
begin
page.SetGrayStroke(0.5);
page.MoveTo(x, 0);
page.LineTo(x, 5);
page.Stroke();
page.MoveTo(x, height);
page.LineTo(x, height - 5);
page.Stroke();
page.SetGrayStroke(0.8);
end
x += 5;
end
// Draw horizontal text
y := 0;
while y < height do
begin
if y % 10 = 0 and y > 0 then
begin
page.BeginText();
page.MoveTextPos(5, y - 2);
page.ShowText(tostring(y));
page.EndText();
end
y += 5;
end
// Draw vertical text
x := 0;
while x < width do
begin
if x % 50 = 0 and x > 0 then
begin
buf := tostring(x);
page.BeginText();
page.MoveTextPos(x, 5);
page.ShowText(buf);
page.EndText();
page.BeginText();
page.MoveTextPos(x, height - 10);
page.ShowText(buf);
page.EndText();
end
x += 5;
end
page.SetGrayFill(0);
page.SetGrayStroke(0);
End;

BIN
demo/image_demo.pdf Normal file

Binary file not shown.

173
demo/image_demo.tsl Normal file
View File

@ -0,0 +1,173 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "image_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
pdf.SetCompressionMode(TSPdfEnumerations.COMP_ALL);
// create default-font
font := pdf.GetFont("Helvetica", "");
// add a new page object.
page := pdf.AddPage();
page.SetWidth(550);
page.SetHeight(500);
dst := page.CreateDestination();
dst.SetXYZ(0, page.GetHeight(), 1);
pdf.SetOpenAction(dst);
page.BeginText();
page.SetFontAndSize(font, 20);
page.MoveTextPos(220, page.GetHeight() - 70);
page.ShowText("Image Demo");
page.EndText();
// load image file.
png_path := path + separator + "pngsuite" + separator;
p1 := png_path + "basn3p02.png";
image := pdf.LoadPngImageFromFile("", p1);
// image1 is masked by image2.
image1 := pdf.LoadPngImageFromFile("", p1);
// image2 is a mask image.
p2 := png_path + "basn0g01.png";
image2 := pdf.LoadPngImageFromFile("", p2);
// image3 is a RGB-color image. we use this image for color-mask
p3 := png_path + "maskimage.png";
image3 := pdf.LoadPngImageFromFile("", p3);
iw := image.GetWidth();
ih := image.GetHeight();
page.SetLineWidth(0.5);
x := 100;
y := page.GetHeight() - 150;
// Draw image to the canvas.(normal-mode with actual size.)//
page.DrawImage(image, x, y, iw, ih);
ShowDescription(page, x, y, "Actual Size");
x += 150;
// Scalling image(X direction)
page.DrawImage(image, x, y, iw * 1.5, ih);
ShowDescription(page, x, y, "Scalling image(X direction)");
x += 150;
// Scalling image(Y direction).
page.DrawImage(image, x, y, iw, ih * 1.5);
ShowDescription(page, x, y, "Scalling image(Y direction)");
x := 100;
y -= 120;
// Skewing image.
angle1 := 10;
angle2 := 20;
rad1 := angle1 * 180 * 3.141592;
rad2 := angle2 * 180 * 3.141592;
page.GSave();
page.Concat(iw, tan(rad1) * iw, tan(rad2) * ih, ih, x, y);
page.ExecuteXObject(image);
page.GRestore();
ShowDescription(page, x, y, "Skewing image");
x += 150;
// Rotating image
angle := 30; // rotation of 30 degrees.
rad := angle * 180 * 3.141592; // Calcurate the radian value.
page.GSave();
page.Concat(iw * cos(rad), iw * sin(rad), ih * -sin(rad), ih * cos(rad), x, y);
page.ExecuteXObject(image);
page.GRestore();
ShowDescription(page, x, y, "Rotating image");
x += 150;
// draw masked image.
// Set image2 to the mask image of image1
image1.SetMaskImage(image2);
page.SetRGBFill(0, 0, 0);
page.BeginText();
page.MoveTextPos(x - 6, y + 14);
page.ShowText("MASKMASK");
page.EndText();
page.DrawImage(image1, x - 3, y - 3, iw + 6, ih + 6);
ShowDescription(page, x, y, "masked image");
x := 100;
y -= 120;
// color mask.
page.SetRGBFill(0, 0, 0);
page.BeginText();
page.MoveTextPos(x - 6, y + 14);
page.ShowText("MASKMASK");
page.EndText();
image3.SetColorMask(0, 255, 0, 0, 0, 255);
page.DrawImage(image3, x, y, iw, ih);
ShowDescription(page, x, y, "Color Mask");
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;
Function ShowDescription(page, x, y, text)
Begin
page.MoveTo(x, y - 10);
page.LineTo(x, y + 10);
page.MoveTo(x - 10, y);
page.LineTo(x + 10, y);
page.Stroke();
page.SetFontAndSize(page.GetCurrentFont(), 8);
page.SetRGBFill(0, 0, 0);
page.BeginText();
buf := format("(x=%d,y=%d)", x, y);
page.MoveTextPos(x - page.TextWidth(buf) - 5, y - 10);
page.ShowText(buf);
page.EndText();
page.BeginText();
page.MoveTextPos(x - 20, y - 25);
page.ShowText(text);
page.EndText();
End;

BIN
demo/images/gray.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
demo/images/rgb.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
demo/jpeg_demo.pdf Normal file

Binary file not shown.

66
demo/jpeg_demo.tsl Normal file
View File

@ -0,0 +1,66 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "jpeg_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
pdf.SetCompressionMode(TSPdfEnumerations.COMP_ALL);
// create default-font
font := pdf.GetFont("Helvetica", "");
// add a new page object.
page := pdf.AddPage(pdf);
page.SetWidth(650);
page.SetHeight(500);
height := page.GetHeight();
dst := page.CreateDestination();
dst.SetXYZ(0, height, 1);
pdf.SetOpenAction(dst);
page.BeginText();
page.SetFontAndSize(font, 20);
page.MoveTextPos(220, height - 70);
page.ShowText("Jpeg Demo");
page.EndText();
page.SetFontAndSize(font, 12);
jpeg_path := path + separator + "images" + separator;
DrawImage(pdf, alias, jpeg_path, "rgb.jpg", 70, height - 410, "24bit color image");
DrawImage(pdf, alias, jpeg_path, "gray.jpg", 340, height - 410, "8bit grayscale image");
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;
Function DrawImage(pdf, alias, path, filename, x, y, text);
Begin
filename2 := path + filename;
page := pdf.GetCurrentPage();
image := pdf.LoadJpegImageFromFile(alias, filename2);
// Draw image to the canvas
image_width := image.GetWidth();
image_height := image.GetHeight();
page.DrawImage(image, x, y, image_width, image_height);
// Print the text
page.BeginText();
page.SetTextLeading(16);
page.MoveTextPos(x, y);
page.ShowTextNextLine(filename);
page.ShowTextNextLine(text);
page.EndText();
End;

296
demo/line_demo.pdf Normal file
View File

@ -0,0 +1,296 @@
%PDF-1.3
%·¾­ª
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 5 0 R ]
/Count 1
>>
endobj
3 0 obj
<<
/Producer (Haru Free PDF Library 2.4.4)
>>
endobj
4 0 obj
<<
/Type /Font
/BaseFont /Helvetica
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
5 0 obj
<<
/Type /Page
/MediaBox [ 0 0 595 841 ]
/Contents 6 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
6 0 obj
<<
/Length 7 0 R
>>
stream
1 w
50 50 495 731 re
S
/F1 24 Tf
BT
239.47999 791 Td
(Line Demo) Tj
ET
/F1 10 Tf
0 w
BT
60 760 Td
(line width = 0) Tj
ET
60 755 m
260 755 l
S
1 w
BT
60 730 Td
(line width = 1.0) Tj
ET
60 725 m
260 725 l
S
2 w
BT
60 700 Td
(line width = 2.0) Tj
ET
60 695 m
260 695 l
S
1 w
[3 ] 1 d
BT
60 670 Td
(dash_ptn=\1333, phase=1 -- 2 on, 3 off, 3 on..) Tj
ET
60 665 m
260 665 l
S
[3 7 ] 2 d
BT
60 640 Td
(dash_ptn=\1337, 3, phase=2 -- 5 on, 3 off, 7 on..) Tj
ET
60 635 m
260 635 l
S
[8 7 2 7 ] 0 d
BT
60 610 Td
(dash_ptn=\1338, 7, 2, 7, phase=0) Tj
ET
60 605 m
260 605 l
S
[] 0 d
30 w
0 0.6 0 RG
0 J
BT
60 570 Td
(PDF_BUTT_END) Tj
ET
90 545 m
220 545 l
S
1 J
BT
60 505 Td
(PDF_ROUND_END) Tj
ET
90 480 m
220 480 l
S
2 J
BT
60 440 Td
(PDF_PROJECTING_SQUARE_END) Tj
ET
90 415 m
220 415 l
S
30 w
0 0 0.5 RG
0 j
120 300 m
150 340 l
200 300 l
S
BT
60 360 Td
(PDF_MITER_JOIN) Tj
ET
1 j
120 195 m
160 235 l
200 195 l
S
BT
60 255 Td
(PDF_ROUND_JOIN) Tj
ET
2 j
120 90 m
160 130 l
200 90 l
S
BT
60 150 Td
(PDF_BEVEL_JOIN) Tj
ET
2 w
0 0 0 RG
0.75 0 0 rg
BT
300 760 Td
(Stroke) Tj
ET
300 730 220 25 re
S
BT
300 710 Td
(Fill) Tj
ET
300 680 220 25 re
f
BT
300 660 Td
(Fill then Stroke) Tj
ET
300 630 220 25 re
B
q
BT
300 610 Td
(Clip Rectangle) Tj
ET
300 580 220 25 re
W
S
/F1 13 Tf
BT
290 600 Td
12 TL
(Clip Clip Clip Clip Clip Clip Clip Clip Clip Clip) Tj
(Clip Clip Clip Clip Clip Clip Clip Clip Clip Clip) '
(Clip Clip Clip Clip Clip Clip Clip Clip Clip Clip) '
ET
Q
0 0 0 rg
BT
300 540 Td
(CurveTo2\050x1, y1, x2. y2\051) Tj
ET
BT
335 435 Td
(Current point) Tj
100 90 Td
(\050x1, y1\051) Tj
50 -60 Td
(\050x2, y2\051) Tj
ET
[3 ] 0 d
0.5 w
430 530 m
480 470 l
S
[] 0 d
1.5 w
330 440 m
430 530 480 470 v
S
BT
300 390 Td
(CurveTo3\050x1, y1, x2. y2\051) Tj
ET
BT
335 285 Td
(Current point) Tj
100 90 Td
(\050x1, y1\051) Tj
50 -60 Td
(\050x2, y2\051) Tj
ET
[3 ] 0 d
0.5 w
330 290 m
430 380 l
S
[] 0 d
1.5 w
330 290 m
430 380 480 320 y
S
BT
300 240 Td
(CurveTo\050x1, y1, x2. y2, x3, y3\051) Tj
ET
BT
335 135 Td
(Current point) Tj
100 80 Td
(\050x1, y1\051) Tj
60 -30 Td
(\050x2, y2\051) Tj
-10 -100 Td
(\050x3, y3\051) Tj
ET
[3 ] 0 d
0.5 w
330 140 m
430 220 l
S
490 190 m
480 90 l
S
[] 0 d
1.5 w
330 140 m
430 220 490 190 480 90 c
S
endstream
endobj
7 0 obj
2209
endobj
xref
0 8
0000000000 65535 f
0000000015 00000 n
0000000064 00000 n
0000000123 00000 n
0000000184 00000 n
0000000282 00000 n
0000000458 00000 n
0000002721 00000 n
trailer
<<
/Root 1 0 R
/Info 3 0 R
/Size 8
>>
startxref
2741
%%EOF

290
demo/line_demo.tsl Normal file
View File

@ -0,0 +1,290 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "line_demo.pdf";
output_file := path + separator + output_file;
page_title := "Line Demo";
pdf := new PdfFile();
// 默认字体
font := pdf.GetFont("Helvetica", "");
// 添加页面
page := pdf.AddPage();
// print the lines of the page
page.SetLineWidth(1);
width := page.GetWidth();
height := page.GetHeight();
page.Rectangle(50, 50, width - 100, height - 110);
page.Stroke();
// print the title of the page (with positioning center)
page.SetFontAndSize(font, 24);
tw := page.TextWidth(page_title);
page.BeginText();
page.MoveTextPos((width - tw) / 2, height - 50);
page.ShowText(page_title);
page.EndText();
page.SetFontAndSize(font, 10);
// Draw verious widths of lines
page.SetLineWidth(0);
DrawLine(page, 60, 770, "line width = 0");
page.SetLineWidth(1.0);
DrawLine(page, 60, 740, "line width = 1.0");
page.SetLineWidth(2.0);
DrawLine(page, 60, 710, "line width = 2.0");
// Line dash pattern
DASH_MODE1 := array(3);
DASH_MODE2 := array(3, 7);
DASH_MODE3 := array(8, 7, 2, 7);
page.SetLineWidth(1.0);
page.SetDash(DASH_MODE1, 1, 1);
DrawLine(page, 60, 680, "dash_ptn=[3, phase=1 -- 2 on, 3 off, 3 on..");
page.SetDash(DASH_MODE2, 2, 2);
DrawLine(page, 60, 650, "dash_ptn=[7, 3, phase=2 -- 5 on, 3 off, 7 on..");
page.SetDash(DASH_MODE3, 4, 0);
DrawLine(page, 60, 620, "dash_ptn=[8, 7, 2, 7, phase=0");
page.SetDash(array(), 0, 0);
page.SetLineWidth(30);
page.SetRGBStroke(0.0, 0.6, 0.0);
// Line Cap Style
page.SetLineCap(TSPdfEnumerations.BUTT_END);
DrawLine2(page, 60, 570, "PDF_BUTT_END");
page.SetLineCap(TSPdfEnumerations.ROUND_END);
DrawLine2(page, 60, 505, "PDF_ROUND_END");
page.SetLineCap(TSPdfEnumerations.PROJECTING_SQUARE_END);
DrawLine2(page, 60, 440, "PDF_PROJECTING_SQUARE_END");
// Line Join Style
page.SetLineWidth(30);
page.SetRGBStroke(0.0, 0.0, 0.5);
page.SetLineJoin(TSPdfEnumerations.MITER_JOIN);
page.MoveTo(120, 300);
page.LineTo(150, 340);
page.LineTo(200, 300);
page.Stroke();
page.BeginText();
page.MoveTextPos(60, 360);
page.ShowText("PDF_MITER_JOIN");
page.EndText();
page.SetLineJoin(TSPdfEnumerations.ROUND_JOIN);
page.MoveTo(120, 195);
page.LineTo(160, 235);
page.LineTo(200, 195);
page.Stroke();
page.BeginText();
page.MoveTextPos(60, 255);
page.ShowText("PDF_ROUND_JOIN");
page.EndText();
page.SetLineJoin(TSPdfEnumerations.BEVEL_JOIN);
page.MoveTo(120, 90);
page.LineTo(160, 130);
page.LineTo(200, 90);
page.Stroke();
page.BeginText();
page.MoveTextPos(60, 150);
page.ShowText("PDF_BEVEL_JOIN");
page.EndText();
// Draw Rectangle
page.SetLineWidth(2);
page.SetRGBStroke(0, 0, 0);
page.SetRGBFill(0.75, 0, 0);
DrawRect(page, 300, 770, "Stroke");
page.Stroke();
DrawRect(page, 300, 720, "Fill");
page.Fill();
DrawRect(page, 300, 670, "Fill then Stroke");
page.FillStroke();
// Clip Rect
page.GSave();
DrawRect(page, 300, 620, "Clip Rectangle");
page.Clip();
page.Stroke();
page.SetFontAndSize(font, 13);
page.BeginText();
page.MoveTextPos(290, 600);
page.SetTextLeading(12);
page.ShowText("Clip Clip Clip Clip Clip Clip Clip Clip Clip Clip");
page.ShowTextNextLine("Clip Clip Clip Clip Clip Clip Clip Clip Clip Clip");
page.ShowTextNextLine("Clip Clip Clip Clip Clip Clip Clip Clip Clip Clip");
page.EndText();
page.GRestore();
// Curve Example(CurveTo2)
x := 330;
y := 440;
x1 := 430;
y1 := 530;
x2 := 480;
y2 := 470;
x3 := 480;
y3 := 90;
page.SetRGBFill(0, 0, 0);
page.BeginText();
page.MoveTextPos(300, 540);
page.ShowText("CurveTo2(x1, y1, x2. y2)");
page.EndText();
page.BeginText();
page.MoveTextPos(x + 5, y - 5);
page.ShowText("Current point");
page.MoveTextPos(x1 - x, y1 - y);
page.ShowText("(x1, y1)");
page.MoveTextPos(x2 - x1, y2 - y1);
page.ShowText("(x2, y2)");
page.EndText();
page.SetDash(DASH_MODE1, 1, 0);
page.SetLineWidth(0.5);
page.MoveTo(x1, y1);
page.LineTo(x2, y2);
page.Stroke();
page.SetDash(array(), 0, 0);
page.SetLineWidth(1.5);
page.MoveTo(x, y);
page.CurveTo2(x1, y1, x2, y2);
page.Stroke();
// Curve Example(CurveTo3)
y -= 150;
y1 -= 150;
y2 -= 150;
page.BeginText();
page.MoveTextPos(300, 390);
page.ShowText("CurveTo3(x1, y1, x2. y2)");
page.EndText();
page.BeginText();
page.MoveTextPos(x + 5, y - 5);
page.ShowText("Current point");
page.MoveTextPos(x1 - x, y1 - y);
page.ShowText("(x1, y1)");
page.MoveTextPos(x2 - x1, y2 - y1);
page.ShowText("(x2, y2)");
page.EndText();
page.SetDash(DASH_MODE1, 1, 0);
page.SetLineWidth(0.5);
page.MoveTo(x, y);
page.LineTo(x1, y1);
page.Stroke();
page.SetDash(array(), 0, 0);
page.SetLineWidth(1.5);
page.MoveTo(x, y);
page.CurveTo3(x1, y1, x2, y2);
page.Stroke();
// Curve Example(CurveTo)
y -= 150;
y1 -= 160;
y2 -= 130;
x2 += 10;
page.BeginText();
page.MoveTextPos(300, 240);
page.ShowText("CurveTo(x1, y1, x2. y2, x3, y3)");
page.EndText();
page.BeginText();
page.MoveTextPos(x + 5, y - 5);
page.ShowText("Current point");
page.MoveTextPos(x1 - x, y1 - y);
page.ShowText("(x1, y1)");
page.MoveTextPos(x2 - x1, y2 - y1);
page.ShowText("(x2, y2)");
page.MoveTextPos(x3 - x2, y3 - y2);
page.ShowText("(x3, y3)");
page.EndText();
page.SetDash(DASH_MODE1, 1, 0);
page.SetLineWidth(0.5);
page.MoveTo(x, y);
page.LineTo(x1, y1);
page.Stroke();
page.MoveTo(x2, y2);
page.LineTo(x3, y3);
page.Stroke();
page.SetDash(array(), 0, 0);
page.SetLineWidth(1.5);
page.MoveTo(x, y);
page.CurveTo(x1, y1, x2, y2, x3, y3);
page.Stroke();
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;
Function DrawLine(page, x, y, text);
Begin
page.BeginText();
page.MoveTextPos(x, y - 10);
page.ShowText(text);
page.EndText();
page.MoveTo(x, y - 15);
page.LineTo(x + 200, y - 15);
page.Stroke();
End;
Function DrawLine2(page, x, y, text);
Begin
page.BeginText();
page.MoveTextPos(x, y);
page.ShowText(text);
page.EndText();
page.MoveTo(x + 30, y - 25);
page.LineTo(x + 160, y - 25);
page.Stroke();
End;
Function DrawRect(page, x, y, text);
Begin
page.BeginText();
page.MoveTextPos(x, y - 10);
page.ShowText(text);
page.EndText();
page.Rectangle(x, y - 40, 220, 25);
End;

View File

@ -0,0 +1,449 @@
%PDF-1.3
%·¾­ª
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 5 0 R 8 0 R 11 0 R 14 0 R 17 0 R 20 0 R 23 0 R 26 0 R ]
/Count 8
>>
endobj
3 0 obj
<<
/Producer (Haru Free PDF Library 2.4.4)
>>
endobj
4 0 obj
<<
/Type /Font
/BaseFont /Helvetica
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
5 0 obj
<<
/Type /Page
/MediaBox [ 0 0 300 220 ]
/Contents 6 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
/Annots [ 30 0 R 32 0 R 34 0 R 36 0 R 38 0 R 40 0 R 42 0 R 43 0 R ]
>>
endobj
6 0 obj
<<
/Length 7 0 R
>>
stream
BT
/F1 10 Tf
15 200 Td
(Link Annotation Demo) Tj
ET
BT
/F1 8 Tf
20 180 Td
23 TL
(Jump to Page1\050HilightMode=TSPdfEnumerations.ANNOT_NO_HIGHTLIGHT\051) Tj
T*
(Jump to Page2\050HilightMode=TSPdfEnumerations.ANNOT_INVERT_BOX\051) Tj
T*
(Jump to Page3\050HilightMode=TSPdfEnumerations.ANNOT_INVERT_BORDER\051) Tj
T*
(Jump to Page4\050HilightMode=TSPdfEnumerations.ANNOT_DOWN_APPEARANCE\051) Tj
T*
(Jump to Page5\050dash border\051) Tj
T*
(Jump to Page6\050no border\051) Tj
T*
(Jump to Page7\050bold border\051) Tj
T*
(URI\050) Tj
(http:\057\057sourceforge.net\057projects\057libharu) Tj
(\051) Tj
ET
endstream
endobj
7 0 obj
599
endobj
8 0 obj
<<
/Type /Page
/MediaBox [ 0 0 200 200 ]
/Contents 9 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
9 0 obj
<<
/Length 10 0 R
>>
stream
/F1 20 Tf
BT
50 150 Td
(Page:1) Tj
ET
endstream
endobj
10 0 obj
38
endobj
11 0 obj
<<
/Type /Page
/MediaBox [ 0 0 200 200 ]
/Contents 12 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
12 0 obj
<<
/Length 13 0 R
>>
stream
/F1 20 Tf
BT
50 150 Td
(Page:2) Tj
ET
endstream
endobj
13 0 obj
38
endobj
14 0 obj
<<
/Type /Page
/MediaBox [ 0 0 200 200 ]
/Contents 15 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
15 0 obj
<<
/Length 16 0 R
>>
stream
/F1 20 Tf
BT
50 150 Td
(Page:3) Tj
ET
endstream
endobj
16 0 obj
38
endobj
17 0 obj
<<
/Type /Page
/MediaBox [ 0 0 200 200 ]
/Contents 18 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
18 0 obj
<<
/Length 19 0 R
>>
stream
/F1 20 Tf
BT
50 150 Td
(Page:4) Tj
ET
endstream
endobj
19 0 obj
38
endobj
20 0 obj
<<
/Type /Page
/MediaBox [ 0 0 200 200 ]
/Contents 21 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
21 0 obj
<<
/Length 22 0 R
>>
stream
/F1 20 Tf
BT
50 150 Td
(Page:5) Tj
ET
endstream
endobj
22 0 obj
38
endobj
23 0 obj
<<
/Type /Page
/MediaBox [ 0 0 200 200 ]
/Contents 24 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
24 0 obj
<<
/Length 25 0 R
>>
stream
/F1 20 Tf
BT
50 150 Td
(Page:6) Tj
ET
endstream
endobj
25 0 obj
38
endobj
26 0 obj
<<
/Type /Page
/MediaBox [ 0 0 200 200 ]
/Contents 27 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
27 0 obj
<<
/Length 28 0 R
>>
stream
/F1 20 Tf
BT
50 150 Td
(Page:7) Tj
ET
endstream
endobj
28 0 obj
38
endobj
29 0 obj
[ 8 0 R /Fit ]
endobj
30 0 obj
<<
/Rect [ 16 176 301.19198 190 ]
/Type /Annot
/Subtype /Link
/Dest 29 0 R
/P 5 0 R
/H /N
>>
endobj
31 0 obj
[ 11 0 R /Fit ]
endobj
32 0 obj
<<
/Rect [ 16 153 286.97601 167 ]
/Type /Annot
/Subtype /Link
/Dest 31 0 R
/P 5 0 R
>>
endobj
33 0 obj
[ 14 0 R /Fit ]
endobj
34 0 obj
<<
/Rect [ 16 130 304.30398 144 ]
/Type /Annot
/Subtype /Link
/Dest 33 0 R
/P 5 0 R
/H /O
>>
endobj
35 0 obj
[ 17 0 R /Fit ]
endobj
36 0 obj
<<
/Rect [ 16 107 320.75201 121 ]
/Type /Annot
/Subtype /Link
/Dest 35 0 R
/P 5 0 R
/H /P
>>
endobj
37 0 obj
[ 20 0 R /Fit ]
endobj
38 0 obj
<<
/Rect [ 16 84 125.82399 98 ]
/Type /Annot
/Subtype /Link
/Dest 37 0 R
/P 5 0 R
/Border [ 0 0 1 [ 3 2 ] ]
>>
endobj
39 0 obj
[ 23 0 R /Fit ]
endobj
40 0 obj
<<
/Rect [ 16 61 117.37599 75 ]
/Type /Annot
/Subtype /Link
/Dest 39 0 R
/P 5 0 R
/Border [ 0 0 0 ]
>>
endobj
41 0 obj
[ 26 0 R /Fit ]
endobj
42 0 obj
<<
/Rect [ 16 38 123.59999 52 ]
/Type /Annot
/Subtype /Link
/Dest 41 0 R
/P 5 0 R
/Border [ 0 0 2 ]
>>
endobj
43 0 obj
<<
/Rect [ 16 15 175.16799 29 ]
/Type /Annot
/Subtype /Link
/A <<
/Type /Action
/S /URI
/URI (http:\057\057sourceforge.net\057projects\057libharu)
>>
/P 5 0 R
>>
endobj
xref
0 44
0000000000 65535 f
0000000015 00000 n
0000000064 00000 n
0000000171 00000 n
0000000232 00000 n
0000000330 00000 n
0000000574 00000 n
0000001227 00000 n
0000001246 00000 n
0000001422 00000 n
0000001515 00000 n
0000001534 00000 n
0000001712 00000 n
0000001806 00000 n
0000001825 00000 n
0000002003 00000 n
0000002097 00000 n
0000002116 00000 n
0000002294 00000 n
0000002388 00000 n
0000002407 00000 n
0000002585 00000 n
0000002679 00000 n
0000002698 00000 n
0000002876 00000 n
0000002970 00000 n
0000002989 00000 n
0000003167 00000 n
0000003261 00000 n
0000003280 00000 n
0000003311 00000 n
0000003420 00000 n
0000003452 00000 n
0000003555 00000 n
0000003587 00000 n
0000003696 00000 n
0000003728 00000 n
0000003837 00000 n
0000003869 00000 n
0000003996 00000 n
0000004028 00000 n
0000004147 00000 n
0000004179 00000 n
0000004298 00000 n
trailer
<<
/Root 1 0 R
/Info 3 0 R
/Size 44
>>
startxref
4476
%%EOF

View File

@ -0,0 +1,190 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "link_annotation_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
uri := "http://sourceforge.net/projects/libharu";
// create default-font
font := pdf.GetFont("Helvetica", "");
// create index page
page := pdf.AddPage();
page.SetWidth(300);
page.SetHeight(220);
// Add 7 pages to the document.
page_arr := array();
for i:=0 to 6 do
begin
p := pdf.AddPage();
page_arr[i] := p;
PrintPage(page_arr[i], font, i + 1);
end
page.BeginText();
page.SetFontAndSize(font, 10);
page.MoveTextPos(15, 200);
page.ShowText("Link Annotation Demo");
page.EndText();
// Create Link-Annotation object on index page.
page.BeginText();
page.SetFontAndSize(font, 8);
page.MoveTextPos(20, 180);
page.SetTextLeading(23);
// page1 (ANNOT_NO_HIGHTLIGHT)
tp := page.GetCurrentTextPos();
page.ShowText("Jump to Page1(HilightMode=TSPdfEnumerations.ANNOT_NO_HIGHTLIGHT)");
pos := page.GetCurrentTextPos();
rect := array(tp[0] - 4, tp[1] - 4, pos[0] + 4, pos[1] + 10);
page.MoveToNextLine();
dst := page_arr[0].CreateDestination();
annot := page.CreateLinkAnnot(rect, dst);
annot.LinkAnnotSetHighlightMode(TSPdfEnumerations.ANNOT_NO_HIGHTLIGHT);
// page2(pdf.ANNOT_INVERT_BOX)
tp := page.GetCurrentTextPos();
page.ShowText("Jump to Page2(HilightMode=TSPdfEnumerations.ANNOT_INVERT_BOX)");
pos := page.GetCurrentTextPos();
rect := array(tp[0] - 4, tp[1] - 4, pos[0] + 4, pos[1] + 10);
page.MoveToNextLine();
dst := page_arr[1].CreateDestination();
annot := page.CreateLinkAnnot(rect, dst);
annot.LinkAnnotSetHighlightMode(TSPdfEnumerations.ANNOT_INVERT_BOX);
// page3(pdf.ANNOT_INVERT_BORDER)
tp := page.GetCurrentTextPos();
page.ShowText("Jump to Page3(HilightMode=TSPdfEnumerations.ANNOT_INVERT_BORDER)");
pos := page.GetCurrentTextPos();
pos := page.GetCurrentTextPos();
rect := array(tp[0] - 4, tp[1] - 4, pos[0] + 4, pos[1] + 10);
page.MoveToNextLine();
dst := page_arr[2].CreateDestination();
annot := page.CreateLinkAnnot(rect, dst);
annot.LinkAnnotSetHighlightMode(TSPdfEnumerations.ANNOT_INVERT_BORDER);
// page4(pdf.ANNOT_DOWN_APPEARANCE)
tp := page.GetCurrentTextPos();
page.ShowText("Jump to Page4(HilightMode=TSPdfEnumerations.ANNOT_DOWN_APPEARANCE)");
pos := page.GetCurrentTextPos();
rect := array(tp[0] - 4, tp[1] - 4, pos[0] + 4, pos[1] + 10);
page.MoveToNextLine();
dst := page_arr[3].CreateDestination();
annot := page.CreateLinkAnnot(rect, dst);
annot.LinkAnnotSetHighlightMode(TSPdfEnumerations.ANNOT_DOWN_APPEARANCE);
// page5(dash border)
tp := page.GetCurrentTextPos();
page.ShowText("Jump to Page5(dash border)");
pos := page.GetCurrentTextPos();
rect := array(tp[0] - 4, tp[1] - 4, pos[0] + 4, pos[1] + 10);
page.MoveToNextLine();
dst := page_arr[4].CreateDestination();
annot := page.CreateLinkAnnot(rect, dst);
annot.LinkAnnotSetBorderStyle(1, 3, 2);
// page6(no border)
tp := page.GetCurrentTextPos();
page.ShowText("Jump to Page6(no border)");
pos := page.GetCurrentTextPos();
rect := array(tp[0] - 4, tp[1] - 4, pos[0] + 4, pos[1] + 10);
page.MoveToNextLine();
dst := page_arr[5].CreateDestination();
annot := page.CreateLinkAnnot(rect, dst);
annot.LinkAnnotSetBorderStyle(0, 0, 0);
// page7(bold border)
tp := page.GetCurrentTextPos();
page.ShowText("Jump to Page7(bold border)");
pos := page.GetCurrentTextPos();
rect := array(tp[0] - 4, tp[1] - 4, pos[0] + 4, pos[1] + 10);
page.MoveToNextLine();
dst := page_arr[6].CreateDestination();
annot := page.CreateLinkAnnot(rect, dst);
annot.LinkAnnotSetBorderStyle(2, 0, 0);
// URI link
tp := page.GetCurrentTextPos();
page.ShowText("URI(");
page.ShowText(uri);
page.ShowText(")");
pos := page.GetCurrentTextPos();
rect := array(tp[0] - 4, tp[1] - 4, pos[0] + 4, pos[1] + 10);
page.CreateURILinkAnnot(rect, uri);
page.EndText();
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;
Function PrintPage(page, font, page_num);
Begin
page.SetWidth(200);
page.SetHeight(200);
page.SetFontAndSize(font, 20);
page.BeginText();
page.MoveTextPos(50, 150);
buf := format("Page:%d", page_num);
page.ShowText(buf);
page.EndText();
End;

10
demo/mbtext/EUC_JP.txt Normal file
View File

@ -0,0 +1,10 @@
(こんにちは。)
(おはようございます。)
(こんばんは。)
(はじめまして、どうぞよろしく。)
(お帰りなさい。)
(おやすみなさい。)
(さようなら。)
(お元気ですか。)
(お久しぶり。)
(お邪魔します。)

10
demo/mbtext/cp932.txt Normal file
View File

@ -0,0 +1,10 @@
(こんにちは。)
(おはようございます。)
(こんばんは。)
(はじめまして、どうぞよろしく。)
(お帰りなさい。)
(おやすみなさい。)
(さようなら。)
(お元気ですか。)
(お久しぶり。)
(お邪魔します。)

10
demo/mbtext/cp936.txt Normal file
View File

@ -0,0 +1,10 @@
你好!
早上好!
晚上好!
你好,请多关照。
回来了。
晚安。
再见!
身体好吗?
好久不见!
打扰了。<EFBFBD>

1
demo/mbtext/euc.txt Normal file
View File

@ -0,0 +1 @@
アメンボ赤いなあいうえお。浮き藻に小エビもおよいでる。

1
demo/mbtext/sjis.txt Normal file
View File

@ -0,0 +1 @@
アメンボ赤いなあいうえお。浮き藻に小エビもおよいでる。

211
demo/outline_demo.pdf Normal file
View File

@ -0,0 +1,211 @@
%PDF-1.3
%·¾­ª
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
/PageMode /UseOutlines
/Outlines 14 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 5 0 R 8 0 R 11 0 R ]
/Count 3
>>
endobj
3 0 obj
<<
/Producer (Haru Free PDF Library 2.4.4)
>>
endobj
4 0 obj
<<
/Type /Font
/BaseFont /Helvetica
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
5 0 obj
<<
/Type /Page
/MediaBox [ 0 0 800 800 ]
/Contents 6 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
6 0 obj
<<
/Length 7 0 R
>>
stream
/F1 30 Tf
/F1 20 Tf
BT
30 740 Td
(Page:1) Tj
ET
endstream
endobj
7 0 obj
48
endobj
8 0 obj
<<
/Type /Page
/MediaBox [ 0 0 800 800 ]
/Contents 9 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
9 0 obj
<<
/Length 10 0 R
>>
stream
/F1 30 Tf
/F1 20 Tf
BT
30 740 Td
(Page:2) Tj
ET
endstream
endobj
10 0 obj
48
endobj
11 0 obj
<<
/Type /Page
/MediaBox [ 0 0 800 800 ]
/Contents 12 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
12 0 obj
<<
/Length 13 0 R
>>
stream
/F1 30 Tf
/F1 20 Tf
BT
30 740 Td
(Page:3) Tj
ET
endstream
endobj
13 0 obj
48
endobj
14 0 obj
<<
/Type /Outlines
/First 15 0 R
/Last 15 0 R
/Count 4
>>
endobj
15 0 obj
<<
/Title (OutlineRoot)
/Type /Outlines
/Parent 14 0 R
/First 16 0 R
/Last 18 0 R
/Count 3
>>
endobj
16 0 obj
<<
/Title (page1)
/Type /Outlines
/Parent 15 0 R
/Next 17 0 R
/Dest 19 0 R
>>
endobj
17 0 obj
<<
/Title (page2)
/Type /Outlines
/Prev 16 0 R
/Parent 15 0 R
/Next 18 0 R
/Dest 20 0 R
>>
endobj
18 0 obj
<<
/Title <FEFF00490053004F0038003800350039002D003200200074006500780074002001580142015800B40158013E0158015B01020000015802C7015800B8>
/Type /Outlines
/Prev 17 0 R
/Parent 15 0 R
/Dest 21 0 R
>>
endobj
19 0 obj
[ 5 0 R /XYZ 0 800 1 ]
endobj
20 0 obj
[ 8 0 R /XYZ 0 800 1 ]
endobj
21 0 obj
[ 11 0 R /XYZ 0 800 1 ]
endobj
xref
0 22
0000000000 65535 f
0000000015 00000 n
0000000104 00000 n
0000000176 00000 n
0000000237 00000 n
0000000335 00000 n
0000000511 00000 n
0000000613 00000 n
0000000631 00000 n
0000000807 00000 n
0000000910 00000 n
0000000929 00000 n
0000001107 00000 n
0000001211 00000 n
0000001230 00000 n
0000001304 00000 n
0000001414 00000 n
0000001508 00000 n
0000001615 00000 n
0000001824 00000 n
0000001863 00000 n
0000001902 00000 n
trailer
<<
/Root 1 0 R
/Info 3 0 R
/Size 22
>>
startxref
1942
%%EOF

83
demo/outline_demo.tsl Normal file
View File

@ -0,0 +1,83 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "outline_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
// create default-font
font := pdf.GetFont("Helvetica", "");
// Set page mode to use outlines.
pdf.SetPageMode(TSPdfEnumerations.PAGE_MODE_USE_OUTLINE);
page_arr := array();
// Add 3 pages to the document.
page := pdf.AddPage();
page.SetFontAndSize(font, 30);
PrintPage(page, font, 1);
page_arr[0] := page;
page := pdf.AddPage();
page.SetFontAndSize(font, 30);
PrintPage(page, font, 2);
page_arr[1] := page;
page := pdf.AddPage();
page.SetFontAndSize(font, 30);
PrintPage(page, font, 3);
page_arr[2] := page;
// create outline root.
root := pdf.CreateOutline(nil, "OutlineRoot", nil);
root.SetOpened(true);
outline1 := pdf.CreateOutline(root, "page1", nil);
outline2 := pdf.CreateOutline(root, "page2", nil);
// create outline with test which is ISO8859-2 encoding
outline3 := pdf.CreateOutline(root, "ISO8859-2 text سشصض×طظ", pdf.GetEncoder("ISO8859-2"));
// create destination objects on each pages and link it to outline items.
dst := page_arr[0].CreateDestination();
height := page_arr[0].GetHeight();
dst.SetXYZ(0, height, 1);
outline1.SetDestination(dst);
dst := page_arr[1].CreateDestination();
height := page_arr[1].GetHeight();
dst.SetXYZ(0, height, 1);
outline2.SetDestination(dst);
dst := page_arr[2].CreateDestination();
height := page_arr[2].GetHeight();
dst.SetXYZ(0, height, 1);
outline3.SetDestination(dst);
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;
Function PrintPage(page, font, page_num);
Begin
page.SetWidth(800);
page.SetHeight(800);
page.SetFontAndSize(font, 20);
page.BeginText();
page.MoveTextPos(30, 740);
buf := format("Page:%d", page_num);
page.ShowText(buf);
page.EndText();
End;

86
demo/permission_demo.pdf Normal file
View File

@ -0,0 +1,86 @@
%PDF-1.4
%·¾­ª
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 5 0 R ]
/Count 1
>>
endobj
3 0 obj
<<
/Producer <3B31DBE5EDA2686B1704AC27DC644919F64AED9FC6B8A875483A5D>
>>
endobj
4 0 obj
<<
/Type /Font
/BaseFont /Helvetica
/Subtype /Type1
/Encoding /StandardEncoding
>>
endobj
5 0 obj
<<
/Type /Page
/MediaBox [ 0 0 708.66101 498.89801 ]
/Contents 6 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
>>
endobj
6 0 obj
<<
/Length 7 0 R
>>
stream
õ­<C3B5>ô­©& øš î³nn¯sŠÉϯ<C38F>ækð%G~q/Q­aαÓz®ýAW9="C¸zwa†;ÄʘÅå(÷³èJ²gƒT$S7´é
endstream
endobj
7 0 obj
83
endobj
8 0 obj
<<
/O <566FA873EE33C797CD3B904FDADF814AFA34DF9A38F6ED41B984E2C6DA2AA6F5>
/U <4F1701F7CD1141344D5B4FDD31E86C6200000000000000000000000000000000>
/Filter /Standard
/V 2
/R 3
/Length 128
/P 0
>>
endobj
xref
0 9
0000000000 65535 f
0000000015 00000 n
0000000064 00000 n
0000000123 00000 n
0000000211 00000 n
0000000309 00000 n
0000000497 00000 n
0000000634 00000 n
0000000652 00000 n
trailer
<<
/Encrypt 8 0 R
/Root 1 0 R
/Info 3 0 R
/ID [ <32F1568EF2DBA0E79ADC1FC9A8372131> <32F1568EF2DBA0E79ADC1FC9A8372131> ]
/Size 9
>>
startxref
858
%%EOF

42
demo/permission_demo.tsl Normal file
View File

@ -0,0 +1,42 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "permission_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
// create default-font
font := pdf.GetFont("Helvetica", "");
// add a new page object.
page := pdf.AddPage();
page.SetSize(TSPdfEnumerations.PAGE_SIZE_B5, TSPdfEnumerations.PAGE_LANDSCAPE);
text := "User cannot print and copy this document.";
page.BeginText();
page.SetFontAndSize(font, 20);
tw := page.TextWidth(text);
width := page.GetWidth();
height := page.GetHeight();
page.MoveTextPos((width - tw) / 2, (height - 20) / 2);
page.ShowText(text);
page.EndText();
owner_passwd := "owner";
user_passwd := "";
pdf.SetPassword(owner_passwd, user_passwd);
pdf.SetPermission(TSPdfEnumerations.ENABLE_READ);
pdf.SetEncryptionMode(TSPdfEnumerations.ENCRYPT_R3, 16);
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;

BIN
demo/png_demo.pdf Normal file

Binary file not shown.

82
demo/png_demo.tsl Normal file
View File

@ -0,0 +1,82 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "png_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
pdf.SetCompressionMode(TSPdfEnumerations.COMP_ALL);
// create default-font
font := pdf.GetFont("Helvetica", "");
// add a new page object.
page := pdf.AddPage();
page.SetWidth(550);
page.SetHeight(650);
height := page.GetHeight();
dst := page.CreateDestination();
dst.SetXYZ(0, height, 1);
errcode := pdf.SetOpenAction(dst);
page.BeginText();
page.SetFontAndSize(font, 20);
page.MoveTextPos(220, height - 70);
page.ShowText("Png Demo");
page.EndText();
page.SetFontAndSize(font, 12);
png_path := path + separator + "pngsuite" + separator;
DrawImage(pdf, alias, png_path, "basn0g01.png", 100, height - 150, "1bit grayscale.");
DrawImage(pdf, alias, png_path, "basn0g02.png", 200, height - 150, "2bit grayscale.");
DrawImage(pdf, alias, png_path, "basn0g04.png", 300, height - 150, "4bit grayscale.");
DrawImage(pdf, alias, png_path, "basn0g08.png", 400, height - 150, "8bit grayscale.");
DrawImage(pdf, alias, png_path, "basn2c08.png", 100, height - 250, "8bit color.");
DrawImage(pdf, alias, png_path, "basn2c16.png", 200, height - 250, "16bit color.");
DrawImage(pdf, alias, png_path, "basn3p01.png", 100, height - 350, "1bit pallet.");
DrawImage(pdf, alias, png_path, "basn3p02.png", 200, height - 350, "2bit pallet.");
DrawImage(pdf, alias, png_path, "basn3p04.png", 300, height - 350, "4bit pallet.");
DrawImage(pdf, alias, png_path, "basn3p08.png", 400, height - 350, "8bit pallet.");
DrawImage(pdf, alias, png_path, "basn4a08.png", 100, height - 450, "8bit alpha.");
DrawImage(pdf, alias, png_path, "basn4a16.png", 200, height - 450, "16bit alpha.");
DrawImage(pdf, alias, png_path, "basn6a08.png", 100, height - 550, "8bit alpha.");
DrawImage(pdf, alias, png_path, "basn6a16.png", 200, height - 550, "16bit alpha.");
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;
Function DrawImage(pdf, alias, png_path, filename, x, y, text);
Begin
filename2 := png_path + filename;
page := pdf.GetCurrentPage();
image := pdf.LoadPngImageFromFile(alias, filename2);
// Draw image to the canvas
image_width := image.GetWidth();
image_height := image.GetHeight();
page.DrawImage(image, x, y, image_width, image_height);
// Print the text
page.BeginText();
page.SetTextLeading(16);
page.MoveTextPos(x, y);
page.ShowTextNextLine(filename);
page.ShowTextNextLine(text);
page.EndText();
End;

85
demo/pngsuite/README Normal file
View File

@ -0,0 +1,85 @@
pngsuite
--------
(c) Willem van Schaik, 1999
Permission to use, copy, and distribute these images for any purpose and
without fee is hereby granted.
These 15 images are part of the much larger PngSuite test-set of
images, available for developers of PNG supporting software. The
complete set, available at http:/www.schaik.com/pngsuite/, contains
a variety of images to test interlacing, gamma settings, ancillary
chunks, etc.
The images in this directory represent the basic PNG color-types:
grayscale (1-16 bit deep), full color (8 or 16 bit), paletted
(1-8 bit) and grayscale or color images with alpha channel. You
can use them to test the proper functioning of PNG software.
filename depth type
------------ ------ --------------
basn0g01.png 1-bit grayscale
basn0g02.png 2-bit grayscale
basn0g04.png 4-bit grayscale
basn0g08.png 8-bit grayscale
basn0g16.png 16-bit grayscale
basn2c08.png 8-bit truecolor
basn2c16.png 16-bit truecolor
basn3p01.png 1-bit paletted
basn3p02.png 2-bit paletted
basn3p04.png 4-bit paletted
basn3p08.png 8-bit paletted
basn4a08.png 8-bit gray with alpha
basn4a16.png 16-bit gray with alpha
basn6a08.png 8-bit RGBA
basn6a16.png 16-bit RGBA
Here is the correct result of typing "pngtest -m *.png" in
this directory:
Testing basn0g01.png: PASS (524 zero samples)
Filter 0 was used 32 times
Testing basn0g02.png: PASS (448 zero samples)
Filter 0 was used 32 times
Testing basn0g04.png: PASS (520 zero samples)
Filter 0 was used 32 times
Testing basn0g08.png: PASS (3 zero samples)
Filter 1 was used 9 times
Filter 4 was used 23 times
Testing basn0g16.png: PASS (1 zero samples)
Filter 1 was used 1 times
Filter 2 was used 31 times
Testing basn2c08.png: PASS (6 zero samples)
Filter 1 was used 5 times
Filter 4 was used 27 times
Testing basn2c16.png: PASS (592 zero samples)
Filter 1 was used 1 times
Filter 4 was used 31 times
Testing basn3p01.png: PASS (512 zero samples)
Filter 0 was used 32 times
Testing basn3p02.png: PASS (448 zero samples)
Filter 0 was used 32 times
Testing basn3p04.png: PASS (544 zero samples)
Filter 0 was used 32 times
Testing basn3p08.png: PASS (4 zero samples)
Filter 0 was used 32 times
Testing basn4a08.png: PASS (32 zero samples)
Filter 1 was used 1 times
Filter 4 was used 31 times
Testing basn4a16.png: PASS (64 zero samples)
Filter 0 was used 1 times
Filter 1 was used 2 times
Filter 2 was used 1 times
Filter 4 was used 28 times
Testing basn6a08.png: PASS (160 zero samples)
Filter 1 was used 1 times
Filter 4 was used 31 times
Testing basn6a16.png: PASS (1072 zero samples)
Filter 1 was used 4 times
Filter 4 was used 28 times
libpng passes test
Willem van Schaik
<willem@schaik.com>
October 1999

BIN
demo/pngsuite/basn0g01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

BIN
demo/pngsuite/basn0g02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

BIN
demo/pngsuite/basn0g04.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

BIN
demo/pngsuite/basn0g08.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

BIN
demo/pngsuite/basn0g16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

BIN
demo/pngsuite/basn2c08.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

BIN
demo/pngsuite/basn2c16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

BIN
demo/pngsuite/basn3p01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

BIN
demo/pngsuite/basn3p02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

BIN
demo/pngsuite/basn3p04.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

BIN
demo/pngsuite/basn3p08.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
demo/pngsuite/basn4a08.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

BIN
demo/pngsuite/basn4a16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
demo/pngsuite/basn6a08.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

BIN
demo/pngsuite/basn6a16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
demo/pngsuite/maskimage.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
demo/raw_image_demo.pdf Normal file

Binary file not shown.

87
demo/raw_image_demo.tsl Normal file
View File

@ -0,0 +1,87 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "raw_image_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
pdf.SetCompressionMode(TSPdfEnumerations.COMP_ALL);
// create default-font
font := pdf.GetFont("Helvetica", "");
// add a new page object.
page := pdf.AddPage();
page.SetWidth(172);
page.SetHeight(80);
height := page.GetHeight();
page.BeginText();
page.SetFontAndSize(font, 20);
page.MoveTextPos(220, height - 70);
page.ShowText("Raw Image Demo");
page.EndText();
raw_image_path := path + separator + "rawimage" + separator;
raw_image_file1 := raw_image_path + "32_32_rgb.dat";
// load RGB raw-image file.
image := pdf.LoadRawImageFromFile(alias, raw_image_file1, 32, 32, TSPdfEnumerations.CS_DEVICE_RGB);
x := 20;
y := 20;
// Draw image to the canvas. (normal-mode with actual size.)//
page.DrawImage(image, x, y, 32, 32);
// load GrayScale raw-image file.
raw_image_file2 := raw_image_path + "32_32_gray.dat";
image := pdf.LoadRawImageFromFile(alias, raw_image_file2, 32, 32, TSPdfEnumerations.CS_DEVICE_GRAY);
x := 70;
y := 20;
// Draw image to the canvas. (normal-mode with actual size.)//
page.DrawImage(image, x, y, 32, 32);
// load GrayScale raw-image (1bit) file from memory.
RAW_IMAGE_DATA := array(
"0xff", "0xff", "0xff", "0xfe", "0xff", "0xff", "0xff", "0xfc",
"0xff", "0xff", "0xff", "0xf8", "0xff", "0xff", "0xff", "0xf0",
"0xf3", "0xf3", "0xff", "0xe0", "0xf3", "0xf3", "0xff", "0xc0",
"0xf3", "0xf3", "0xff", "0x80", "0xf3", "0x33", "0xff", "0x00",
"0xf3", "0x33", "0xfe", "0x00", "0xf3", "0x33", "0xfc", "0x00",
"0xf8", "0x07", "0xf8", "0x00", "0xf8", "0x07", "0xf0", "0x00",
"0xfc", "0xcf", "0xe0", "0x00", "0xfc", "0xcf", "0xc0", "0x00",
"0xff", "0xff", "0x80", "0x00", "0xff", "0xff", "0x00", "0x00",
"0xff", "0xfe", "0x00", "0x00", "0xff", "0xfc", "0x00", "0x00",
"0xff", "0xf8", "0x0f", "0xe0", "0xff", "0xf0", "0x0f", "0xe0",
"0xff", "0xe0", "0x0c", "0x30", "0xff", "0xc0", "0x0c", "0x30",
"0xff", "0x80", "0x0f", "0xe0", "0xff", "0x00", "0x0f", "0xe0",
"0xfe", "0x00", "0x0c", "0x30", "0xfc", "0x00", "0x0c", "0x30",
"0xf8", "0x00", "0x0f", "0xe0", "0xf0", "0x00", "0x0f", "0xe0",
"0xe0", "0x00", "0x00", "0x00", "0xc0", "0x00", "0x00", "0x00",
"0x80", "0x00", "0x00", "0x00", "0x00", "0x00", "0x00", "0x00"
);
RAW_IMAGE_DATA := array2str(RAW_IMAGE_DATA, "");
RAW_IMAGE_DATA := DecoderAdixstr(RAW_IMAGE_DATA, 2, 16);
image := pdf.LoadRawImageFromMem(Binary(RAW_IMAGE_DATA), 32, 32, TSPdfEnumerations.CS_DEVICE_GRAY, 1);
x := 120;
y := 20;
// Draw image to the canvas. (normal-mode with actual size.)//
page.DrawImage(image, x, y, 32, 32);
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;

Binary file not shown.

Binary file not shown.

BIN
demo/rawimage/32_32_rgb.dat Normal file

Binary file not shown.

View File

@ -0,0 +1,198 @@
%PDF-1.3
%·¾­ª
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 5 0 R ]
/Count 1
>>
endobj
3 0 obj
<<
/Producer (Haru Free PDF Library 2.4.4)
>>
endobj
4 0 obj
<<
/Type /Font
/BaseFont /Times-Roman
/Subtype /Type1
/Encoding /WinAnsiEncoding
>>
endobj
5 0 obj
<<
/Type /Page
/MediaBox [ 0 0 400 500 ]
/Contents 6 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
/Font <<
/F1 4 0 R
>>
>>
/Parent 2 0 R
/Annots [ 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R 13 0 R 14 0 R 15 0 R ]
>>
endobj
6 0 obj
<<
/Length 7 0 R
>>
stream
BT
/F1 16 Tf
130 450 Td
(Annotation Demo) Tj
ET
/F1 11 Tf
BT
85 380 Td
(Comment Icon.) Tj
ET
BT
245 380 Td
(Key Icon) Tj
ET
BT
85 280 Td
(Note Icon.) Tj
ET
BT
245 280 Td
(Help Icon) Tj
ET
BT
85 180 Td
(NewParagraph Icon) Tj
ET
BT
245 180 Td
(Paragraph Icon) Tj
ET
BT
85 80 Td
(Insert Icon) Tj
ET
BT
245 80 Td
(Text Icon\050ISO8859-2 text\051) Tj
ET
endstream
endobj
7 0 obj
349
endobj
8 0 obj
<<
/Rect [ 50 350 150 400 ]
/Type /Annot
/Subtype /Text
/Contents (Annotation with Comment Icon. \012 This annotation set to be opened initially.)
/P 5 0 R
/Name /Key
>>
endobj
9 0 obj
<<
/Rect [ 210 350 350 400 ]
/Type /Annot
/Subtype /Text
/Contents (Annotation with Key Icon)
/P 5 0 R
/Name /Paragraph
>>
endobj
10 0 obj
<<
/Rect [ 50 250 150 300 ]
/Type /Annot
/Subtype /Text
/Contents (Annotation with Note Icon)
/P 5 0 R
/Name /Note
>>
endobj
11 0 obj
<<
/Rect [ 210 250 350 300 ]
/Type /Annot
/Subtype /Text
/Contents (Annotation with Help Icon)
/P 5 0 R
/Name /Help
>>
endobj
12 0 obj
<<
/Rect [ 50 150 150 200 ]
/Type /Annot
/Subtype /Text
/Contents (Annotation with NewParagraph Icon)
/P 5 0 R
/Name /NewParagraph
>>
endobj
13 0 obj
<<
/Rect [ 210 150 350 200 ]
/Type /Annot
/Subtype /Text
/Contents (Annotation with Paragraph Icon)
/P 5 0 R
/Name /Paragraph
>>
endobj
14 0 obj
<<
/Rect [ 50 50 150 100 ]
/Type /Annot
/Subtype /Text
/Contents (Annotation with Insert Icon)
/P 5 0 R
/Name /Insert
>>
endobj
15 0 obj
<<
/Rect [ 210 50 350 100 ]
/Type /Annot
/Subtype /Text
/Contents <FEFF0041006E006E006F0074006100740069006F006E00200077006900740068002000490053004F00380038003500390020007400650078007400200143000001430000014300000110015B011002DB0143000001430000>
/P 5 0 R
>>
endobj
xref
0 16
0000000000 65535 f
0000000015 00000 n
0000000064 00000 n
0000000123 00000 n
0000000184 00000 n
0000000283 00000 n
0000000525 00000 n
0000000928 00000 n
0000000947 00000 n
0000001132 00000 n
0000001270 00000 n
0000001404 00000 n
0000001539 00000 n
0000001689 00000 n
0000001834 00000 n
0000001971 00000 n
trailer
<<
/Root 1 0 R
/Info 3 0 R
/Size 16
>>
startxref
2244
%%EOF

View File

@ -0,0 +1,112 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "text_annotation_demo.pdf";
output_file := path + separator + output_file;
pdf := new PdfFile();
// use Times-Roman font.
font := pdf.GetFont("Times-Roman", "WinAnsiEncoding");
page := pdf.AddPage();
page.SetWidth(400);
page.SetHeight(500);
page.BeginText();
page.SetFontAndSize(font, 16);
page.MoveTextPos(130, 450);
page.ShowText("Annotation Demo");
page.EndText();
rect1 := array(50, 350, 150, 400);
rect2 := array(210, 350, 350, 400);
rect3 := array(50, 250, 150, 300);
rect4 := array(210, 250, 350, 300);
rect5 := array(50, 150, 150, 200);
rect6 := array(210, 150, 350, 200);
rect7 := array(50, 50, 150, 100);
rect8 := array(210, 50, 350, 100);
annotation := page.CreateTextAnnot(rect1, "Annotation with Comment Icon. \n This annotation set to be opened initially.", nil);
annotation.TextAnnotSetIcon(TSPdfEnumerations.ANNOT_ICON_COMMENT);
annotation.TextAnnotSetOpened(true);
annotation := page.CreateTextAnnot(rect2, "Annotation with Key Icon", nil);
annotation.TextAnnotSetIcon(TSPdfEnumerations.ANNOT_ICON_PARAGRAPH);
annotation := page.CreateTextAnnot(rect3, "Annotation with Note Icon", nil);
annotation.TextAnnotSetIcon(TSPdfEnumerations.ANNOT_ICON_NOTE);
annotation := page.CreateTextAnnot(rect4, "Annotation with Help Icon", nil);
annotation.TextAnnotSetIcon(TSPdfEnumerations.ANNOT_ICON_HELP);
annotation := page.CreateTextAnnot(rect5, "Annotation with NewParagraph Icon", nil);
annotation.TextAnnotSetIcon(TSPdfEnumerations.ANNOT_ICON_NEW_PARAGRAPH);
annotation := page.CreateTextAnnot(rect6, "Annotation with Paragraph Icon", nil);
annotation.TextAnnotSetIcon(TSPdfEnumerations.ANNOT_ICON_PARAGRAPH);
annotation := page.CreateTextAnnot(rect7, "Annotation with Insert Icon", nil);
annotation.TextAnnotSetIcon(TSPdfEnumerations.ANNOT_ICON_INSERT);
encoding := pdf.GetEncoder("ISO8859-2");
page.CreateTextAnnot(rect8, "Annotation with ISO8859 text стужвьы", encoding);
page.SetFontAndSize(font, 11);
page.BeginText();
page.MoveTextPos(rect1[0] + 35, rect1[3] - 20);
page.ShowText("Comment Icon.");
page.EndText();
page.BeginText();
page.MoveTextPos(rect2[0] + 35, rect2[3] - 20);
page.ShowText("Key Icon");
page.EndText();
page.BeginText();
page.MoveTextPos(rect3[0] + 35, rect3[3] - 20);
page.ShowText("Note Icon.");
page.EndText();
page.BeginText();
page.MoveTextPos(rect4[0] + 35, rect4[3] - 20);
page.ShowText("Help Icon");
page.EndText();
page.BeginText();
page.MoveTextPos(rect5[0] + 35, rect5[3] - 20);
page.ShowText("NewParagraph Icon");
page.EndText();
page.BeginText();
page.MoveTextPos(rect6[0] + 35, rect6[3] - 20);
page.ShowText("Paragraph Icon");
page.EndText();
page.BeginText();
page.MoveTextPos(rect7[0] + 35, rect7[3] - 20);
page.ShowText("Insert Icon");
page.EndText();
page.BeginText();
page.MoveTextPos(rect8[0] + 35, rect8[3] - 20);
page.ShowText("Text Icon(ISO8859-2 text)");
page.EndText();
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;

BIN
demo/text_demo.pdf Normal file

Binary file not shown.

389
demo/text_demo.tsl Normal file
View File

@ -0,0 +1,389 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "text_demo.pdf";
output_file := path + separator + output_file;
page_title := "Text Demo";
pdf := new PdfFile();
// set compression mode
pdf.SetCompressionMode(TSPdfEnumerations.COMP_ALL);
// create default-font
font := pdf.GetFont("Helvetica", "");
// add a new page object.
page := pdf.AddPage();
// draw grid to the page
PrintGrid(pdf, page);
width := page.GetWidth();
height := page.GetHeight();
// print the title of the page (with positioning center).
page.SetFontAndSize(font, 24);
tw := page.TextWidth(page_title);
page.BeginText();
page.TextOut((width - tw) / 2, height - 50, page_title);
page.EndText();
page.BeginText();
page.MoveTextPos(60, height - 60);
// font size
fsize := 8;
samp_text := "abcdefgABCDEFG123!#$%&+-@?";
samp_text2 := "The quick brown fox jumps over the lazy dog.";
while (fsize < 60) do
begin
// set style and size of font.
page.SetFontAndSize(font, fsize);
// set the position of the text.
page.MoveTextPos(0, -5 - fsize);
// measure the number of characters which included in the page.
len := page.MeasureText(samp_text, width - 120, false, "");
buf := samp_text[:len];
page.ShowText(buf);
// print the description.
page.MoveTextPos(0, -10);
page.SetFontAndSize(font, 8);
page.ShowText("Fontsize=" $ fsize);
fsize *= 1.5;
end
// font color
page.SetFontAndSize(font, 8);
page.MoveTextPos(0, -30);
page.ShowText("Font color");
page.SetFontAndSize(font, 18);
page.MoveTextPos(0, -20);
len := length(samp_text);
for i:=0 to len - 1 do
begin
r := i / len;
g := 1 - i / len;
buf := samp_text[integer(i + 1)];
page.SetRGBFill(r, g, 0.0);
page.ShowText(buf);
end
page.MoveTextPos(0, -25);
for i:=0 to len - 1 do
begin
r := i / len;
b := 1 - i / len;
buf := samp_text[integer(i + 1)];
page.SetRGBFill(r, 0.0, b);
page.ShowText(buf);
end
page.MoveTextPos(0, -25);
for i:=0 to len - 1 do
begin
b := i / len;
g := 1 - i / len;
buf := samp_text[integer(i + 1)];
page.SetRGBFill(0.0, g, b);
page.ShowText(buf);
end
page.EndText();
ypos := 450;
// Font rendering mode
page.SetFontAndSize(font, 32);
page.SetRGBFill(0.5, 0.5, 0.0);
page.SetLineWidth(1.5);
// PDF_FILL
ShowDescription(page, 60, ypos, "RenderingMode=PDF_FILL");
page.SetTextRenderingMode(TSPdfEnumerations.FILL);
page.BeginText();
page.TextOut(60, ypos, "ABCabc123");
page.EndText();
// PDF_STROKE
ShowDescription(page, 60, ypos - 50, "RenderingMode=PDF_STROKE");
page.SetTextRenderingMode(TSPdfEnumerations.STROKE);
page.BeginText();
page.TextOut(60, ypos - 50, "ABCabc123");
page.EndText();
// PDF_FILL_THEN_STROKE
ShowDescription(page, 60, ypos - 100, "RenderingMode=PDF_FILL_THEN_STROKE");
page.SetTextRenderingMode(TSPdfEnumerations.FILL_THEN_STROKE);
page.BeginText();
page.TextOut(60, ypos - 100, "ABCabc123");
page.EndText();
// PDF_FILL_CLIPPING
ShowDescription(page, 60, ypos - 150, "RenderingMode=PDF_FILL_CLIPPING");
page.GSave();
page.SetTextRenderingMode(TSPdfEnumerations.FILL_CLIPPING);
page.BeginText();
page.TextOut(60, ypos - 150, "ABCabc123");
page.EndText();
ShowStripePattern(page, 60, ypos - 150);
page.GRestore();
// PDF_STROKE_CLIPPING
ShowDescription(page, 60, ypos - 200, "RenderingMode=PDF_STROKE_CLIPPING");
page.GSave();
page.SetTextRenderingMode(TSPdfEnumerations.STROKE_CLIPPING);
page.BeginText();
page.TextOut(60, ypos - 200, "ABCabc123");
page.EndText();
ShowStripePattern(page, 60, ypos - 200);
page.GRestore();
// PDF_FILL_STROKE_CLIPPING
ShowDescription(page, 60, ypos - 250,
"RenderingMode=PDF_FILL_STROKE_CLIPPING");
page.GSave();
page.SetTextRenderingMode(TSPdfEnumerations.FILL_STROKE_CLIPPING);
page.BeginText();
page.TextOut(60, ypos - 250, "ABCabc123");
page.EndText();
ShowStripePattern(page, 60, ypos - 250);
page.GRestore();
// Reset text attributes
page.SetTextRenderingMode(TSPdfEnumerations.FILL);
page.SetRGBFill(0, 0, 0);
page.SetFontAndSize(font, 30);
// Rotating text
angle1 := 30; // A rotation of 30 degrees.
rad1 := angle1 / 180 / 3.141592; // Calcurate the radian value.
ShowDescription(page, 320, ypos - 60, "Rotating text");
page.BeginText();
page.SetTextMatrix(cos(rad1), sin(rad1), -sin(rad1), cos(rad1), 330, ypos - 60);
page.ShowText("ABCabc123");
page.EndText();
// Skewing text.
ShowDescription(page, 320, ypos - 120, "Skewing text");
page.BeginText();
angle1 := 10;
angle2 := 20;
rad1 := angle1 / 180 / 3.141592;
rad2 := angle2 / 180 / 3.141592;
page.SetTextMatrix(1, tan(rad1), tan(rad2), 1, 320, ypos - 120);
page.ShowText("ABCabc123");
page.EndText();
// scaling text (X direction)
ShowDescription(page, 320, ypos - 175, "Scaling text (X direction)");
page.BeginText();
page.SetTextMatrix(1.5, 0, 0, 1, 320, ypos - 175);
page.ShowText("ABCabc12");
page.EndText();
// scaling text (Y direction)
ShowDescription(page, 320, ypos - 250, "Scaling text (Y direction)");
page.BeginText();
page.SetTextMatrix(1, 0, 0, 2, 320, ypos - 250);
page.ShowText("ABCabc123");
page.EndText();
// char spacing, word spacing
ShowDescription(page, 60, 140, "char-spacing 0");
ShowDescription(page, 60, 100, "char-spacing 1.5");
ShowDescription(page, 60, 60, "char-spacing 1.5, word-spacing 2.5");
page.SetFontAndSize(font, 20);
page.SetRGBFill(0.1, 0.3, 0.1);
// char-spacing 0
page.BeginText();
page.TextOut(60, 140, samp_text2);
page.EndText();
// char-spacing 1.5
page.SetCharSpace(1.5);
page.BeginText();
page.TextOut(60, 100, samp_text2);
page.EndText();
// char-spacing 1.5, word-spacing 3.5
page.SetWordSpace(2.5);
page.BeginText();
page.TextOut(60, 60, samp_text2);
page.EndText();
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;
Function ShowStripePattern(page, x, y)
Begin
iy := 0;
text_width := page.TextWidth("ABCabc123");
while iy < 50 do
begin
page.SetRGBStroke(0.0, 0.0, 0.5);
page.SetLineWidth(1);
page.MoveTo(x, y + iy);
page.LineTo(x + text_width, y + iy);
page.Stroke();
iy += 3;
end
page.SetLineWidth(2.5);
End;
Function ShowDescription(page, x, y, text)
Begin
fsize := page.GetCurrentFontSize();
font := page.GetCurrentFont();
rgb := page.GetRGBFill();
page.BeginText();
page.SetRGBFill(0, 0, 0);
page.SetTextRenderingMode(TSPdfEnumerations.FILL);
page.SetFontAndSize(font, 10);
page.TextOut(x, y - 12, text);
page.EndText();
page.SetFontAndSize(font, fsize);
[r, g, b] := rgb;
page.SetRGBFill(r, g, b);
End;
Function PrintGrid(pdf, page)
Begin
height := page.GetHeight();
width := page.GetWidth();
font := pdf.GetFont("Helvetica", "");
page.SetFontAndSize(font, 5);
page.SetGrayFill(0.5);
page.SetGrayStroke(0.8);
// Draw horizontal lines
y := 0;
while y < height do
begin
if y % 10 = 0 then
page.SetLineWidth(0.5);
else begin
wid := page.GetWidth();
if wid <> 0.25 then page.SetLineWidth(0.25);
end
page.MoveTo(0, y);
page.LineTo(width, y);
page.Stroke();
if y % 10 = 0 and y > 0 then
begin
page.SetGrayStroke(0.5);
page.MoveTo(0, y);
page.LineTo(5, y);
page.Stroke();
page.SetGrayStroke(0.8);
end
y += 5;
end
// Draw vertical lines
x := 0;
while x < width do
begin
if x % 10 = 0 then
page.SetLineWidth(0.5);
else
if page.GetWidth() <> 0.25 then page.SetLineWidth(0.25);
page.MoveTo(x, 0);
page.LineTo(x, height);
page.Stroke();
if x % 50 = 0 and x > 0 then
begin
page.SetGrayStroke(0.5);
page.MoveTo(x, 0);
page.LineTo(x, 5);
page.Stroke();
page.MoveTo(x, height);
page.LineTo(x, height - 5);
page.Stroke();
page.SetGrayStroke(0.8);
end
x += 5;
end
// Draw horizontal text
y := 0;
while y < height do
begin
if y % 10 = 0 and y > 0 then
begin
page.BeginText();
page.MoveTextPos(5, y - 2);
page.ShowText(tostring(y));
page.EndText();
end
y += 5;
end
// Draw vertical text
x := 0;
while x < width do
begin
if x % 50 = 0 and x > 0 then
begin
buf := tostring(x);
page.BeginText();
page.MoveTextPos(x, 5);
page.ShowText(buf);
page.EndText();
page.BeginText();
page.MoveTextPos(x, height - 10);
page.ShowText(buf);
page.EndText();
end
x += 5;
end
page.SetGrayFill(0);
page.SetGrayStroke(0);
End;

1744
demo/text_demo2.pdf Normal file

File diff suppressed because it is too large Load Diff

311
demo/text_demo2.tsl Normal file
View File

@ -0,0 +1,311 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "text_demo2.pdf";
output_file := path + separator + output_file;
no := 0;
pdf := new PdfFile();
SAMP_TXT := "The quick brown fox jumps over the lazy dog. ";
// add a new page object.
page := pdf.AddPage();
page.SetSize(TSPdfEnumerations.PAGE_SIZE_A5, TSPdfEnumerations.PAGE_PORTRAIT);
PrintGrid(pdf, page);
height := page.GetHeight();
font := pdf.GetFont("Helvetica", "");
page.SetTextLeading(20);
// TALIGN_LEFT
left := 25;
top := 545;
right := 200;
bottom := top - 40;
page.Rectangle(left, bottom, right - left, top - bottom);
page.Stroke();
page.BeginText();
page.SetFontAndSize(font, 10);
page.TextOut(left, top + 3, "TSPdfEnumerations.TALIGN_LEFT");
page.SetFontAndSize(font, 13);
page.TextRect(left, top, right, bottom, SAMP_TXT, TSPdfEnumerations.TALIGN_LEFT, "");
page.EndText();
// TALIGN_RIGTH
left := 220;
right := 395;
page.Rectangle(left, bottom, right - left, top - bottom);
page.Stroke();
page.BeginText();
page.SetFontAndSize(font, 10);
page.TextOut(left, top + 3, "TSPdfEnumerations.TALIGN_RIGTH");
page.SetFontAndSize(font, 13);
page.TextRect(left, top, right, bottom, SAMP_TXT, TSPdfEnumerations.TALIGN_RIGHT, "");
page.EndText();
// TALIGN_CENTER
left := 25;
top := 475;
right := 200;
bottom := top - 40;
page.Rectangle(left, bottom, right - left, top - bottom);
page.Stroke();
page.BeginText();
page.SetFontAndSize(font, 10);
page.TextOut(left, top + 3, "TSPdfEnumerations.TALIGN_CENTER");
page.SetFontAndSize(font, 13);
page.TextRect(left, top, right, bottom, SAMP_TXT, TSPdfEnumerations.TALIGN_CENTER, "");
page.EndText();
// TALIGN_JUSTIFY
left := 220;
right := 395;
page.Rectangle(left, bottom, right - left, top - bottom);
page.Stroke();
page.BeginText();
page.SetFontAndSize(font, 10);
page.TextOut(left, top + 3, "TSPdfEnumerations.TALIGN_JUSTIFY");
page.SetFontAndSize(font, 13);
page.TextRect(left, top, right, bottom, SAMP_TXT, TSPdfEnumerations.TALIGN_JUSTIFY, "");
page.EndText();
// Skewed coordinate system
page.GSave();
angle1 := 5;
angle2 := 10;
rad1 := angle1 / 180 * 3.141592;
rad2 := angle2 / 180 * 3.141592;
page.Concat(1, tan(rad1), tan(rad2), 1, 25, 350);
left := 0;
top := 40;
right := 175;
bottom := 0;
page.Rectangle(left, bottom, right - left, top - bottom);
page.Stroke();
page.BeginText();
page.SetFontAndSize(font, 10);
page.TextOut(left, top + 3, "Skewed coordinate system");
page.SetFontAndSize(font, 13);
page.TextRect(left, top, right, bottom, SAMP_TXT, TSPdfEnumerations.TALIGN_LEFT, "");
page.EndText();
page.GRestore();
// Rotated coordinate system
page.GSave();
angle1 := 5;
rad1 := angle1 / 180 * 3.141592;
page.Concat(cos(rad1), sin(rad1), -sin(rad1), cos(rad1), 220, 350);
left := 0;
top := 40;
right := 175;
bottom := 0;
page.Rectangle(left, bottom, right - left, top - bottom);
page.Stroke();
page.BeginText();
page.SetFontAndSize(font, 10);
page.TextOut(left, top + 3, "Rotated coordinate system");
page.SetFontAndSize(font, 13);
page.TextRect(left, top, right, bottom, SAMP_TXT, TSPdfEnumerations.TALIGN_LEFT, "");
page.EndText();
page.GRestore();
// text along a circle
page.SetGrayStroke(0);
page.Circle(210, 190, 145);
page.Circle(210, 190, 113);
page.Stroke();
angle1 := 360 /(length(SAMP_TXT));
angle2 := 180;
page.BeginText();
font := pdf.GetFont("Courier-Bold", "");
page.SetFontAndSize(font, 30);
for i:=0 to length(SAMP_TXT)-1 do
begin
rad1 := (angle2 - 90) / 180 * 3.141592;
rad2 := angle2 / 180 * 3.141592;
x := 210 + cos(rad2) * 122;
y := 190 + sin(rad2) * 122;
page.SetTextMatrix(cos(rad1), sin(rad1), -sin(rad1), cos(rad1), x, y);
page.ShowText(SAMP_TXT[i+1]);
angle2 -= angle1;
end
page.EndText();
// save the document to a file
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;
Function PrintText(page, no)
Begin
point := page.GetCurrentTextPos();
no++;
buf := format("[.%d%0.2f %0.2f%]", no, point[0], point[1]);
page.ShowText(buf);
End
Function PrintGrid(pdf, page)
Begin
height := page.GetHeight();
width := page.GetWidth();
font := pdf.GetFont("Helvetica", "");
page.SetFontAndSize(font, 5);
page.SetGrayFill(0.5);
page.SetGrayStroke(0.8);
// Draw horizontal lines
y := 0;
while y < height do
begin
if y % 10 = 0 then
page.SetLineWidth(0.5);
else begin
wid := page.GetWidth();
if wid <> 0.25 then page.SetLineWidth(0.25);
end
page.MoveTo(0, y);
page.LineTo(width, y);
page.Stroke();
if y % 10 = 0 and y > 0 then
begin
page.SetGrayStroke(0.5);
page.MoveTo(0, y);
page.LineTo(5, y);
page.Stroke();
page.SetGrayStroke(0.8);
end
y += 5;
end
// Draw vertical lines
x := 0;
while x < width do
begin
if x % 10 = 0 then
page.SetLineWidth(0.5);
else begin
wid := page.GetWidth();
if wid <> 0.25 then page.SetLineWidth(0.25);
end
page.MoveTo(x, 0);
page.LineTo(x, height);
page.Stroke();
if x % 50 = 0 and x > 0 then
begin
page.SetGrayStroke(0.5);
page.MoveTo(x, 0);
page.LineTo(x, 5);
page.Stroke();
page.MoveTo(x, height);
page.LineTo(x, height - 5);
page.Stroke();
page.SetGrayStroke(0.8);
end
x += 5;
end
// Draw horizontal text
y := 0;
while y < height do
begin
if y % 10 = 0 and y > 0 then
begin
page.BeginText();
page.MoveTextPos(5, y - 2);
page.ShowText(tostring(y));
page.EndText();
end
y += 5;
end
// Draw vertical text
x := 0;
while x < width do
begin
if x % 50 = 0 and x > 0 then
begin
buf := tostring(x);
page.BeginText();
page.MoveTextPos(x, 5);
page.ShowText(buf);
page.EndText();
page.BeginText();
page.MoveTextPos(x, height - 10);
page.ShowText(buf);
page.EndText();
end
x += 5;
end
page.SetGrayFill(0);
page.SetGrayStroke(0);
End;

Binary file not shown.

BIN
demo/ttfont/simhei.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
demo/ttfont_demo.pdf Normal file

Binary file not shown.

91
demo/ttfont_demo.tsl Normal file
View File

@ -0,0 +1,91 @@
Uses TSPdfEnumerations;
{$IFDEF LINUX}
separator := "/";
{$ELSE}
separator := "\\";
{$ENDIF}
alias := "";
path := "";
InitCmdParams(alias, path);
output_file := "ttfont_demo.pdf";
output_file := path + separator + output_file;
SAMP_TXT := "这是中文";
pdf := new PdfFile();
// declaration for using Chinese encoding.
pdf.UseUTFEncodings();
pdf.SetCompressionMode(TSPdfEnumerations.COMP_ALL);
// load ttc file
ttf_file := path + separator + "ttfont" + separator + "simhei.ttf";
detail_font_name := pdf.LoadTTFontFromFile(alias, ttf_file, true);
// add a new page object.
page := pdf.AddPage();
title_font := pdf.GetFont("Helvetica", "");
detail_font := pdf.GetFont(detail_font_name, "UTF-8");
page.SetFontAndSize(title_font, 10);
page.BeginText();
// move the position of the text to top of the page.
page.MoveTextPos(10, 190);
page.ShowText(detail_font_name);
page.ShowText("(");
encoding_name := detail_font.GetEncodingName();
page.ShowText(encoding_name);
page.ShowText(")");
page.SetFontAndSize(detail_font, 15);
page.MoveTextPos(10, -20);
page.ShowText("abcdefghijklmnopqrstuvwxyz");
page.MoveTextPos(0, -20);
page.ShowText("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
page.MoveTextPos(0, -20);
page.ShowText("1234567890");
page.MoveTextPos(0, -20);
page.SetFontAndSize(detail_font, 10);
page.ShowText(SAMP_TXT);
page.MoveTextPos(0, -18);
page.SetFontAndSize(detail_font, 16);
page.ShowText(SAMP_TXT);
page.MoveTextPos(0, -27);
page.SetFontAndSize(detail_font, 23);
page.ShowText(SAMP_TXT);
page.MoveTextPos(0, -36);
page.SetFontAndSize(detail_font, 30);
page.ShowText(SAMP_TXT);
page.MoveTextPos(0, -36);
pw := page.TextWidth(SAMP_TXT);
page_height := 210;
page_width := pw + 40;
page.SetWidth(page_width);
page.SetHeight(page_height);
// finish to print text.
page.EndText();
page.SetLineWidth(0.5);
page.MoveTo(10, page_height - 25);
page.LineTo(page_width - 10, page_height - 25);
page.Stroke();
page.MoveTo(10, page_height - 85);
page.LineTo(page_width - 10, page_height - 85);
page.Stroke();
err := pdf.SaveToFile(alias, output_file);
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
return;

340
demo/type1/COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

54
demo/type1/README Normal file
View File

@ -0,0 +1,54 @@
This is release 1.0.7pre22 of Valek Filippov's improved versions of the URW
type 1 font collection, repackaged for distribution with Ghostscript.
Cyrillized free URW fonts.
These fonts were made from the free URW fonts distributed with ghostscript.
There are NO changes in the latin part of them (I hope).
Cyrillic glyphs were added by copying suitable latin ones
and painting oulines of unique cyrillic glyphs in same style as the others.
For all modification pfaedit was used.
The license for result is (of course) same as for original fonts,
i.e. GPL with an exception that you can put these fonts in your own non-GPLed
documents. (Looks like LGPL from my point of view =).
The "sources" of these fonts in the native pfaedit format are available
at ftp://ftp.gnome.ru/fonts/sources
The great font editor pfaedit is available at http://pfaedit.sf.net.
That page also includes some links to fonts created by
George Williams -- the author of pfaedit.
Acknowledgements:
I would like to thank George Williams, the pfaedit's author and developer.
He is the most bug-reporter/feature-requester friendly developer
I ever saw in my not so short life. At some moment in the future
I must write a book about him: "George Williams and my best experience
in bug-reporting." George also greatly helped me bug-hunting these fonts,
explained to me some very important things about fonts and font design,
quickly adopted pfaedit to my needs (or pointed me to The Right Place in
documentation where I found better way of doing things).
I would like to thank Alexey Novodvorsky (aka AEN), who
pointed me to pfaedit and George Williams' fonts, explained
The Task to me. He is also one of the main participators in the
development of Sysiphus -- free repository of free software.
I didn't loose my time for compiling/installing and supporting
my linux box coz I used the result of Sysiphus developers' works.
I would like to thank Sergey Vlasov, who tested these fonts and reported
about bugs. Also he help me to make some bug-reports to George about
pfaedit bugs.
I would like Dmitry 40in, who did big QA for some font outlines, drawn some glyphs,
and explain some The Truths for me.
I would like to thank Vlad Harchev (aka hvv), who
proofread this text for me.
Also I have to thank RMS for GPL and URW for releasing the fonts
under it.
Thank you very much!
Valek Filippov frob@df.ru
(C)opyLeft 2001

1569
demo/type1/a010013l.afm Normal file

File diff suppressed because it is too large Load Diff

BIN
demo/type1/a010013l.pfb Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.