VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.Pdf.Tree.StructureTree Namespace / PdfStructureTreeRoot Class
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
В этом разделе
    Класс PdfStructureTreeRoot
    В этом разделе
    Предоставляет информацию о корне дерева структуры PDF документа.
    Объектная модель
    PdfStructureElementDictionary PdfNameToNameDictionary PdfStructureTreeNodeList PdfDocument PdfIndirectReference PdfBasicObject PdfStructureTreeRoot
    Синтаксис
    'Declaration
    
    Public Class PdfStructureTreeRoot
       Inherits PdfStructureCompositeNode
    
    
    public class PdfStructureTreeRoot : PdfStructureCompositeNode
    
    
    public __gc class PdfStructureTreeRoot : public PdfStructureCompositeNode*
    
    
    public ref class PdfStructureTreeRoot : public PdfStructureCompositeNode^
    
    
    Пример

    Вот пример, показывающий, как создать размеченный PDF документ с древовидной структурой и помеченным текстовым клипом:

    
    ''' <summary>
    ''' Creates a tagged PDF document with structure tree and marked text clip.
    ''' </summary>
    Public Shared Sub CreateTaggedPdfWithStructureTree()
        ' create new PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument()
            ' add new page to the PDF document
            document.Pages.Add(New System.Drawing.SizeF(250, 250))
    
            ' create marked information object
            Dim markInfo As New Vintasoft.Imaging.Pdf.Tree.PdfMarkInformation(document)
            markInfo.IsMarked = True
            ' add marked information object to the PDF document
            document.MarkedInformation = markInfo
    
            ' create the structure tree element, which defines a root of structure tree
            Dim rootElement As New Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeRoot(document)
            ' add the root element to the structure tree
            document.StructureTree = rootElement
    
            ' create the structure tree element, which defines PDF document
            Dim documentElement As New Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureElement(document, "Document", rootElement)
            ' create children for root element
            rootElement.Children = New Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeNodeList(document)
            ' add the PDF document element to the childen of root element
            rootElement.Children.Add(documentElement)
    
            ' create the structure tree element, which defines PDF page
            Dim pageElement As New Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureElement(document, "Page", documentElement)
            ' associate structure tree element with the first PDF page
            pageElement.Page = document.Pages(0)
            ' create children for PDF document element
            documentElement.Children = New Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeNodeList(document)
            ' add the PDF page element to the childen of PDF document element
            documentElement.Children.Add(pageElement)
    
            ' create the structure tree element, which defines clipped text
            Dim clippedTextElement As New Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureElement(document, "ClipText", pageElement)
            ' associate structure tree element with the first PDF page
            clippedTextElement.Page = document.Pages(0)
            ' create children for PDF page element
            pageElement.Children = New Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeNodeList(document)
            ' add the clipped text element to the childen of PDF page element
            pageElement.Children.Add(clippedTextElement)
    
            ' create the marked content identifier
            Dim markedContentId As New Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfMarkedContentIdentifier(document, 1)
            ' create children for clipped text element
            clippedTextElement.Children = New Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeNodeList(document)
            ' add the marked content identifier to the childen of clipped text element
            clippedTextElement.Children.Add(markedContentId)
    
            ' get graphics object associated with page
            Using graphics As Vintasoft.Imaging.Pdf.Drawing.PdfGraphics = document.Pages(0).GetGraphics()
                ' begin the marked content with identifier "1"
                graphics.BeginMarkedContent(pageElement.StructureType, markedContentId)
    
                ' save graphics state
                graphics.SaveGraphicsState()
                ' update clip region
                graphics.IntersectClip(New System.Drawing.RectangleF(0, 50, 100, 100))
    
                ' get the PDF font
                Dim pdfFont As Vintasoft.Imaging.Pdf.Tree.Fonts.PdfFont = document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman)
                ' draw a text string
                graphics.DrawString("Text string", pdfFont, 30, New Vintasoft.Imaging.Pdf.Drawing.PdfBrush(System.Drawing.Color.Green), New System.Drawing.PointF(25, 100))
    
                ' restore graphics state
                graphics.RestoreGraphicsState()
    
                ' end the marked content
                graphics.EndMarkedContent()
            End Using
    
            ' save document
            document.SaveChanges("D:\testTaggedPdf.pdf")
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Creates a tagged PDF document with structure tree and marked text clip.
    /// </summary>
    public static void CreateTaggedPdfWithStructureTree()
    {
        // create new PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument())
        {
            // add new page to the PDF document
            document.Pages.Add(new System.Drawing.SizeF(250, 250));
    
            // create marked information object
            Vintasoft.Imaging.Pdf.Tree.PdfMarkInformation markInfo =
                new Vintasoft.Imaging.Pdf.Tree.PdfMarkInformation(document);
            markInfo.IsMarked = true;
            // add marked information object to the PDF document
            document.MarkedInformation = markInfo;
    
            // create the structure tree element, which defines a root of structure tree
            Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeRoot rootElement =
                new Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeRoot(document);
            // add the root element to the structure tree
            document.StructureTree = rootElement;
    
            // create the structure tree element, which defines PDF document
            Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureElement documentElement =
                new Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureElement(document, "Document", rootElement);
            // create children for root element
            rootElement.Children = new Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeNodeList(document);
            // add the PDF document element to the childen of root element
            rootElement.Children.Add(documentElement);
    
            // create the structure tree element, which defines PDF page
            Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureElement pageElement =
                new Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureElement(document, "Page", documentElement);
            // associate structure tree element with the first PDF page
            pageElement.Page = document.Pages[0];
            // create children for PDF document element
            documentElement.Children = new Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeNodeList(document);
            // add the PDF page element to the childen of PDF document element
            documentElement.Children.Add(pageElement);
    
            // create the structure tree element, which defines clipped text
            Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureElement clippedTextElement =
                new Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureElement(document, "ClipText", pageElement);
            // associate structure tree element with the first PDF page
            clippedTextElement.Page = document.Pages[0];
            // create children for PDF page element
            pageElement.Children = new Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeNodeList(document);
            // add the clipped text element to the childen of PDF page element
            pageElement.Children.Add(clippedTextElement);
    
            // create the marked content identifier
            Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfMarkedContentIdentifier markedContentId =
                new Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfMarkedContentIdentifier(document, 1);
            // create children for clipped text element
            clippedTextElement.Children = new Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeNodeList(document);
            // add the marked content identifier to the childen of clipped text element
            clippedTextElement.Children.Add(markedContentId);
    
            // get graphics object associated with page
            using (Vintasoft.Imaging.Pdf.Drawing.PdfGraphics graphics = document.Pages[0].GetGraphics())
            {
                // begin the marked content with identifier "1"
                graphics.BeginMarkedContent(pageElement.StructureType, markedContentId);
    
                // save graphics state
                graphics.SaveGraphicsState();
                // update clip region
                graphics.IntersectClip(new System.Drawing.RectangleF(0, 50, 100, 100));
    
                // get the PDF font
                Vintasoft.Imaging.Pdf.Tree.Fonts.PdfFont pdfFont = document.FontManager.GetStandardFont(
                    Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman);
                // draw a text string
                graphics.DrawString(
                    "Text string",
                    pdfFont,
                    30,
                    new Vintasoft.Imaging.Pdf.Drawing.PdfBrush(System.Drawing.Color.Green),
                    new System.Drawing.PointF(25, 100));
    
                // restore graphics state
                graphics.RestoreGraphicsState();
    
                // end the marked content
                graphics.EndMarkedContent();
            }
    
            // save document
            document.SaveChanges(@"D:\testTaggedPdf.pdf");
        }
    }
    
    

    Иерархия наследования

    System.Object
       Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase
          Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeNode
             Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureCompositeNode
                Vintasoft.Imaging.Pdf.Tree.StructureTree.PdfStructureTreeRoot

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также