📄 textout.dpr
字号:
{*******************************************************}
{ }
{ This unit is part of the VISPDF VCL library. }
{ Written by R.Husske - ALL RIGHTS RESERVED. }
{ }
{ Copyright (C) 2000-2008, www.vispdf.com }
{ }
{ e-mail: support@vispdf.com }
{ http://www.vispdf.com }
{ }
{*******************************************************}
program TextOut;
{$APPTYPE CONSOLE}
uses
SysUtils, Graphics, Classes, Windows, VPDFDoc;
var
VPDF: TVPDF;
OutlineRoot: TVPDFDocOutlineObject;
CurrnetOutline: TVPDFDocOutlineObject;
procedure ShowFontGroup ( FontGroup: string; Position: Integer );
begin
VPDF.CurrentPage.SetFont( FontGroup, [], 14); // Set font
VPDF.CurrentPage.TextOut( Position, 50, 0, FontGroup ); // Show font name
VPDF.CurrentPage.SetFont( FontGroup, [fsBold], 14); // Set font with Bold style
VPDF.CurrentPage.TextOut( Position, 70, 0, FontGroup+'-Bold' ); // Show font name
VPDF.CurrentPage.SetFont( FontGroup, [fsItalic], 14); // Set font with Italic style
VPDF.CurrentPage.TextOut( Position, 90, 0, FontGroup+'-Italic' ); // Show font name
VPDF.CurrentPage.SetFont( FontGroup, [fsBold, fsItalic], 14); // Set font with Bold Italic style
VPDF.CurrentPage.TextOut( Position, 110, 0, FontGroup+'-Bold-Italic' ); // Show font name
end;
procedure ShowCharset ( FontCharset: TFontCharset; First, Last: Integer; Y1, Y2: Integer );
var
i: Integer;
CSName: string;
begin
case FontCharset of
ARABIC_CHARSET: CSName := 'ARABIC_CHARSET';
BALTIC_CHARSET: CSName := 'BALTIC_CHARSET';
EASTEUROPE_CHARSET: CSName := 'EASTEUROPE_CHARSET';
GREEK_CHARSET: CSName := 'GREEK_CHARSET';
RUSSIAN_CHARSET: CSName := 'RUSSIAN_CHARSET';
TURKISH_CHARSET: CSName := 'TURKISH_CHARSET';
end;
VPDF.CurrentPage.SetFont( 'Arial', [fsBold, fsItalic], 12); // Set charset header font
VPDF.CurrentPage.TextOut ( 50, Y1, 0, CSName + ' example: ');
VPDF.CurrentPage.SetFont( 'Arial', [], 14, FontCharset );
for I := First to Last do
begin
VPDF.CurrentPage.TextOut( 30 + (I mod 25) * 22, Y2 + (I div 25) * 17, 0 , AnsiChar(chr(I)) ); //Show some characters
end;
end;
procedure ShowTable ( X, Y: Integer);
begin
VPDF.CurrentPage.Rectangle(X, Y, 300, 50);
VPDF.CurrentPage.Stroke;
VPDF.CurrentPage.Rectangle(X, Y + 50, 300, 50);
VPDF.CurrentPage.Stroke;
VPDF.CurrentPage.MoveTo( X + 130, Y );
VPDF.CurrentPage.LineTo( X + 130, Y + 100 );
VPDF.CurrentPage.Stroke;
end;
begin
VPDF:= TVPDF.Create(nil);
try
VPDF.AutoLaunch := true; // PDF file will be shown automatically
VPDF.NotEmbeddedFonts.Add('Arial');
VPDF.StandardFontEmulation := true;
VPDF.FileName := '.\TextOut.pdf'; // Set PDF filename
VPDF.Compression := cmNone; // Set flate compression
VPDF.PageLayout := plOneColumn; // One column viewer mode
VPDF.BeginDoc( true ); // Create PDF file
OutlineRoot := VPDF.OutlineRoot; // Get Outlines Root
//--------------------------- Standard fonts --------------------------//
VPDF.CurrentPage.SetFont('Arial Unicode MS', [fsBold, fsUnderline], 20); // Show page header
VPDF.CurrentPage.TextOut( 220, 10, 0, 'Standard fonts' );
OutlineRoot.AddChild( 'Standard fonts', 220, 10 ); // Add Outline block linked to 220, 10 in current page
ShowFontGroup( 'Times New Roman', 20 );
ShowFontGroup( 'Arial', 230 );
ShowFontGroup( 'Courier New', 380 );
//--------------------------- Charsets --------------------------//
VPDF.CurrentPage.SetFont('Arial', [fsBold, fsUnderline], 20); // Show next header
VPDF.CurrentPage.TextOut( 250, 170, 0, 'Charsets' );
CurrnetOutline := OutlineRoot.AddChild( 'Charsets', 250, 170 ); // Add Outline block linked to 250, 170 in current page
CurrnetOutline.Opened := true; // The outline will be opened
CurrnetOutline.AddChild( 'ARABIC_CHARSET', 210, 105 ); // Add Outline linked to 210, 105 in current page
ShowCharset ( ARABIC_CHARSET, 161, 252, 210, 105 );
CurrnetOutline.AddChild( 'BALTIC_CHARSET', 300, 195 ); // Add Outline linked to 300, 195 in current page
ShowCharset ( BALTIC_CHARSET, 166, 255, 300, 195 );
CurrnetOutline.AddChild( 'EASTEUROPE_CHARSET', 390, 285 ); // Add Outline linked to 390, 285 in current page
ShowCharset ( EASTEUROPE_CHARSET, 161, 255, 390, 285 );
CurrnetOutline.AddChild( 'GREEK_CHARSET', 390, 285 ); // Add Outline linked to 480, 285 in current page
ShowCharset ( GREEK_CHARSET, 161, 254, 480, 375 );
CurrnetOutline.AddChild( 'RUSSIAN_CHARSET', 390, 285 ); // Add Outline linked to 570, 465 in current page
ShowCharset ( RUSSIAN_CHARSET, 161, 255, 570, 465 );
CurrnetOutline.AddChild( 'TURKISH_CHARSET', 660, 555 ); // Add Outline linked to 660, 555 in current page
ShowCharset ( TURKISH_CHARSET, 161, 255, 660, 555 );
VPDF.AddPage;
//--------------------------- Text Scaling --------------------------//
VPDF.CurrentPage.SetFont('Arial', [fsBold, fsUnderline], 20); // Show next header
OutlineRoot.AddChild( 'Text Scaling', 200, 20 );
VPDF.CurrentPage.TextOut( 200, 20, 0, 'Horizontal text scaling' );
ShowTable(170, 60);
VPDF.CurrentPage.SetFont('Times New Roman', [], 12); // Draw table
VPDF.CurrentPage.TextOut( 200, 80, 0, '=100 (default)' );
VPDF.CurrentPage.TextOut( 230, 125, 0, '=50' );
VPDF.CurrentPage.SetFont('Times New Roman', [], 24);
VPDF.CurrentPage.TextOut( 350, 80, 0, 'Word' );
VPDF.CurrentPage.SetHorizontalScaling( 50 ); // Set horizontal scaling
VPDF.CurrentPage.TextOut( 350, 120, 0, 'WordWord' );
VPDF.CurrentPage.SetHorizontalScaling( 100 ); // Set horizontal scaling
//--------------------------- Character Spacing --------------------------//
VPDF.CurrentPage.SetFont('Arial', [fsBold, fsUnderline], 20); // Show next header
OutlineRoot.AddChild( 'Character Spacing', 200, 180 );
VPDF.CurrentPage.TextOut( 220, 180, 0, 'Character Spacing' );
ShowTable(170, 220);
VPDF.CurrentPage.SetFont('Times New Roman', [], 12);
VPDF.CurrentPage.TextOut( 200, 240, 0, '=0 (default)' );
VPDF.CurrentPage.TextOut( 230, 290, 0, '=5' );
VPDF.CurrentPage.SetFont('Times New Roman', [], 24);
VPDF.CurrentPage.TextOut( 320, 230, 0, 'Character' );
VPDF.CurrentPage.SetCharacterSpacing( 5 ); // Set character spacing
VPDF.CurrentPage.TextOut( 320, 280, 0, 'Character' );
VPDF.CurrentPage.SetCharacterSpacing( 0 ); // Set character spacing
//--------------------------- Word Spacing --------------------------//
VPDF.CurrentPage.SetFont('Arial', [fsBold, fsUnderline], 20); // Show next header
OutlineRoot.AddChild( 'Word Spacing', 200, 340 );
VPDF.CurrentPage.TextOut( 250, 340, 0, 'Word Spacing' );
ShowTable(170, 380);
VPDF.CurrentPage.SetFont('Times New Roman', [], 12);
VPDF.CurrentPage.TextOut( 200, 400, 0, '=0 (default)' );
VPDF.CurrentPage.TextOut( 230, 450, 0, '=5' );
VPDF.CurrentPage.SetFont('Times New Roman', [], 24);
VPDF.CurrentPage.TextOut( 320, 390, 0, 'Word Space' );
VPDF.CurrentPage.SetWordSpacing( 5 ); //Set word spacing
VPDF.CurrentPage.TextOut( 320, 440, 0, 'Word Space' );
VPDF.CurrentPage.SetWordSpacing( 0 ); //Set word spacing
//--------------------------- Rendering modes --------------------------//
VPDF.CurrentPage.SetFont('Arial', [fsBold, fsUnderline], 20); // Show next header
OutlineRoot.AddChild( 'Rendering modes', 200, 540 );
VPDF.CurrentPage.TextOut( 240, 540, 0, 'Rendering modes' );
VPDF.CurrentPage.Rectangle( 50, 580, 500, 150 );
VPDF.CurrentPage.Stroke;
VPDF.CurrentPage.MoveTo( 175, 580 );
VPDF.CurrentPage.LineTo( 175, 730 );
VPDF.CurrentPage.Stroke;
VPDF.CurrentPage.MoveTo( 300, 580 );
VPDF.CurrentPage.LineTo( 300, 730 );
VPDF.CurrentPage.Stroke;
VPDF.CurrentPage.MoveTo( 425, 580 );
VPDF.CurrentPage.LineTo( 425, 730 );
VPDF.CurrentPage.Stroke;
VPDF.CurrentPage.MoveTo( 50, 655 );
VPDF.CurrentPage.LineTo( 550, 655 );
VPDF.CurrentPage.Stroke;
VPDF.CurrentPage.SetFont('Arial', [], 12); // Show table header
VPDF.CurrentPage.TextOut( 100, 610, 0, 'Fill');
VPDF.CurrentPage.TextOut( 215, 610, 0, 'Stroke');
VPDF.CurrentPage.TextOut( 320, 610, 0, 'Fill then Stroke');
VPDF.CurrentPage.TextOut( 465, 610, 0, 'Invisible');
VPDF.CurrentPage.SetFont('Arial', [fsBold], 72);
VPDF.CurrentPage.SetRGBStrokeColor ( clRed ); // Set stroke color
VPDF.CurrentPage.SetRGBFillColor ( clYellow ); // Set fill color
VPDF.CurrentPage.SetTextRenderingMode( trFill ); // Set only fill rendering mode
VPDF.CurrentPage.TextOut( 80, 650, 0, 'W');
VPDF.CurrentPage.SetTextRenderingMode( trStroke ); // Set only stroke rendering mode
VPDF.CurrentPage.TextOut( 205, 650, 0, 'W');
VPDF.CurrentPage.SetTextRenderingMode( trFillThenStroke ); // Set fill and stroke rendering mode
VPDF.CurrentPage.TextOut( 330, 650, 0, 'W');
VPDF.CurrentPage.SetTextRenderingMode( trInvisible ); // Set invisible rendering mode
VPDF.CurrentPage.TextOut( 465, 650, 0, 'W');
VPDF.CurrentPage.SetTextRenderingMode( trFillThenStroke ); // Set default rendering mode
VPDF.EndDoc;
finally
VPDF.Free;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -