コード例 #1
0
    public Example_44()
    {
        int rotate = 0;

        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_44.pdf", FileMode.Create)));

        Font f1 = new Font(pdf, CoreFont.HELVETICA);

        f1.SetSize(12f);

        Font f2 = new Font(
            pdf,
            "STHeitiSC-Light",      // Chinese (Simplified) font
            CodePage.UNICODE);

        f2.SetSize(12f);

        Page page = new Page(pdf, Letter.PORTRAIT);

        TextColumn column = new TextColumn(rotate);

        column.SetLocation(70f, 70f);
        column.SetWidth(500f);
        column.SetSpaceBetweenLines(5.0f);
        column.SetSpaceBetweenParagraphs(10.0f);

        Paragraph p1 = new Paragraph();

        p1.Add(new TextLine(f1,
                            "The Swiss Confederation was founded in 1291 as a defensive alliance among three cantons. In succeeding years, other localities joined the original three. The Swiss Confederation secured its independence from the Holy Roman Empire in 1499. Switzerland's sovereignty and neutrality have long been honored by the major European powers, and the country was not involved in either of the two World Wars. The political and economic integration of Europe over the past half century, as well as Switzerland's role in many UN and international organizations, has strengthened Switzerland's ties with its neighbors. However, the country did not officially become a UN member until 2002."));
        column.AddParagraph(p1);

        String chinese = "用于附属装置选择器应用程序的分析方法和计算基于与物料、附属装置和机器有关的不同参数和变量。 此类参数和变量的准确性会影响附属装置选择 应用程序结果的准确性。 虽然沃尔沃建筑设备公司、其子公司和附属公司(统称“沃尔沃建筑设备”)已尽力确保附属装置选择应用程序的准确性,但沃尔沃建筑设备无法保证结果准确无误。 因此,沃尔沃建筑设备并未对附属装置选择应用程序结果的准确性作出保证或声明(无论明示或暗示)。 沃尔沃建筑设备特此声明不对有关附属装置选择应用程序报告,此处获得的结果,或用于附属装置选择应用程序的设备的适宜性的所有明示或暗示保证,包括但不限于用于特定目的的适销性或合适性的任何保证承担任何责任。 在任何情况下,沃尔沃建筑设备均不对为实体或由实体创建的结果(或任何其它实体)以及由此造成的任何间接、意外、必然或特殊损害,包括但不限于损失收益或利润承担任何责任。";

        column.AddChineseParagraph(f2, chinese);

        column.DrawOn(page);

        pdf.Close();
    }
コード例 #2
0
    public Example_10()
    {
        int rotate = 0;
        // int rotate = 90;
        // int rotate = 270;

        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_10.pdf", FileMode.Create)));

        pdf.SetTitle("Using TextColumn and Paragraph classes");
        pdf.SetSubject("Examples");
        pdf.SetAuthor("Innovatics Inc.");

        String fileName = "images/sz-map.png";
        Image  image1   = new Image(
            pdf, new FileStream(fileName, FileMode.Open, FileAccess.Read), ImageType.PNG);

        Font f1 = new Font(pdf, CoreFont.HELVETICA);

        f1.SetSize(10f);

        Font f2 = new Font(pdf, CoreFont.HELVETICA_BOLD);

        f2.SetSize(14f);

        Font f3 = new Font(pdf, CoreFont.HELVETICA_BOLD);

        f3.SetSize(12f);

        Font f4 = new Font(pdf, CoreFont.HELVETICA_OBLIQUE);

        f4.SetSize(10f);

        Page page = new Page(pdf, Letter.PORTRAIT);

        image1.SetLocation(90f, 35f);
        image1.ScaleBy(0.75f);
        image1.DrawOn(page);

        TextColumn column = new TextColumn(rotate);

        column.SetSpaceBetweenLines(5.0f);
        column.SetSpaceBetweenParagraphs(10.0f);

        Paragraph p1 = new Paragraph();

        p1.SetAlignment(Align.CENTER);
        p1.Add(new TextLine(f2, "Switzerland"));

        Paragraph p2 = new Paragraph();

        p2.Add(new TextLine(f2, "Introduction"));

        StringBuilder buf = new StringBuilder();

        buf.Append("The Swiss Confederation was founded in 1291 as a defensive ");
        buf.Append("alliance among three cantons. In succeeding years, other ");
        buf.Append("localities joined the original three. ");
        buf.Append("The Swiss Confederation secured its independence from the ");
        buf.Append("Holy Roman Empire in 1499. Switzerland's sovereignty and ");
        buf.Append("neutrality have long been honored by the major European ");
        buf.Append("powers, and the country was not involved in either of the ");
        buf.Append("two World Wars. The political and economic integration of ");
        buf.Append("Europe over the past half century, as well as Switzerland's ");
        buf.Append("role in many UN and international organizations, has ");
        buf.Append("strengthened Switzerland's ties with its neighbors. ");
        buf.Append("However, the country did not officially become a UN member ");
        buf.Append("until 2002.");

        Paragraph p3 = new Paragraph();

        // p3.SetAlignment(Align.LEFT);
        // p3.SetAlignment(Align.RIGHT);
        p3.SetAlignment(Align.JUSTIFY);
        TextLine text = new TextLine(f1, buf.ToString());

        text.SetFont(f1);
        p3.Add(text);

        buf = new StringBuilder();
        buf.Append("Switzerland remains active in many UN and international ");
        buf.Append("organizations but retains a strong commitment to neutrality.");

        text = new TextLine(f1, buf.ToString());
        text.SetColor(Color.red);
        p3.Add(text);

        Paragraph p4 = new Paragraph();

        p4.Add(new TextLine(f3, "Economy"));

        buf = new StringBuilder();
        buf.Append("Switzerland is a peaceful, prosperous, and stable modern ");
        buf.Append("market economy with low unemployment, a highly skilled ");
        buf.Append("labor force, and a per capita GDP larger than that of the ");
        buf.Append("big Western European economies. The Swiss in recent years ");
        buf.Append("have brought their economic practices largely into ");
        buf.Append("conformity with the EU's to enhance their international ");
        buf.Append("competitiveness. Switzerland remains a safehaven for ");
        buf.Append("investors, because it has maintained a degree of bank secrecy ");
        buf.Append("and has kept up the franc's long-term external value. ");
        buf.Append("Reflecting the anemic economic conditions of Europe, GDP ");
        buf.Append("growth stagnated during the 2001-03 period, improved during ");
        buf.Append("2004-05 to 1.8% annually and to 2.9% in 2006.");

        Paragraph p5 = new Paragraph();

        p5.SetAlignment(Align.JUSTIFY);
        text = new TextLine(f1, buf.ToString());
        p5.Add(text);

        text = new TextLine(f4,
                            "Even so, unemployment has remained at less than half the EU average.");
        text.SetColor(Color.blue);
        p5.Add(text);

        Paragraph p6 = new Paragraph();

        p6.SetAlignment(Align.RIGHT);
        text = new TextLine(f1, "Source: The world fact book.");
        text.SetColor(Color.blue);
        text.SetURIAction(
            "https://www.cia.gov/library/publications/the-world-factbook/geos/sz.html");
        p6.Add(text);

        column.AddParagraph(p1);
        column.AddParagraph(p2);
        column.AddParagraph(p3);
        column.AddParagraph(p4);
        column.AddParagraph(p5);
        column.AddParagraph(p6);

        if (rotate == 0)
        {
            column.SetLocation(90f, 300f);
        }
        else if (rotate == 90)
        {
            column.SetLocation(90f, 780f);
        }
        else if (rotate == 270)
        {
            column.SetLocation(550f, 310f);
        }

        float columnWidth = 470f;

        column.SetSize(columnWidth, 100f);
        float[] xy = column.DrawOn(page);

        Line line = new Line(
            xy[0],
            xy[1],
            xy[0] + columnWidth,
            xy[1]);

        line.DrawOn(page);

        pdf.Complete();
    }