真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

C#/VB.NET創(chuàng)建PDF項(xiàng)目符號(hào)列表和多級(jí)編號(hào)列表-創(chuàng)新互聯(lián)

使用項(xiàng)目符號(hào)和編號(hào),可以讓文檔的層次結(jié)構(gòu)更清晰、更有條理,也更容易突出重點(diǎn)。在編輯文檔的過程中,我個(gè)人也比較偏愛項(xiàng)目標(biāo)號(hào)來標(biāo)注文章重點(diǎn)信息。在之前的文章中,介紹了如何在Word中來創(chuàng)建項(xiàng)目標(biāo)號(hào)和編號(hào)列表,在本篇文章中,將介紹創(chuàng)建PDF項(xiàng)目符號(hào)列表和多級(jí)編號(hào)列表的方法。
借助工具:Free Spire.PDF for .NET
PS:dll可以直接在安裝路徑下的Bin文件夾中獲取。

為懷仁等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及懷仁網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都網(wǎng)站建設(shè)、做網(wǎng)站、懷仁網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

1.創(chuàng)建PDF符號(hào)列表

Csharp

using System;
using System.Drawing;
using Spire.Pdf;
using Spire.Pdf.Graphics;
using Spire.Pdf.Lists;

namespace CreateList_PDF
{
    class Program
    {
        static void Main(string[] args)
        {
            //創(chuàng)建一個(gè)PDF文檔
            PdfDocument doc = new PdfDocument();
            //添加一頁(yè)A4大小的頁(yè)面
            PdfPageBase page = doc.Pages.Add(PdfPageSize.A4);
            float y = 10;

            //創(chuàng)建標(biāo)題并設(shè)置格式,包括字體、字號(hào)、顏色
            PdfBrush brush2 = PdfBrushes.Black;
            PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("楷體", 18f, FontStyle.Regular), true);
            PdfStringFormat format1 = new PdfStringFormat(PdfTextAlignment.Center);
            page.Canvas.DrawString("Categories List(項(xiàng)目列表)", font1, brush2, page.Canvas.ClientSize.Width / 2, y, format1);
            y = y + font1.MeasureString("Categories List(項(xiàng)目列表)", format1).Height;
            y = y + 5;

            //創(chuàng)建列表文字并設(shè)置格式
            RectangleF rctg = new RectangleF(new PointF(0, 0), page.Canvas.ClientSize);
            PdfLinearGradientBrush brush
                = new PdfLinearGradientBrush(rctg, Color.SteelBlue, Color.Blue, PdfLinearGradientMode.Vertical);
            PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("宋體", 15f, FontStyle.Regular), true);
            String formatted
                = "Part 1 Listening(聽力部分) \n Part 2 Speaking(口語部分) \n Part 3 Reading(閱讀部分) \n Part 4 Writing(寫作部分)"
                + "\n Part 5 Test(測(cè)試) 1 \n Part 6 Test(測(cè)試) 2 \n Part 7 Test Answers(測(cè)試答案)";

            //創(chuàng)建PdfList 類對(duì)象,并設(shè)置列表及樣式
            PdfList list = new PdfList(formatted);
            list.Font = font2;
            list.Indent = 8;
            list.TextIndent = 5;
            list.Brush = brush;
            PdfLayoutResult result = list.Draw(page, 0, y);
            y = result.Bounds.Bottom;

            //保存并打開文檔
            doc.SaveToFile("List.pdf");
            System.Diagnostics.Process.Start("List.pdf");
        }
    }
}

測(cè)試結(jié)果:

C#/VB.NET 創(chuàng)建PDF項(xiàng)目符號(hào)列表和多級(jí)編號(hào)列表

VB.NET

Imports System
Imports System.Drawing
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports Spire.Pdf.Lists

Namespace CreateList_PDF

    Class Program

        Private Shared Sub Main(ByVal args As String())
            Dim doc As PdfDocument = New PdfDocument()
            Dim page As PdfPageBase = doc.Pages.Add(PdfPageSize.A4)
            Dim y As Single = 10
            Dim brush2 As PdfBrush = PdfBrushes.Black
            Dim font1 As PdfTrueTypeFont = New PdfTrueTypeFont(New Font("楷體", 18F, FontStyle.Regular), True)
            Dim format1 As PdfStringFormat = New PdfStringFormat(PdfTextAlignment.Center)
            page.Canvas.DrawString("Categories List(項(xiàng)目列表)", font1, brush2, page.Canvas.ClientSize.Width / 2, y, format1)
            y = y + font1.MeasureString("Categories List(項(xiàng)目列表)", format1).Height
            y = y + 5
            Dim rctg As RectangleF = New RectangleF(New PointF(0, 0), page.Canvas.ClientSize)
            Dim brush As PdfLinearGradientBrush = New PdfLinearGradientBrush(rctg, Color.SteelBlue, Color.Blue, PdfLinearGradientMode.Vertical)
            Dim font2 As PdfTrueTypeFont = New PdfTrueTypeFont(New Font("宋體", 15F, FontStyle.Regular), True)
            Dim formatted As String = "Part 1 Listening(聽力部分) " & vbLf & " Part 2 Speaking(口語部分) " & vbLf & " Part 3 Reading(閱讀部分) " & vbLf & " Part 4 Writing(寫作部分)" & vbLf & " Part 5 Test(測(cè)試) 1 " & vbLf & " Part 6 Test(測(cè)試) 2 " & vbLf & " Part 7 Test Answers(測(cè)試答案)"
            Dim list As PdfList = New PdfList(formatted)
            list.Font = font2
            list.Indent = 8
            list.TextIndent = 5
            list.Brush = brush
            Dim result As PdfLayoutResult = list.Draw(page, 0, y)
            y = result.Bounds.Bottom
            doc.SaveToFile("List.pdf")
            System.Diagnostics.Process.Start("List.pdf")
        End Sub
    End Class
End Namespace

2.創(chuàng)建PDF多級(jí)編號(hào)列表

Spire.Pdf.dll支持多種類型的編號(hào)類型
C#/VB.NET 創(chuàng)建PDF項(xiàng)目符號(hào)列表和多級(jí)編號(hào)列表

Csharp

using Spire.Pdf;
using Spire.Pdf.Graphics;
using Spire.Pdf.Lists;
using System;
using System.Drawing;

namespace List2
{
    class Program
    {
        static void Main(string[] args)
        {
            //新建PDF文檔,并添加一頁(yè)A4大小的空白頁(yè)面
            PdfDocument doc = new PdfDocument();
            PdfPageBase page = doc.Pages.Add(PdfPageSize.A4);

            float y = 10;

            //添加標(biāo)題并設(shè)置文本和格式
            PdfBrush brush2 = PdfBrushes.Black;
            PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("宋體", 18f, FontStyle.Regular), true);
            PdfStringFormat format1 = new PdfStringFormat(PdfTextAlignment.Center);
            page.Canvas.DrawString("目錄一覽", font1, brush2, page.Canvas.ClientSize.Width / 2, y, format1);
            y = y + font1.MeasureString("目錄一覽", format1).Height;
            y = y + 5;

            //添加文本并設(shè)置字體
            RectangleF rctg = new RectangleF(new PointF(0, 0), page.Canvas.ClientSize);
            PdfLinearGradientBrush brush
            = new PdfLinearGradientBrush(rctg, Color.DarkBlue, Color.Brown, PdfLinearGradientMode.Vertical);
            PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("宋體", 15f, FontStyle.Regular), true);
            String formatted1 = "第一章 總 論";
            String formatted2 = "第一節(jié) 經(jīng)濟(jì)法概述 ";
            String formatted3 = "第二節(jié) 經(jīng)濟(jì)法主體 ";
            String formatted4 = "第二章 公司法律制度";

            //設(shè)置編號(hào)列表樣式
            PdfOrderedMarker marker1 = new PdfOrderedMarker(PdfNumberStyle.Numeric, new PdfFont(PdfFontFamily.Helvetica, 15f));
            PdfOrderedMarker marker2 = new PdfOrderedMarker(PdfNumberStyle.LowerRoman, new PdfFont(PdfFontFamily.Helvetica, 12f));

            //為第一級(jí)編號(hào)列表設(shè)置格式
            PdfSortedList list1 = new PdfSortedList(font2);
            list1.Indent = 0;
            list1.TextIndent = 5;
            list1.Brush = brush;
            list1.Marker = marker1;

            //為第二級(jí)編號(hào)列表設(shè)置格式
            PdfSortedList list2 = new PdfSortedList(font2);
            list2.Marker = marker2;
            list2.Brush = brush;
            list2.TextIndent = 10;

            //應(yīng)用編號(hào)列表格式到指定文本
            PdfListItem item = list1.Items.Add(formatted1);
            item.SubList = list2;
            list2.Items.Add(formatted2);
            list2.Items.Add(formatted3);
            list1.Items.Add(formatted4);            

            //設(shè)置PDF文檔布局和位置
            PdfTextLayout textLayout = new PdfTextLayout();
            textLayout.Break = PdfLayoutBreakType.FitPage;
            textLayout.Layout = PdfLayoutType.Paginate;
            list1.Draw(page, new PointF(0, y), textLayout);

            //保存文件
            doc.SaveToFile("多級(jí)列表.pdf");
            System.Diagnostics.Process.Start("多級(jí)列表.pdf");
        }
    }
}

測(cè)試結(jié)果:
C#/VB.NET 創(chuàng)建PDF項(xiàng)目符號(hào)列表和多級(jí)編號(hào)列表

VB.NET

Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports Spire.Pdf.Lists
Imports System
Imports System.Drawing

Namespace List2

    Class Program

        Private Shared Sub Main(ByVal args As String())
            Dim doc As PdfDocument = New PdfDocument()
            Dim page As PdfPageBase = doc.Pages.Add(PdfPageSize.A4)
            Dim y As Single = 10
            Dim brush2 As PdfBrush = PdfBrushes.Black
            Dim font1 As PdfTrueTypeFont = New PdfTrueTypeFont(New Font("宋體", 18F, FontStyle.Regular), True)
            Dim format1 As PdfStringFormat = New PdfStringFormat(PdfTextAlignment.Center)
            page.Canvas.DrawString("目錄一覽", font1, brush2, page.Canvas.ClientSize.Width / 2, y, format1)
            y = y + font1.MeasureString("目錄一覽", format1).Height
            y = y + 5
            Dim rctg As RectangleF = New RectangleF(New PointF(0, 0), page.Canvas.ClientSize)
            Dim brush As PdfLinearGradientBrush = New PdfLinearGradientBrush(rctg, Color.DarkBlue, Color.Brown, PdfLinearGradientMode.Vertical)
            Dim font2 As PdfTrueTypeFont = New PdfTrueTypeFont(New Font("宋體", 15F, FontStyle.Regular), True)
            Dim formatted1 As String = "第一章 總 論"
            Dim formatted2 As String = "第一節(jié) 經(jīng)濟(jì)法概述 "
            Dim formatted3 As String = "第二節(jié) 經(jīng)濟(jì)法主體 "
            Dim formatted4 As String = "第二章 公司法律制度"
            Dim marker1 As PdfOrderedMarker = New PdfOrderedMarker(PdfNumberStyle.Numeric, NewPdfFont(PdfFontFamily.Helvetica, 15F))
            Dim marker2 As PdfOrderedMarker = New PdfOrderedMarker(PdfNumberStyle.LowerRoman, NewPdfFont(PdfFontFamily.Helvetica, 12F))
            Dim list1 As PdfSortedList = New PdfSortedList(font2)
            list1.Indent = 0
            list1.TextIndent = 5
            list1.Brush = brush
            list1.Marker = marker1
            Dim list2 As PdfSortedList = New PdfSortedList(font2)
            list2.Marker = marker2
            list2.Brush = brush
            list2.TextIndent = 10
            Dim item As PdfListItem = list1.Items.Add(formatted1)
            item.SubList = list2
            list2.Items.Add(formatted2)
            list2.Items.Add(formatted3)
            list1.Items.Add(formatted4)
            Dim textLayout As PdfTextLayout = New PdfTextLayout()
            textLayout.Break = PdfLayoutBreakType.FitPage
            textLayout.Layout = PdfLayoutType.Paginate
            list1.Draw(page, New PointF(0, y), textLayout)
            doc.SaveToFile("多級(jí)列表.pdf")
            System.Diagnostics.Process.Start("多級(jí)列表.pdf")
        End Sub
    End Class
End Namespace

以上內(nèi)容為本次關(guān)于“創(chuàng)建PDF項(xiàng)目標(biāo)號(hào)列表和多級(jí)編號(hào)列表”的全部?jī)?nèi)容。如需轉(zhuǎn)載,請(qǐng)注明出處。感謝閱讀!

創(chuàng)新互聯(lián)www.cdcxhl.cn,專業(yè)提供香港、美國(guó)云服務(wù)器,動(dòng)態(tài)BGP最優(yōu)骨干路由自動(dòng)選擇,持續(xù)穩(wěn)定高效的網(wǎng)絡(luò)助力業(yè)務(wù)部署。公司持有工信部辦法的idc、isp許可證, 機(jī)房獨(dú)有T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確進(jìn)行流量調(diào)度,確保服務(wù)器高可用性。佳節(jié)活動(dòng)現(xiàn)已開啟,新人活動(dòng)云服務(wù)器買多久送多久。


網(wǎng)頁(yè)題目:C#/VB.NET創(chuàng)建PDF項(xiàng)目符號(hào)列表和多級(jí)編號(hào)列表-創(chuàng)新互聯(lián)
地址分享:http://weahome.cn/article/cojppe.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部