using System; using System.IO; using System.Collections;using System.Collections.Generic; using System.Text; using PDFjet.NET; /** * Example_04.cs * * The PDF generated by this example program will only work with Adobe Reader 8 * or Foxit Reader v2.0 or higher versions. It also requires the Asian Font Packs * from Adobe or Foxit Software respectively. */ public class Example_04 { public Example_04() { PDF pdf = new PDF(); Font f1 = new Font( pdf, "AdobeMingStd-Light", // Chinese (Traditional) font CodePage.UNICODE); Font f2 = new Font( pdf, "AdobeSongStd-Light", // Chinese (Simplified) font CodePage.UNICODE); Font f3 = new Font( pdf, "KozMinProVI-Regular", // Japanese font CodePage.UNICODE); Font f4 = new Font( pdf, "AdobeMyungjoStd-Medium", // Korean font CodePage.UNICODE); Page page = new Page(pdf, Letter.PORTRAIT); f1.SetSize(20); f2.SetSize(20); f3.SetSize(20); f4.SetSize(20); double x_pos = 100.0; double y_pos = 20.0; StreamReader reader = new StreamReader("data/happy-new-year.txt"); TextLine text = new TextLine(f1); String line = null; while ((line = reader.ReadLine()) != null) { if (line.IndexOf("Simplified") != -1) { text.SetFont(f2); } else if (line.IndexOf("Japanese") != -1) { text.SetFont(f3); } else if (line.IndexOf("Korean") != -1) { text.SetFont(f4); } text.SetText(line); text.SetPosition(x_pos, y_pos += 24); text.DrawOn(page); } reader.Close(); pdf.Wrap(); pdf.Save("Example_04.pdf"); } public static void Main(String[] args) { try { new Example_04(); } catch (Exception e) { Console.WriteLine(e); } } } // End of Example_04.cs