This example shows how to add complex scripts such as Chinese, Japanese and Korean. Here, we choose to embed and subset our font to ensure our document renders correctly on all platforms.

 

   

Setup
 

First, we create an ABCpdf Doc object and set the font size.

Set theDoc = Server.CreateObject("ABCpdf10.Doc")
theDoc.FontSize = 32

 

   

Read
 

We read in our Japanese text from a Unicode text file.

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\mypdfs\Japanese2.txt", 1, False, -1)
theText = f.ReadAll

 

   

Add
 

Because we want to ensure that our document renders correctly on all platforms, we're going to embed our font in Unicode format. We specify a left-to-right writing direction, and we choose to subset our font.

Please note when embedding fonts, you must ensure you have permission to embed and redistribute the embedded font as part of your PDF.

theDoc.Page = theDoc.AddPage()
theDoc.Font = theDoc.EmbedFont("MS PGothic", "Unicode", False, True)
theDoc.AddText "Japanese" & theText

 

   

Add
 

Just to show how it works, we'll also render a page in vertical writing mode.

theDoc.Page = theDoc.AddPage()
theDoc.Font = theDoc.EmbedFont("MS PGothic", "Unicode", True, True)
theDoc.AddText "Japanese" & theText

 

   

Save
 

Finally, we save at a specified location.

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

 

   

Results
 

We get the following output.


unicode.pdf [Page 1]

unicode.pdf [Page 2]