Categories: PDF Programming

HotPDF Component Vertical Text Sample Project

HotPDF Delphi Component: Creating Vertical Text Layouts in PDF Documents

This comprehensive guide demonstrates how the HotPDF component enables developers to generate Unicode vertical text in PDF documents with ease.

Understanding Vertical Typesetting (縦書き/세로쓰기/竖排)

Vertical typesetting, also known as vertical writing, 縱書 in Chinese or tategaki (縦書き) in Japanese, is a traditional text layout method that originated in ancient China over 2,000 years ago. This writing system flows from top to bottom and right to left, creating a distinctive visual appearance that carries deep cultural significance.

Historical and Cultural Context

Vertical writing systems have played a crucial role in East Asian literature and documentation:

  • China: Traditional Chinese texts, classical poetry, and calligraphy predominantly used vertical layouts. Modern simplified Chinese primarily uses horizontal writing, though vertical text remains common in artistic and ceremonial contexts.
  • Japan: Japanese maintains both vertical (縦書き/tategaki) and horizontal (横書き/yokogaki) writing systems. Vertical text is still widely used in novels, manga, newspapers, and traditional documents.
  • Korea: Historically used vertical writing (세로쓰기), but modern Korean (한글) predominantly uses horizontal layouts. Vertical text appears in traditional contexts and artistic applications.
  • Vietnam: Traditional Vietnamese texts used vertical layouts when written in Chinese characters (Chữ Hán), though this practice has largely disappeared with the adoption of the Latin alphabet.

Modern Applications of Vertical Text

Despite the global trend toward horizontal writing, vertical text layouts remain relevant in several contexts:

  • Publishing: Traditional novels, poetry collections, and literary works in Taiwan, Japan, and Hong Kong
  • Design: Logos, signage, and artistic layouts that require visual impact
  • Digital Media: E-books, mobile applications, and web content targeting traditional reading preferences
  • Documentation: Legal documents, certificates, and formal communications in traditional formats

HotPDF Component: Professional Vertical Text Support

The HotPDF Delphi component provides comprehensive support for vertical text layout in PDF documents, making it an ideal solution for developers working with multilingual applications or traditional document formats.

Key Features for Vertical Typography

  • Unicode Support: Full compatibility with CJK (Chinese, Japanese, Korean) character sets
  • Font Embedding: Ensures consistent display across different systems
  • Mixed Layouts: Combine horizontal and vertical text in the same document
  • Precise Positioning: Pixel-perfect control over text placement
  • Multi-language Support: Handle complex scripts and character combinations
Figure 1: PDF document with vertical text layout generated by HotPDF Component, demonstrating multi-language support for Chinese (中文), Japanese (日本語), and Korean (한국어) vertical typography.

Implementation Guide: Delphi Code Example

The following comprehensive Delphi code example demonstrates how to implement vertical text rendering using the HotPDF component. This example showcases both horizontal and vertical text layouts with multiple languages.

Code Features Highlighted

  • Font Configuration: Proper setup of Unicode fonts for multi-language support
  • Text Positioning: Precise control over text placement in vertical layouts
  • Language Mixing: Combining different scripts (Latin, CJK) in the same document
  • Resource Management: Proper initialization and cleanup of PDF resources
{***********************************************************}
// HotPDF PDF Component
// Copyright(c)2007-2025, https://www.loslab.com
{***********************************************************}

{
  Unit: uVerticalText
  Purpose: Demonstrates vertical text output capabilities in HotPDF
  Features: - Horizontal and vertical text rendering
           - Multi-language support (English, Korean, Japanese, Chinese)
           - Unicode character handling
           - Font embedding for proper display
}
unit uVerticalText;

interface

{$I ..\..\..\Lib\HotPDF.inc}

uses
  {$IFDEF XE2+}
  WinApi.Windows,
  WinApi.Messages,
  System.SysUtils,
  System.Classes,
  Vcl.Graphics,
  Vcl.StdCtrls,
  Vcl.Controls,
  Vcl.Dialogs,
  Vcl.Forms,
  {$ELSE}
  Windows,
  Messages,
  SysUtils,
  Graphics,
  Controls,
  StdCtrls,
  Classes,
  Dialogs,
  Forms,
  {$ENDIF}
  HPDFDoc;                    // HotPDF component for PDF generation

type
  // Main form class for the vertical text demonstration
  TForm1 = class(TForm)
    Button1: TButton;         // Button to trigger PDF generation
    procedure Button1Click(Sender: TObject);
  private
    {Private declarations}
  public
    {Public declarations}
  end;

var
  Form1: TForm1;              // Main form instance
  HotPDF: THotPDF;            // HotPDF component instance

implementation

{$R *.DFM}

// Important Note: Old version of Delphi cannot handle Unicode characters correctly.
// You need Delphi 2009 or above to open this file.

{
  Method: Button1Click
  Purpose: Demonstrates vertical and horizontal text output with multiple languages
  Parameters: Sender - The object that triggered the event
  Features: - Creates a PDF with both horizontal and vertical text
           - Shows text in multiple languages (English, Korean, Japanese, Chinese)
           - Uses Unicode font for proper character display
           - Demonstrates different text positioning techniques
}
procedure TForm1.Button1Click(Sender: TObject);
begin
  // Create HotPDF instance
  HotPDF := THotPDF.Create(nil);
  try
    // Configure PDF generation settings
    HotPDF.AutoLaunch := true;        // Automatically open PDF after creation
    HotPDF.FontEmbedding := true;     // Embed fonts for proper display
    HotPDF.FileName := 'VerticalText.pdf';  // Set output filename
    
    // Begin PDF document creation
    HotPDF.BeginDoc;
    HotPDF.CurrentPage.Size := psA4;  // Set page size to A4

    // === HORIZONTAL TEXT DEMONSTRATION ===
    HotPDF.CurrentPage.SetFont('Arial Unicode MS', [], 12, 0, False); // Set horizontal text mode
    // Output horizontal text in multiple languages
    HotPDF.CurrentPage.TextOut(80, 70, 0, 'Horizontal Text 가로텍스트 가로쓰기 横向きのテキスト 横書き 横向文本 横書');
    // Add decorative separator line
    HotPDF.CurrentPage.TextOut(40, 110, 0, '※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※');

    // === VERTICAL TEXT DEMONSTRATION ===
    HotPDF.CurrentPage.SetFont('Arial Unicode MS', [], 12, 0, true); // Set vertical text mode
    
    // Mixed language vertical text (Korean, Japanese)
    HotPDF.CurrentPage.TextOut(530, 180, 0, '縦書 縦書き 세로쓰기 垂直テキスト 수직 텍스트');
    
    // Chinese text - Declaration of Independence excerpt
    HotPDF.CurrentPage.SetFont('Arial Unicode MS', [], 12, 0, true); 
    HotPDF.CurrentPage.TextOut(500, 180, 0, '『我等之见解为,下述真理不证自明:凡人生而平等,秉造物者之赐,');
    HotPDF.CurrentPage.TextOut(470, 180, 0, '拥诸无可转让之权利,包含生命权、自由权、与追寻幸福之权。』');

    // Japanese text - Traditional poetry
    HotPDF.CurrentPage.TextOut(430, 180, 0, '昨日またかくてありけり、今日もまたかくてありなむ');
    HotPDF.CurrentPage.TextOut(400, 180, 0, 'この命にを齷齪、明日をのみ思ひわづらふ');
    HotPDF.CurrentPage.TextOut(370, 180, 0, 'いくたびか栄枯の夢の、消え残る谷に下りて');
    HotPDF.CurrentPage.TextOut(340, 180, 0, '河波のいざよふ見れば、砂まじり水巻き帰る');
    HotPDF.CurrentPage.TextOut(310, 180, 0, '嗚呼古城なにをか語り、岸の波なにをか答ふ、過し世を静かに思へ');

    // Chinese classical poetry - Li Bai's poem
    HotPDF.CurrentPage.TextOut(270, 180, 0, '棄我去者昨日之日不可留,亂我心者今日之日多煩憂。');
    HotPDF.CurrentPage.TextOut(240, 180, 0, '長風萬里送秋鴈,對此可以酣高樓。蓬萊文章建安骨,中間小謝又清發');
    HotPDF.CurrentPage.TextOut(210, 180, 0, '俱懷逸興壯思飛,欲上青天攬明月。抽刀斷水水更流,舉杯消愁愁更愁');
    HotPDF.CurrentPage.TextOut(180, 180, 0, '人生在世不稱意。明朝散髮弄扁舟。');

    // Korean text - Contemporary poetry
    // Note: Using Arial Unicode MS instead of Malgun Gothic for compatibility
    //HotPDF.CurrentPage.SetFont('Malgun Gothic', [], 12, 0, true); // Alternative Korean font
    HotPDF.CurrentPage.TextOut(140, 180, 0, '눈 맞으며 어둠 속을 떨며 가는 사람들을트、노래가 길이 되어 앞질러 가고');
    HotPDF.CurrentPage.TextOut(110, 180, 0, '돌아올 길 없는 눈길 앞질러 가고');
    HotPDF.CurrentPage.TextOut(80, 180, 0, '아름다움이 이 세상을 건질 때까지');
    HotPDF.CurrentPage.TextOut(50, 180, 0, '절망에서 즐거움이 찾아올 때까지');

    // === FOOTER DECORATION ===
    HotPDF.CurrentPage.SetFont('Arial Unicode MS', [], 12, 0, False); // Switch back to horizontal text
    // Add decorative footer line
    HotPDF.CurrentPage.TextOut(40, 720, 0, '■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■');
    
    // Finalize PDF document
    HotPDF.EndDoc;
  finally 
    // Clean up resources
    HotPDF.Free;
  end;
end;

end.

Technical Implementation Details

Font Selection and Unicode Support

When working with vertical text in PDFs, proper font selection is crucial for ensuring correct character display across different languages:

  • Arial Unicode MS: Comprehensive Unicode font supporting most CJK characters
  • Font Embedding: Always enable FontEmbedding := true to ensure consistent display
  • Character Encoding: Use UTF-8 encoding for proper Unicode character handling

Text Positioning Best Practices

Vertical text positioning requires careful consideration of reading flow and character spacing:

  1. Right-to-Left Column Flow: Start from the rightmost position and move left for subsequent columns
  2. Top-to-Bottom Character Flow: Characters within each column flow from top to bottom
  3. Consistent Spacing: Maintain uniform column spacing for professional appearance
  4. Mixed Script Handling: Consider different character widths when mixing Latin and CJK scripts

Advanced Features and Customization

Performance Optimization Tips

  • 🚀 Batch Text Operations: Group multiple text outputs to minimize PDF operations
  • 🚀 Font Caching: Reuse font objects when possible to improve performance
  • 🚀 Memory Management: Properly dispose of HotPDF instances to prevent memory leaks
  • 🚀 Stream Processing: Use memory streams for large documents to improve processing speed

Troubleshooting Common Issues

⚠️ Common Problems and Solutions

  • Missing Characters: Ensure the selected font supports all required Unicode ranges
  • Incorrect Positioning: Verify coordinate system understanding (HotPDF uses top-left origin)
  • Font Rendering Issues: Enable font embedding and use Suitable Unicode fonts
  • Performance Problems: Optimize text output calls and consider document structure

Related Resources and Further Reading

Documentation and Support

Related Topics

  • 🔗 PDF Text Rendering: Advanced typography techniques in PDF documents
  • 🔗 Multilingual PDF Generation: Handling complex scripts and right-to-left languages
  • 🔗 Delphi Unicode Programming: Best practices for Unicode handling in Delphi applications
  • 🔗 Asian Typography: Traditional and modern approaches to CJK text layout

Conclusion

The HotPDF Delphi component provides robust support for vertical text layouts, making it an excellent choice for developers working with traditional Asian typography or modern design applications requiring vertical text orientation. With proper implementation of Unicode fonts, careful positioning, and attention to cultural typography conventions, you can create professional PDF documents that respect traditional reading patterns while maintaining modern technical standards.

Whether you’re developing applications for publishing, document management, or creative design, the vertical text capabilities of HotPDF enable you to create culturally appropriate and visually appealing PDF documents that serve diverse global audiences.

losLab

Devoted to developing PDF and Spreadsheet developer library, including PDF creation, PDF manipulation, PDF rendering library, and Excel Spreadsheet creation & manipulation library.

Recent Posts

HotPDF Delphi组件:在PDF文档中创建垂直文本布局

HotPDF Delphi组件:在PDF文档中创建垂直文本布局 本综合指南演示了HotPDF组件如何让开发者轻松在PDF文档中生成Unicode垂直文本。 理解垂直排版(縦書き/세로쓰기/竖排) 垂直排版,也称为垂直书写,中文称为縱書,日文称为tategaki(縦書き),是一种起源于2000多年前古代中国的传统文本布局方法。这种书写系统从上到下、从右到左流动,创造出具有深厚文化意义的独特视觉外观。 历史和文化背景 垂直书写系统在东亚文学和文献中发挥了重要作用: 中国:传统中文文本、古典诗歌和书法主要使用垂直布局。现代简体中文主要使用横向书写,但垂直文本在艺术和仪式场合仍然常见。 日本:日语保持垂直(縦書き/tategaki)和水平(横書き/yokogaki)两种书写系统。垂直文本仍广泛用于小说、漫画、报纸和传统文档。 韩国:历史上使用垂直书写(세로쓰기),但现代韩语(한글)主要使用水平布局。垂直文本出现在传统场合和艺术应用中。 越南:传统越南文本在使用汉字(Chữ Hán)书写时使用垂直布局,但随着拉丁字母的采用,这种做法已基本消失。 垂直文本的现代应用 尽管全球趋向于水平书写,垂直文本布局在几个方面仍然相关: 出版:台湾、日本和香港的传统小说、诗集和文学作品…

1 day ago

HotPDF Delphi 컴포넌트: PDF 문서에서 세로쓰기

HotPDF Delphi 컴포넌트: PDF 문서에서 세로쓰기 텍스트 레이아웃 생성 이 포괄적인 가이드는 HotPDF 컴포넌트를 사용하여…

2 days ago

HotPDF Delphiコンポーネント-PDFドキュメントでの縦書き

HotPDF Delphiコンポーネント:PDFドキュメントでの縦書きテキストレイアウトの作成 この包括的なガイドでは、HotPDFコンポーネントを使用して、開発者がPDFドキュメントでUnicode縦書きテキストを簡単に生成する方法を実演します。 縦書き組版の理解(縦書き/세로쓰기/竖排) 縦書き組版は、日本語では縦書きまたはたてがきとも呼ばれ、2000年以上前の古代中国で生まれた伝統的なテキストレイアウト方法です。この書字体系は上から下、右から左に流れ、深い文化的意義を持つ独特の視覚的外観を作り出します。 歴史的・文化的背景 縦書きシステムは東アジアの文学と文書において重要な役割を果たしてきました: 中国:伝統的な中国語テキスト、古典詩、書道では主に縦書きレイアウトが使用されていました。現代の簡体字中国語は主に横書きを使用していますが、縦書きテキストは芸術的・儀式的な文脈で一般的です。 日本:日本語は縦書き(縦書き/たてがき)と横書き(横書き/よこがき)の両方の書字体系を維持しています。縦書きテキストは小説、漫画、新聞、伝統的な文書で広く使用されています。 韓国:歴史的には縦書き(세로쓰기)を使用していましたが、現代韓国語(한글)は主に横書きレイアウトを使用しています。縦書きテキストは伝統的な文脈や芸術的応用で見られます。 ベトナム:伝統的なベトナム語テキストは漢字(Chữ Hán)で書かれた際に縦書きレイアウトを使用していましたが、この慣行はラテン文字の採用とともにほぼ消失しました。 縦書きテキストの現代的応用 横書きへの世界的な傾向にもかかわらず、縦書きテキストレイアウトはいくつかの文脈で関連性を保っています: 出版:台湾、日本、香港の伝統的な小説、詩集、文学作品…

2 days ago

Отладка проблем порядка страниц PDF: Реальный кейс-стади

Отладка проблем порядка страниц PDF: Реальный кейс-стади компонента HotPDF Опубликовано losLab | Разработка PDF |…

3 days ago

PDF 페이지 순서 문제 디버깅: HotPDF 컴포넌트 실제 사례 연구

PDF 페이지 순서 문제 디버깅: HotPDF 컴포넌트 실제 사례 연구 발행자: losLab | PDF 개발…

3 days ago

PDFページ順序問題のデバッグ:HotPDFコンポーネント実例研究

PDFページ順序問題のデバッグ:HotPDFコンポーネント実例研究 発行者:losLab | PDF開発 | Delphi PDFコンポーネント PDF操作は特にページ順序を扱う際に複雑になることがあります。最近、私たちはPDF文書構造とページインデックスに関する重要な洞察を明らかにした魅力的なデバッグセッションに遭遇しました。このケーススタディは、一見単純な「オフバイワン」エラーがPDF仕様の深い調査に発展し、文書構造に関する根本的な誤解を明らかにした過程を示しています。 PDFページ順序の概念 - 物理的オブジェクト順序と論理的ページ順序の関係 問題 私たちはHotPDF DelphiコンポーネントのCopyPageと呼ばれるPDFページコピーユーティリティに取り組んでいました。このプログラムはデフォルトで最初のページをコピーするはずでしたが、代わりに常に2番目のページをコピーしていました。一見すると、これは単純なインデックスバグのように見えました -…

3 days ago