HotPDF component text out sample generates font and character set demonstration, as shown in the image above.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
program TextOut; {$APPTYPE CONSOLE} uses SysUtils, Graphics, Classes, Windows, HPDFDoc; var HotPDF: THotPDF; OutlineRoot: THPDFDocOutlineObject; CurrnetOutline: THPDFDocOutlineObject; procedure ShowFontGroup ( FontGroup: AnsiString; Position: Integer ); begin HotPDF.CurrentPage.SetFont( FontGroup, [], 12); HotPDF.CurrentPage.TextOut( Position, 60, 0, FontGroup ); HotPDF.CurrentPage.SetFont( FontGroup, [fsBold], 12); HotPDF.CurrentPage.TextOut( Position, 80, 1, FontGroup+'-Bold' ); // Show font with positive rotation HotPDF.CurrentPage.SetFont( FontGroup, [fsItalic], 12); HotPDF.CurrentPage.TextOut( Position, 100, -1, FontGroup+'-Italic' ); // Show font with negative rotation HotPDF.CurrentPage.SetFont( FontGroup, [fsBold, fsItalic], 12); HotPDF.CurrentPage.TextOut( Position, 120, 0, FontGroup+'-Bold-Italic' ); end; procedure ShowCharset ( FontCharset: TFontCharset; First, Last: Integer; Y1, Y2: Integer ); var i: Integer; CSName: AnsiString; begin // https://docs.microsoft.com/en-us/previous-versions/cc194829(v=msdn.10) case FontCharset of ARABIC_CHARSET: CSName := 'ARABIC_CHARSET'; EASTEUROPE_CHARSET: CSName := 'EASTEUROPE_CHARSET'; OEM_CHARSET: CSName := 'OEM_CHARSET'; RUSSIAN_CHARSET: CSName := 'RUSSIAN_CHARSET'; TURKISH_CHARSET: CSName := 'TURKISH_CHARSET'; end; HotPDF.CurrentPage.SetFont( 'Arial', [fsBold, fsItalic], 12); HotPDF.CurrentPage.TextOut ( 50, Y1, 0, CSName + ' example: '); HotPDF.CurrentPage.SetFont( 'Arial', [], 14, FontCharset ); for I := First to Last do begin HotPDF.CurrentPage.TextOut( 30 + (I mod 25) * 22, Y2 + (I div 25) * 17, 0 , AnsiChar(chr(I)) ); //Show a sequence of characters in the computed position. end; end; procedure ShowTable ( X, Y: Integer); begin HotPDF.CurrentPage.Rectangle(X, Y, 300, 50); HotPDF.CurrentPage.Stroke; HotPDF.CurrentPage.Rectangle(X, Y + 50, 300, 50); HotPDF.CurrentPage.Stroke; HotPDF.CurrentPage.MoveTo( X + 130, Y ); HotPDF.CurrentPage.LineTo( X + 130, Y + 100 ); HotPDF.CurrentPage.Stroke; end; begin HotPDF:= THotPDF.Create(nil); try HotPDF.AutoLaunch := true; HotPDF.NotEmbeddedFonts.Add('Arial'); HotPDF.StandardFontEmulation := true; HotPDF.FileName := 'TextOut.pdf'; HotPDF.PageLayout := plOneColumn; HotPDF.BeginDoc( true ); OutlineRoot := HotPDF.OutlineRoot; //--------------------------- Show fonts --------------------------// HotPDF.CurrentPage.SetFont('Arial', [fsBold, fsUnderline], 20); HotPDF.CurrentPage.TextOut( 195, 20, 0, 'Show Fonts' ); OutlineRoot.AddChild( 'Show Fonts', 180, 20 ); // Add Outline block linked to 180, 20 in current page ShowFontGroup( 'Arial', 50 ); ShowFontGroup( 'Times New Roman', 180 ); ShowFontGroup( 'Courier New', 350 ); //--------------------------- Charsets --------------------------// HotPDF.CurrentPage.SetFont('Arial', [fsBold, fsUnderline], 20); HotPDF.CurrentPage.TextOut( 200, 160, 0, 'Charsets' ); CurrnetOutline := OutlineRoot.AddChild( 'Charsets', 250, 170 ); CurrnetOutline.Opened := true; CurrnetOutline.AddChild( 'ARABIC_CHARSET', 210, 110 ); ShowCharset ( ARABIC_CHARSET, 160, 250, 210, 110 ); CurrnetOutline.AddChild( 'EASTEUROPE_CHARSET', 320, 220 ); ShowCharset ( EASTEUROPE_CHARSET, 160, 250, 320, 220 ); CurrnetOutline.AddChild( 'OEM_CHARSET', 430, 330 ); ShowCharset ( OEM_CHARSET, 160, 250, 430, 330 ); CurrnetOutline.AddChild( 'RUSSIAN_CHARSET', 540, 440 ); ShowCharset ( RUSSIAN_CHARSET, 160, 250, 540, 440 ); CurrnetOutline.AddChild( 'TURKISH_CHARSET', 650, 550 ); ShowCharset ( TURKISH_CHARSET, 160, 250, 650, 550 ); HotPDF.AddPage; //--------------------------- Text Scaling --------------------------// HotPDF.CurrentPage.SetFont('Arial', [fsBold, fsUnderline], 20); OutlineRoot.AddChild( 'Text Scaling', 200, 30 ); HotPDF.CurrentPage.TextOut( 180, 30, 0, 'Horizontal text scaling' ); ShowTable(130, 70); HotPDF.CurrentPage.SetFont('Times New Roman', [], 12); HotPDF.CurrentPage.TextOut( 160, 90, 0, 'default 100' ); HotPDF.CurrentPage.TextOut( 165, 135, 0, 'set to 50' ); HotPDF.CurrentPage.SetFont('Times New Roman', [], 24); HotPDF.CurrentPage.TextOut( 280, 85, 0, 'Word' ); HotPDF.CurrentPage.SetHorizontalScaling( 50 ); HotPDF.CurrentPage.TextOut( 285, 130, 0, 'Word' ); HotPDF.CurrentPage.SetHorizontalScaling( 100 ); //--------------------------- Character Spacing --------------------------// HotPDF.CurrentPage.SetFont('Arial', [fsBold, fsUnderline], 20); OutlineRoot.AddChild( 'Character Spacing', 200, 190 ); HotPDF.CurrentPage.TextOut( 200, 190, 0, 'Character Spacing' ); ShowTable(130, 230); HotPDF.CurrentPage.SetFont('Times New Roman', [], 12); HotPDF.CurrentPage.TextOut( 162, 250, 0, 'default 0' ); HotPDF.CurrentPage.TextOut( 162, 298, 0, 'set space 5' ); HotPDF.CurrentPage.SetFont('Times New Roman', [], 24); HotPDF.CurrentPage.TextOut( 278, 243, 0, 'Character' ); HotPDF.CurrentPage.SetCharacterSpacing( 5 ); HotPDF.CurrentPage.TextOut( 278, 290, 0, 'Character' ); HotPDF.CurrentPage.SetCharacterSpacing( 0 ); //--------------------------- Word Spacing --------------------------// HotPDF.CurrentPage.SetFont('Arial', [fsBold, fsUnderline], 20); OutlineRoot.AddChild( 'Word Spacing', 200, 350 ); HotPDF.CurrentPage.TextOut( 200, 350, 0, 'Word Spacing' ); ShowTable(130, 390); HotPDF.CurrentPage.SetFont('Times New Roman', [], 12); HotPDF.CurrentPage.TextOut( 162, 410, 0, 'default 0' ); HotPDF.CurrentPage.TextOut( 162, 460, 0, 'set space 10' ); HotPDF.CurrentPage.SetFont('Times New Roman', [], 24); HotPDF.CurrentPage.TextOut( 280, 400, 0, 'Word Space' ); HotPDF.CurrentPage.SetWordSpacing( 10 ); HotPDF.CurrentPage.TextOut( 280, 450, 0, 'Word Space' ); HotPDF.CurrentPage.SetWordSpacing( 0 ); //--------------------------- Rendering modes --------------------------// HotPDF.CurrentPage.SetFont('Arial', [fsBold, fsUnderline], 20); OutlineRoot.AddChild( 'Rendering Modes', 200, 520 ); HotPDF.CurrentPage.TextOut( 200, 520, 0, 'Rendering Modes' ); HotPDF.CurrentPage.Rectangle( 50, 560, 500, 150 ); HotPDF.CurrentPage.Stroke; HotPDF.CurrentPage.MoveTo( 175, 560 ); HotPDF.CurrentPage.LineTo( 175, 710 ); HotPDF.CurrentPage.Stroke; HotPDF.CurrentPage.MoveTo( 300, 560 ); HotPDF.CurrentPage.LineTo( 300, 710 ); HotPDF.CurrentPage.Stroke; HotPDF.CurrentPage.MoveTo( 425, 560 ); HotPDF.CurrentPage.LineTo( 425, 710 ); HotPDF.CurrentPage.Stroke; HotPDF.CurrentPage.MoveTo( 50, 625 ); HotPDF.CurrentPage.LineTo( 550, 625 ); HotPDF.CurrentPage.Stroke; HotPDF.CurrentPage.SetFont('Arial', [], 12); HotPDF.CurrentPage.TextOut( 100, 580, 0, 'Fill'); HotPDF.CurrentPage.TextOut( 215, 580, 0, 'Stroke'); HotPDF.CurrentPage.TextOut( 320, 580, 0, 'Fill Stroke'); HotPDF.CurrentPage.TextOut( 465, 580, 0, 'Invisible'); HotPDF.CurrentPage.SetFont('Arial', [fsBold], 72); HotPDF.CurrentPage.SetRGBStrokeColor ( clRed ); HotPDF.CurrentPage.SetRGBFillColor ( clYellow ); HotPDF.CurrentPage.SetTextRenderingMode( trFill ); HotPDF.CurrentPage.TextOut( 90, 630, 0, 'P'); HotPDF.CurrentPage.SetTextRenderingMode( trStroke ); HotPDF.CurrentPage.TextOut( 215, 630, 0, 'D'); HotPDF.CurrentPage.SetTextRenderingMode( trFillThenStroke ); HotPDF.CurrentPage.TextOut( 340, 630, 0, 'F'); HotPDF.CurrentPage.SetTextRenderingMode( trInvisible ); HotPDF.CurrentPage.TextOut( 475, 630, 0, 'X'); HotPDF.CurrentPage.SetTextRenderingMode( trFillThenStroke ); HotPDF.EndDoc; finally HotPDF.Free; end; end. |