Hello world from Delphi HotPDF Component!
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 |
program HelloWorld; {$APPTYPE CONSOLE} uses Windows, Messages, SysUtils, Vcl.Graphics, Classes, HPDFDoc; var HotPDF: THotPDF; Titles: TStrings; Title: String; Window: HWND; begin // Close destination PDF file if opened in Adobe or Fixit PDF readers & editors. Titles := TStringList.Create; Titles.CommaText := '"HelloWorld.pdf", "HelloWorld.pdf - Foxit Reader", "HelloWorld.pdf - Foxit PhantomPDF"'; for Title in Titles do begin Window := FindWindow(Nil, PChar(Title)); while Window <> 0 do begin postmessage(Window, WM_CLOSE, 0, 0); Window := FindWindowEx(0, Window, Nil, PChar(Title)); end; end; Titles.Free; // Create HelloWorld.pdf and write something HotPDF:= THotPDF.Create(nil); try HotPDF.AutoLaunch := true; HotPDF.FileName := 'HelloWorld.pdf'; HotPDF.BeginDoc; HotPDF.CurrentPage.SetFont('Arial Unicode MS', [], 12, 0, False); HotPDF.CurrentPage.TextOut(80, 50, 0, 'Hello, Delphi PDF world!'); HotPDF.CurrentPage.TextOut(80, 70, 0, 'Hola, mundo Delphi PDF!'); HotPDF.CurrentPage.TextOut(80, 90, 0, 'Hallo, Delphi PDF Welt!'); HotPDF.CurrentPage.TextOut(80, 110, 0, 'Bonjour, monde PDF Delphi!'); HotPDF.CurrentPage.TextOut(80, 130, 0, 'Ciao, mondo Delphi PDF!'); HotPDF.CurrentPage.UnicodeTextOut(80, 150, 0, 'Olá, mundo Delphi PDF!'); HotPDF.CurrentPage.UnicodeTextOut(80, 170, 0, 'Здравствуйте, Delphi PDF мир!'); HotPDF.CurrentPage.UnicodeTextOut(80, 190, 0, 'こんにちは、Delphi PDFの世界!'); HotPDF.CurrentPage.UnicodeTextOut(80, 210, 0, 'Merhaba, Delphi PDF dünyası!'); HotPDF.CurrentPage.UnicodeTextOut(80, 230, 0, '你好,Delphi PDF世界'); HotPDF.CurrentPage.SetFont('Malgun Gothic Semilight', [], 12, 0, False); // Set font for Korean text displaying HotPDF.CurrentPage.UnicodeTextOut(80, 250, 0, '여보세요, Delphi PDF 세계!'); HotPDF.EndDoc; finally HotPDF.Free; end; end. |