The PDFDoc Scout SDK product has been acquired by Lionsoft company in January, 2011 and not available on our web-site anymore.

NEW: pdf generator for Web Developers: PDF Generator SDK for Javascriptclick here to read more details...


For 3rd party C# open-source PDF generation library? Check the blog article: .NET Bear, Do You Know Any Free PDF Generation Libraries For Use In Commercial Applications?
 

Check our commercial products for PDF format:

PDF Extractor SDK - extract tables, text, structured data from PDF files in your apps

PDF Renderer SDK - render PDF files to PNG, BMP, TIFF images in your apps

PDF To HTML SDK - convert PDF to HTML with images and formatting preserved

How to set word and character spacing for text in PDF created with PDFDoc Scout library

How to set word and character spacing for text in PDF document generated using PDFDoc Scout library

Download example source code: pdfdocscout_example_text_formatting.zip (10,8 KB)

This example demonstrates how to use different word and character spacing text style in generated PDF document with PDFDoc Scout library

Screenshot (view produced pdf):

screenshot of pdf with text with word spacing and character spacing

' create PDFDoc object
Set PDFDoc = CreateObject("PDFDocScout.PDFDocument")
' initialize library
PDFDoc.InitLibrary "demo", "demo"

' set output filename for PDF document
PDFDoc.OutputFileName = "pdfdocscout_example_text_formatting.pdf"
' automatically open generated PDF document in default PDF viewer application
PDFDoc.AutoOpenGeneratedPDF = true

' starts PDF document generation
PDFDoc.BeginDocument

' constant to define font size
Const FontSize = 14

' Set font for drawning text
PDFDoc.Page.SetFont "Arial Black", FontSize, False, False, False, False, 0

' set additional character spacing (space between characters). Default character spacing is zero (0)
' new character spacing factor value should be calculated as (WidthOfSpaceSymbol / FontSizeValue)
' for example you can take "T" character as a reference and add additional space between each character equal to the width of this character. So visual width of the text will be doubled
' so to add additional space to each character you should calculate: PDFDoc.Page.GetTextWidth("T") / FontSize

PDFDoc.Page.SetCharacterSpacing 0
PDFDoc.Page.AddText "Character spacing", 100, 150, 0

' now add additional character spacing = width of "T" character
PDFDoc.Page.SetCharacterSpacing PDFDoc.Page.GetTextWidth("T")/FontSize
PDFDoc.Page.AddText "Character spacing", 100, 160, 0

' works in the same way as character spacing but for space character only
' so to calculate value to double spaces between words you should calculate: PDFDoc.Page.GetTextWidth(" ") / FontSize

' draw text with default values
PDFDoc.Page.SetCharacterSpacing 0
PDFDoc.Page.SetWordSpacing 0
PDFDoc.Page.AddText "Word Spacing", 100, 200, 0

' now double space characters
PDFDoc.Page.SetWordSpacing PDFDoc.Page.GetTextWidth(" ") / FontSize
PDFDoc.Page.AddText "Word Spacing", 100, 210, 0


' set Horizontal Scaling
' default value is 100%
' to compress it in 2 times you can set scaling to 50%

' draw default settings (100 horizontal scaling)
PDFDoc.Page.SetCharacterSpacing 0
PDFDoc.Page.SetHorizontalScaling 100
PDFDoc.Page.AddText "Scaling", 100, 240, 0

' draw 50% horizontal scaling
PDFDoc.Page.SetHorizontalScaling 50
PDFDoc.Page.AddText "Scaling", 100, 250, 0

' close pdf document generation
PDFDoc.EndDocument

' disconnect from library
Set PDFDoc = Nothing

Download example source code: pdfdocscout_example_text_formatting.zip (10,8 KB)

Filed in: PDFDoc Scout SDK

Tutorials: