This example shows how to create multistyled text.




We want to display all our proper names in bold so we enclose them in bold tags.

theText = "<b>Gallia</b> est omnis divisa in partes tres, quarum unam incolunt <b>Belgae</b>, aliam <b>Aquitani</b>, tertiam qui ipsorum lingua <b>Celtae</b>, nostra <b>Galli</b> appellantur."


Doc Obj

Next, we create an ABCpdf Doc object and give it some basic settings. Although we could pass our HTML styled text directly directly to the AddHtml function, we can take more control over the way that fonts are added to the PDF if we specify font IDs.

Set theDoc = Server.CreateObject("ABCpdf10.Doc")
theDoc.FontSize = 72
theDoc.Rect.Inset 10, 10
theFont1 = theDoc.EmbedFont("Verdana", "Latin", False, True)
theFont2 = theDoc.EmbedFont("Verdana Bold", "Latin", False, True)




We replace the bold tags with font tags that directly reference our chosen fonts and then add the HTML styled text to the current rectangle.

theText = "<font pid=" & theFont1 & ">" & theText & "</font>"
theText = Replace(theText, "<b>", "<font pid=" & theFont2 & ">")
theText = Replace(theText, "</b>", "</font>")
theDoc.AddHtml theText




Finally, we save the document to a specified location.

theDoc.Save "c:\mypdfs\styles.pdf"