The sample shows steps and algorithm of how to set word spacing for text in PDF and how to make it work in your VBScript and VB6 application. ByteScout PDF SDK can set word spacing for text in PDF. It can be used from VBScript and VB6. ByteScout PDF SDK is the SDK for pdf documents generation, modification and updates. Can also generate and fill PDF forms. Provides support for text (fonts, style, size, font family), layers, pdf form fields, vector and raster drawings.
You will save a lot of time on writing and testing code as you may just take the VBScript and VB6 code from ByteScout PDF SDK for set word spacing for text in PDF below and use it in your application. In your VBScript and VB6 project or application you may simply copy & paste the code and then run your app! Enjoy writing a code with ready-to-use sample VBScript and VB6 codes.
ByteScout free trial version is available for download from our website. It includes all these programming tutorials along with source code samples.
' This example demonstrates how to change the word spacing. ' Create Bytescout.PDF.Document object Set pdfDocument = CreateObject("Bytescout.PDF.Document") pdfDocument.RegistrationName = "demo" pdfDocument.RegistrationKey = "demo" Set comHelpers = pdfDocument.ComHelpers ' Add page Set page1 = comHelpers.CreatePage(comHelpers.PAPERFORMAT_A4) pdfDocument.Pages.Add(page1) Set canvas = page1.Canvas Set font = comHelpers.CreateSystemFont("Arial", 16) Set brush = comHelpers.CreateSolidBrush(comHelpers.CreateColorGray(0)) Set stringFormat = comHelpers.CreateStringFormat() ' Standard word spacing stringFormat.WordSpacing = 0.0 canvas.DrawString_4 "Standard word spacing 0.0", (font), (brush), 20, 20, (stringFormat) ' Increased word spacing stringFormat.WordSpacing = 5.0 canvas.DrawString_4 "Increased word spacing 5.0", (font), (brush), 20, 50, (stringFormat) ' Reduced word spacing stringFormat.WordSpacing = -2.5 canvas.DrawString_4 "Reduced word spacing -2.5", (font), (brush), 20, 80, (stringFormat) ' Save document to file pdfDocument.Save("result.pdf") ' Open document in default PDF viewer app Set shell = CreateObject("WScript.Shell") shell.Run "result.pdf", 1, false