📄 ubasepdfdoc.pas
字号:
FPageFontType := pftHelvetica; //use Arial for headers and footers
FPageFontSize := FNormalFontSize; //and the same size of the font
FPageFontStyle := []; //no special style
FLinkColor := clGreen; //use green color for links inside this file
FExternLinkColor := clBlue; //blue links to the WWW
FFileLinkColor := clNavy; //dark blue links to files
FInterpolateImages := True; //interpolate images
FMaxImageScale := 2.5; //don't make images too big
//create list of annotations (links) in current line
FCurrentLineAnnotations := TStringList.Create;
//create list for images
FImagePaths := TStringList.Create;
//set format (intermediate code) for abstract icons
FCommentFormats.FAbstractIconText := InternFormatCharacter +
InternFormatSymbol + Char(sAbstract);
end;
{Destroys the generator object. }
destructor TBasePDFDoc.Destroy;
var i :Integer;
begin
FreeOutline(FOutlineRoot.First); //free the outline
FImagePaths.Free; //free list for images
for i := 0 to FCurrentLineAnnotations.Count - 1 do //delete all annotations
Dispose(PAnnotation(Pointer(FCurrentLineAnnotations.Objects[i])));
FCurrentLineAnnotations.Free; //and the list
inherited Destroy; //free the generator object
end;
{Will be called for all reserved words. They are all formatted in a bold font,
but "string" will just be replaced with a not bold "String".
~param Word a string of one ore more reserved words
~result Word formatted as reserved words }
function TBasePDFDoc.ReservedWord(const Word: String): String;
begin
if Word = 'string' then //is string?
Result := 'String' //use this upper case variant, not bold
else
Result := InternFormatCharacter + InternFormatBold + Word +
InternFormatEndCharacter; //format the word bold
end;
{Returns the number of available options in generators of this class.
~result the number of available "expert"-options
~see GetOptionDescription
~see GetOption
~see SetOption }
class function TBasePDFDoc.GetOptionCount: Cardinal;
begin
Result := inherited GetOptionCount + 17;
end;
{Gets a description of an "expert"-option.
~param Index index of the option to get data of
~param Desc out: the description of the option (name, type, default value,
etc.)
~see GetOptionCount }
class procedure TBasePDFDoc.GetOptionDescription(Index: Cardinal;
var Desc: TOptionDescription);
var PreOptionCount :Cardinal; //number of options in parent class
begin
PreOptionCount := inherited GetOptionCount; //get number of options in parent
if Index < PreOptionCount then //an option in the parent class?
inherited GetOptionDescription(Index, Desc) //forward to parent's method
else
begin
ClearDescription(Desc); //clear structure
case Index - PreOptionCount of //depending on index of option
0: begin //set the values describing the option
Desc.Name := 'UseSansSerifFont';
Desc.Category := 'Generation.Fonts';
Desc.Description := 'Uses the font Arial/Helvetica instead of Times New Roman.';
Desc.DataType := otBoolean;
Desc.DefaultValue.BoolData := False;
end;
1: begin
Desc.Name := 'FontSize';
Desc.Category := 'Generation.Fonts';
Desc.Description := 'Size of the font to use in points.';
Desc.DataType := otReal;
Desc.MinReal := 0.001;
Desc.MaxReal := 100;
Desc.DefaultValue.RealData := 10;
end;
2: begin
Desc.Name := 'LineDistanceScale';
Desc.Category := 'Generation.Fonts';
Desc.Description := 'Factor of the size of the current font to get the distance to the next line.';
Desc.DataType := otReal;
Desc.MinReal := 0.8;
Desc.MaxReal := 5;
Desc.DefaultValue.RealData := 7 / 6;
end;
3: begin
Desc.Name := 'LinkColor';
Desc.Category := 'Generation.Fonts';
Desc.Description := 'Color of links (inside the file). Please enter RGB-Value.';
Desc.DataType := otInteger;
Desc.MinInt := 0;
Desc.MaxInt := $FFFFFF;
Desc.DefaultValue.IntData := clGreen;
end;
4: begin
Desc.Name := 'ExternLinkColor';
Desc.Category := 'Generation.Fonts';
Desc.Description := 'Color of links to the Word Wide Web. Please enter RGB-Value.';
Desc.DataType := otInteger;
Desc.MinInt := 0;
Desc.MaxInt := $FFFFFF;
Desc.DefaultValue.IntData := clBlue;
end;
5: begin
Desc.Name := 'FileLinkColor';
Desc.Category := 'Generation.Fonts';
Desc.Description := 'Color of links (to other files). Please enter RGB-Value.';
Desc.DataType := otInteger;
Desc.MinInt := 0;
Desc.MaxInt := $FFFFFF;
Desc.DefaultValue.IntData := clNavy;
end;
6: begin
Desc.Name := 'PageMarkingFont';
Desc.Category := 'Generation.Fonts';
Desc.Description := 'Use the font Courier, Arial / Helvetica or Times New Roman when printing number of pages etc..';
Desc.DataType := otEnumeration;
Desc.EnumNames := PageMarkingFontEnumerationList;
Desc.DefaultValue.EnumData := 2;
end;
7: begin
Desc.Name := 'PageMarkingFontSize';
Desc.Category := 'Generation.Fonts';
Desc.Description := 'Size of the font to use when printing number of page etc..';
Desc.DataType := otReal;
Desc.MinReal := 0.001;
Desc.MaxReal := 100;
Desc.DefaultValue.RealData := 10;
end;
8: begin
Desc.Name := 'PageMarkingFontStyle';
Desc.Category := 'Generation.Fonts';
Desc.Description := 'Style of the font to use when printing number of page etc..';
Desc.DataType := otEnumeration;
Desc.EnumNames := PageMarkingFontStyleEnumerationList;
Desc.DefaultValue.EnumData := 0;
end;
9: begin
Desc.Name := 'PageWidth';
Desc.Category := 'Generation.Page';
Desc.Description := 'Width of the pages in the file in centimeters.';
Desc.DataType := otReal;
Desc.MinReal := 0.5;
Desc.MaxReal := 100000;
Desc.DefaultValue.RealData := 21;
end;
10: begin
Desc.Name := 'PageHeight';
Desc.Category := 'Generation.Page';
Desc.Description := 'Height of the pages in the file in centimeters.';
Desc.DataType := otReal;
Desc.MinReal := 0.5;
Desc.MaxReal := 100000;
Desc.DefaultValue.RealData := 29.7;
end;
11: begin
Desc.Name := 'LeftMargin';
Desc.Category := 'Generation.Page';
Desc.Description := 'Margin on the left of the page, where no text is written.';
Desc.DataType := otReal;
Desc.MinReal := -0.5;
Desc.MaxReal := 10000;
Desc.DefaultValue.RealData := 3;
end;
12: begin
Desc.Name := 'RightMargin';
Desc.Category := 'Generation.Page';
Desc.Description := 'Margin on the right of the page, where no text is written.';
Desc.DataType := otReal;
Desc.MinReal := -0.5;
Desc.MaxReal := 10000;
Desc.DefaultValue.RealData := 3;
end;
13: begin
Desc.Name := 'TopMargin';
Desc.Category := 'Generation.Page';
Desc.Description := 'Margin on the top of the page, where no text is written.';
Desc.DataType := otReal;
Desc.MinReal := -0.5;
Desc.MaxReal := 10000;
Desc.DefaultValue.RealData := 3;
end;
14: begin
Desc.Name := 'BottomMargin';
Desc.Category := 'Generation.Page';
Desc.Description := 'Margin on the bottom of the page, where no text is written.';
Desc.DataType := otReal;
Desc.MinReal := -0.5;
Desc.MaxReal := 10000;
Desc.DefaultValue.RealData := 3;
end;
15: begin
Desc.Name := 'InterpolateImages';
Desc.Category := 'Generation';
Desc.Description := 'If the images should be shown interpolated (smoother) by the viewer when showing.';
Desc.DataType := otBoolean;
Desc.DefaultValue.BoolData := True;
end;
16: begin
Desc.Name := 'MaxImageScale';
Desc.Category := 'Generation';
Desc.Description := 'Maximimum zoom/scale factor of images.';
Desc.DataType := otReal;
Desc.DefaultValue.RealData := 2.5;
end;
else
assert(Index >= GetOptionCount);
raise EInvalidOption.Create('Invalid index for option supplied!');
end;
end;
end;
{Gets the value of an option. Call ~[link GetOptionDescription] to get the type
and the meaning of the option.
~param Index index of the option to get the value of
~result the value of the option
~see GetOptionCount
~see GetOptionDescription
~see SetOption }
function TBasePDFDoc.GetOption(Index: Cardinal): TOptionValue;
var PreOptionCount :Cardinal; //number of options in parent class
begin
PreOptionCount := inherited GetOptionCount; //get number of options in parent
if Index < PreOptionCount then //an option in the parent class?
Result := inherited GetOption(Index) //forward to parent's method
else
begin
case Index - PreOptionCount of //depending on index of option
0: Result.BoolData := FDefaultFontType = pftHelvetica; //get the value
1: Result.RealData := FNormalFontSize;
2: Result.RealData := FLineDistanceScale;
3: Result.IntData := FLinkColor;
4: Result.IntData := FExternLinkColor;
5: Result.IntData := FFileLinkColor;
6: Result.EnumData := ord(FPageFontType);
7: Result.RealData := FPageFontSize;
8: begin
Result.EnumData := 0;
if pfsBold in FPageFontStyle then
inc(Result.EnumData);
if pfsItalic in FPageFontStyle then
inc(Result.EnumData, 2);
end;
9: Result.RealData := FPageWidth;
10: Result.RealData := FPageHeight;
11: Result.RealData := FLeftMargin;
12: Result.RealData := FRightMargin;
13: Result.RealData := FTopMargin;
14: Result.RealData := FBottomMargin;
15: Result.BoolData := FInterpolateImages;
16: Result.RealData := FMaxImageScale;
else
assert(Index >= GetOptionCount);
raise EInvalidOption.Create('Invalid index for option supplied!');
end;
end;
end;
{Sets the value of an option. Call ~[link GetOptionDescription] to get the type
and the meaning of the option.
~param Index index of the option to set the value
~param Value the new value of the option
~see GetOptionCount
~see GetOptionDescription
~see GetOption }
procedure TBasePDFDoc.SetOption(Index: Cardinal; const Value: TOptionValue);
var PreOptionCount :Cardinal; //number of options in parent class
begin
PreOptionCount := inherited GetOptionCount; //get number of options in parent
if Index < PreOptionCount then //an option in the parent class?
inherited SetOption(Index, Value) //forward to parent's method
else
case Index - PreOptionCount of //depending on index of option
0: if Value.BoolData then //set the value
FDefaultFontType := pftHelvetica
else
FDefaultFontType := pftTimes;
1: FNormalFontSize := Value.RealData;
2: FLineDistanceScale := Value.RealData;
3: FLinkColor := Value.IntData;
4: FExternLinkColor := Value.IntData;
5: FFileLinkColor := Value.IntData;
6: if (Value.EnumData >= ord(low(TPDFFontType))) and
(Value.EnumData <= ord(high(TPDFFontType))) then
FPageFontType := TPDFFontType(Value.IntData);
7: FPageFontSize := Value.RealData;
8: begin
FPageFontStyle := [];
if Value.EnumData in [1, 3] then
include(FPageFontStyle, pfsBold);
if Value.EnumData in [2, 3] then
include(FPageFontStyle, pfsItalic);
end;
9: FPageWidth := Value.RealData;
10: FPageHeight := Value.RealData;
11: FLeftMargin := Value.RealData;
12: FRightMargin := Value.RealData;
13: FTopMargin := Value.RealData;
14: FBottomMargin := Value.RealData;
15: FInterpolateImages := Value.BoolData;
16: FMaxImageScale := Value.RealData;
else
assert(Index >= GetOptionCount);
raise EInvalidOption.Create('Invalid index for option supplied!');
end;
end;
{Returns the text formatted in the format of the documentation. Any special
characters are encoded so the text will appear as is.
~param Text the text to "quote" in the format
~result the encoded text }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -