diff --git a/src/CoreGraphics/CGContextPDF.cs b/src/CoreGraphics/CGContextPDF.cs
index ceb517dc4112..d16cc79721ed 100644
--- a/src/CoreGraphics/CGContextPDF.cs
+++ b/src/CoreGraphics/CGContextPDF.cs
@@ -510,6 +510,123 @@ public void SetPageTagStructureTree (NSDictionary pageTagStructureTreeDictionary
GC.KeepAlive (pageTagStructureTreeDictionary);
}
+#if !__TVOS__
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern IntPtr CGPDFContextBeginMarkedContentSequence (IntPtr context, CGPdfTagType tagType);
+
+ /// Begins a structural marked-content sequence.
+ /// The structure tag for the marked content.
+ /// The marked-content item to add to a structure element, or if another structural sequence is already open.
+ /// Use a structural tag such as or , and balance each successful call with . is not valid for structural marked content.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public CGPDFMarkedContentItem? BeginMarkedContentSequence (CGPdfTagType tagType)
+ {
+ var handle = CGPDFContextBeginMarkedContentSequence (GetCheckedHandle (), tagType);
+ return handle == IntPtr.Zero ? null : new CGPDFMarkedContentItem (handle, owns: true);
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern void CGPDFContextBeginNonStructuralMarkedContentSequence (IntPtr context, CGPdfTagType tagType);
+
+ /// Begins a marked-content sequence that is excluded from the document's logical structure.
+ /// The non-structural tag for the marked content.
+ /// Use for non-structural content and balance this call with . is a structural grouping tag and is not valid here.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public void BeginNonStructuralMarkedContentSequence (CGPdfTagType tagType)
+ {
+ CGPDFContextBeginNonStructuralMarkedContentSequence (GetCheckedHandle (), tagType);
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern void CGPDFContextEndMarkedContentSequence (IntPtr context);
+
+ /// Ends the current structural or non-structural marked-content sequence.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public void EndMarkedContentSequence ()
+ {
+ CGPDFContextEndMarkedContentSequence (GetCheckedHandle ());
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern IntPtr CGPDFContextBeginObjectReference (IntPtr context);
+
+ /// Begins a reference to a single object drawn into the PDF context.
+ /// The marked-content item to add to a structure element, or if the reference could not be created.
+ /// Draw exactly one object before calling .
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public CGPDFMarkedContentItem? BeginObjectReference ()
+ {
+ var handle = CGPDFContextBeginObjectReference (GetCheckedHandle ());
+ return handle == IntPtr.Zero ? null : new CGPDFMarkedContentItem (handle, owns: true);
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern void CGPDFContextEndObjectReference (IntPtr context);
+
+ /// Ends the current object reference.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public void EndObjectReference ()
+ {
+ CGPDFContextEndObjectReference (GetCheckedHandle ());
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern OSStatus CGPDFContextAddStructureTreeRootChild (IntPtr context, IntPtr structureElement);
+
+ /// Adds a structure element as a child of the PDF document's structure-tree root.
+ /// The structure element to add.
+ /// An OSStatus value, where zero indicates success.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public OSStatus AddStructureTreeRootChild (CGPDFStructureElement structureElement)
+ {
+ var status = CGPDFContextAddStructureTreeRootChild (GetCheckedHandle (), structureElement.GetNonNullHandle (nameof (structureElement)));
+ GC.KeepAlive (structureElement);
+ return status;
+ }
+#endif // !__TVOS__
+
///
protected override void Dispose (bool disposing)
{
diff --git a/src/CoreGraphics/CGEnums.cs b/src/CoreGraphics/CGEnums.cs
index 02e76f13e9a1..ac4cc55c56f0 100644
--- a/src/CoreGraphics/CGEnums.cs
+++ b/src/CoreGraphics/CGEnums.cs
@@ -228,6 +228,9 @@ public enum CGPdfTagType /* int32_t */ {
Form,
[TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
Object = 800,
+ /// A non-structural tag for content that should be excluded from the document's logical structure.
+ [NoTV, Mac (27, 0), iOS (27, 0), MacCatalyst (27, 0)]
+ Artifact = 900,
}
// untyped enum -> CGPDFObject.h
diff --git a/src/CoreGraphics/CGPDFMarkedContentItem.cs b/src/CoreGraphics/CGPDFMarkedContentItem.cs
new file mode 100644
index 000000000000..f67cd9bc9f35
--- /dev/null
+++ b/src/CoreGraphics/CGPDFMarkedContentItem.cs
@@ -0,0 +1,58 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#nullable enable
+
+#if !__TVOS__
+
+using System.Diagnostics.CodeAnalysis;
+using CoreFoundation;
+
+namespace CoreGraphics {
+
+ /// Represents the association between drawn PDF content and its place in a PDF structure tree.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public class CGPDFMarkedContentItem : NativeObject {
+
+ [DynamicDependency (DynamicallyAccessedMemberTypes.NonPublicConstructors, typeof (CGPDFMarkedContentItem))]
+ static CGPDFMarkedContentItem ()
+ {
+ }
+
+ internal CGPDFMarkedContentItem (NativeHandle handle, bool owns)
+ : base (handle, owns)
+ {
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern IntPtr CGPDFMarkedContentItemRetain (IntPtr markedContentItem);
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern void CGPDFMarkedContentItemRelease (IntPtr markedContentItem);
+
+ ///
+ protected internal override void Retain ()
+ {
+ CGPDFMarkedContentItemRetain (GetCheckedHandle ());
+ }
+
+ ///
+ protected internal override void Release ()
+ {
+ CGPDFMarkedContentItemRelease (GetCheckedHandle ());
+ }
+ }
+}
+
+#endif // !__TVOS__
diff --git a/src/CoreGraphics/CGPDFStructureElement.cs b/src/CoreGraphics/CGPDFStructureElement.cs
new file mode 100644
index 000000000000..a09088b835a7
--- /dev/null
+++ b/src/CoreGraphics/CGPDFStructureElement.cs
@@ -0,0 +1,249 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#nullable enable
+
+#if !__TVOS__
+
+using System.Diagnostics.CodeAnalysis;
+using CoreFoundation;
+
+namespace CoreGraphics {
+
+ /// Represents an element in a PDF document's logical structure tree.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public class CGPDFStructureElement : NativeObject {
+
+ [DynamicDependency (DynamicallyAccessedMemberTypes.NonPublicConstructors, typeof (CGPDFStructureElement))]
+ static CGPDFStructureElement ()
+ {
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern IntPtr CGPDFStructureElementCreate (CGPdfTagType tagType);
+
+ /// Creates a structure element with the specified PDF structure tag.
+ /// The structure tag for the new element.
+ /// Use a structural tag such as or . is non-structural and is not valid for structure elements.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public CGPDFStructureElement (CGPdfTagType tagType)
+ : base (CGPDFStructureElementCreate (tagType), owns: true)
+ {
+ }
+
+ internal CGPDFStructureElement (NativeHandle handle, bool owns)
+ : base (handle, owns)
+ {
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern IntPtr CGPDFStructureElementRetain (IntPtr structureElement);
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern void CGPDFStructureElementRelease (IntPtr structureElement);
+
+ ///
+ protected internal override void Retain ()
+ {
+ CGPDFStructureElementRetain (GetCheckedHandle ());
+ }
+
+ ///
+ protected internal override void Release ()
+ {
+ CGPDFStructureElementRelease (GetCheckedHandle ());
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern void CGPDFStructureElementSetTitle (IntPtr structureElement, IntPtr title);
+
+ /// Sets the title of the structure element.
+ /// The title to set.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public void SetTitle (string title)
+ {
+ if (title is null)
+ ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (title));
+
+ var titleHandle = CFString.CreateNative (title);
+ try {
+ CGPDFStructureElementSetTitle (GetCheckedHandle (), titleHandle);
+ } finally {
+ CFString.ReleaseNative (titleHandle);
+ }
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern void CGPDFStructureElementSetLanguageIdentifier (IntPtr structureElement, IntPtr languageIdentifier);
+
+ /// Sets the language identifier of the structure element.
+ /// The language identifier to set.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public void SetLanguageIdentifier (string languageIdentifier)
+ {
+ if (languageIdentifier is null)
+ ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (languageIdentifier));
+
+ var languageIdentifierHandle = CFString.CreateNative (languageIdentifier);
+ try {
+ CGPDFStructureElementSetLanguageIdentifier (GetCheckedHandle (), languageIdentifierHandle);
+ } finally {
+ CFString.ReleaseNative (languageIdentifierHandle);
+ }
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern void CGPDFStructureElementSetAlternativeText (IntPtr structureElement, IntPtr alternativeText);
+
+ /// Sets alternative text for the structure element.
+ /// The alternative text to set.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public void SetAlternativeText (string alternativeText)
+ {
+ if (alternativeText is null)
+ ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (alternativeText));
+
+ var alternativeTextHandle = CFString.CreateNative (alternativeText);
+ try {
+ CGPDFStructureElementSetAlternativeText (GetCheckedHandle (), alternativeTextHandle);
+ } finally {
+ CFString.ReleaseNative (alternativeTextHandle);
+ }
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern void CGPDFStructureElementSetExpansionText (IntPtr structureElement, IntPtr expansionText);
+
+ /// Sets the expanded form of an abbreviation in the structure element.
+ /// The expansion text to set.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public void SetExpansionText (string expansionText)
+ {
+ if (expansionText is null)
+ ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (expansionText));
+
+ var expansionTextHandle = CFString.CreateNative (expansionText);
+ try {
+ CGPDFStructureElementSetExpansionText (GetCheckedHandle (), expansionTextHandle);
+ } finally {
+ CFString.ReleaseNative (expansionTextHandle);
+ }
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern void CGPDFStructureElementSetActualText (IntPtr structureElement, IntPtr actualText);
+
+ /// Sets replacement text for the content associated with the structure element.
+ /// The replacement text to set.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public void SetActualText (string actualText)
+ {
+ if (actualText is null)
+ ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (actualText));
+
+ var actualTextHandle = CFString.CreateNative (actualText);
+ try {
+ CGPDFStructureElementSetActualText (GetCheckedHandle (), actualTextHandle);
+ } finally {
+ CFString.ReleaseNative (actualTextHandle);
+ }
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern OSStatus CGPDFStructureElementAddStructureElement (IntPtr structureElement, IntPtr childStructureElement);
+
+ /// Adds a child structure element.
+ /// The child structure element to add.
+ /// An OSStatus value, where zero indicates success.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public OSStatus AddChild (CGPDFStructureElement child)
+ {
+ var status = CGPDFStructureElementAddStructureElement (GetCheckedHandle (), child.GetNonNullHandle (nameof (child)));
+ GC.KeepAlive (child);
+ return status;
+ }
+
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ [DllImport (Constants.CoreGraphicsLibrary)]
+ static extern OSStatus CGPDFStructureElementAddMarkedContentItem (IntPtr structureElement, IntPtr markedContentItem);
+
+ /// Adds marked content to the structure element.
+ /// The marked-content item to add.
+ /// An OSStatus value, where zero indicates success.
+ [SupportedOSPlatform ("ios27.0")]
+ [SupportedOSPlatform ("maccatalyst27.0")]
+ [SupportedOSPlatform ("macos27.0")]
+ [UnsupportedOSPlatform ("tvos")]
+ public OSStatus AddMarkedContentItem (CGPDFMarkedContentItem markedContentItem)
+ {
+ var status = CGPDFStructureElementAddMarkedContentItem (GetCheckedHandle (), markedContentItem.GetNonNullHandle (nameof (markedContentItem)));
+ GC.KeepAlive (markedContentItem);
+ return status;
+ }
+ }
+}
+
+#endif // !__TVOS__
diff --git a/src/frameworks.sources b/src/frameworks.sources
index 8f702ff85d1e..5014a65656ad 100644
--- a/src/frameworks.sources
+++ b/src/frameworks.sources
@@ -542,12 +542,14 @@ COREGRAPHICS_SOURCES = \
CoreGraphics/CGPDFArray.cs \
CoreGraphics/CGPDFContentStream.cs \
CoreGraphics/CGPDFDictionary.cs \
+ CoreGraphics/CGPDFMarkedContentItem.cs \
CoreGraphics/CGPDFObject.cs \
CoreGraphics/CGPDFOperatorTable.cs \
CoreGraphics/CGPDFPage.cs \
CoreGraphics/CGPDFScanner.cs \
CoreGraphics/CGPDFStream.cs \
CoreGraphics/CGPDFString.cs \
+ CoreGraphics/CGPDFStructureElement.cs \
CoreGraphics/CGPdfTagType.cs \
CoreGraphics/CGRenderingBufferProvider.cs \
CoreGraphics/CGSession.cs \
diff --git a/tests/monotouch-test/CoreGraphics/PDFStructureElementTest.cs b/tests/monotouch-test/CoreGraphics/PDFStructureElementTest.cs
new file mode 100644
index 000000000000..6b2fcdded6b5
--- /dev/null
+++ b/tests/monotouch-test/CoreGraphics/PDFStructureElementTest.cs
@@ -0,0 +1,108 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#if !__TVOS__
+
+using CoreGraphics;
+
+namespace MonoTouchFixtures.CoreGraphics {
+
+ [TestFixture]
+ [Preserve (AllMembers = true)]
+ public class PDFStructureElementTest {
+
+ [Test]
+ public void SettersAndChildren ()
+ {
+ TestRuntime.AssertXcodeVersion (27, 0);
+
+ using var root = new CGPDFStructureElement (CGPdfTagType.Document);
+ using var child = new CGPDFStructureElement (CGPdfTagType.Paragraph);
+
+ child.SetTitle ("Title");
+ child.SetLanguageIdentifier ("en");
+ child.SetAlternativeText ("Alternative");
+ child.SetExpansionText ("Expansion");
+ child.SetActualText ("Actual");
+
+ Assert.That (root.AddChild (child), Is.Zero, "AddChild");
+
+ Assert.Throws (() => child.SetTitle (null), "SetTitle");
+ Assert.Throws (() => child.SetLanguageIdentifier (null), "SetLanguageIdentifier");
+ Assert.Throws (() => child.SetAlternativeText (null), "SetAlternativeText");
+ Assert.Throws (() => child.SetExpansionText (null), "SetExpansionText");
+ Assert.Throws (() => child.SetActualText (null), "SetActualText");
+ Assert.Throws (() => root.AddChild (null), "AddChild null");
+ Assert.Throws (() => root.AddMarkedContentItem (null), "AddMarkedContentItem null");
+ }
+
+ [Test]
+ public void TaggedPdfAuthoring ()
+ {
+ TestRuntime.AssertXcodeVersion (27, 0);
+
+ var mediaBox = new CGRect (0, 0, 100, 100);
+ using var data = new NSMutableData ();
+ using var consumer = new CGDataConsumer (data);
+ using var context = new CGContextPDF (consumer, mediaBox);
+ using var root = new CGPDFStructureElement (CGPdfTagType.Document);
+ using var paragraph = new CGPDFStructureElement (CGPdfTagType.Paragraph);
+ using var objectElement = new CGPDFStructureElement (CGPdfTagType.Object);
+
+ Assert.Throws (() => context.AddStructureTreeRootChild (null), "Add root null");
+ Assert.That (root.AddChild (paragraph), Is.Zero, "Add paragraph");
+ Assert.That (root.AddChild (objectElement), Is.Zero, "Add object");
+ Assert.That (context.AddStructureTreeRootChild (root), Is.Zero, "Add root");
+
+ context.BeginPage (null);
+ try {
+ using var markedContentItem = context.BeginMarkedContentSequence (CGPdfTagType.Paragraph);
+ Assert.That (markedContentItem, Is.Not.Null, "Marked content");
+ if (markedContentItem is not null) {
+ try {
+ context.FillRect (new CGRect (10, 10, 20, 20));
+ } finally {
+ context.EndMarkedContentSequence ();
+ }
+ Assert.That (paragraph.AddMarkedContentItem (markedContentItem), Is.Zero, "Add marked content");
+ }
+
+ context.BeginNonStructuralMarkedContentSequence (CGPdfTagType.Artifact);
+ try {
+ context.FillRect (new CGRect (40, 10, 20, 20));
+ } finally {
+ context.EndMarkedContentSequence ();
+ }
+
+ byte [] imageData = new byte [4];
+ using var colorSpace = CGColorSpace.CreateDeviceRGB ();
+ using var bitmapContext = new CGBitmapContext (imageData, 1, 1, 8, 4, colorSpace, CGBitmapFlags.PremultipliedLast);
+ using var image = bitmapContext.ToImage ();
+ Assert.That (image, Is.Not.Null, "Image");
+
+ using var objectReference = context.BeginObjectReference ();
+ Assert.That (objectReference, Is.Not.Null, "Object reference");
+ if (objectReference is not null) {
+ try {
+ context.DrawImage (new CGRect (10, 40, 20, 20), image);
+ } finally {
+ context.EndObjectReference ();
+ }
+ Assert.That (objectElement.AddMarkedContentItem (objectReference), Is.Zero, "Add object reference");
+ }
+ } finally {
+ context.EndPage ();
+ }
+
+ context.Close ();
+ Assert.That (data.Length, Is.GreaterThan ((nuint) 0), "PDF data");
+
+ using var provider = new CGDataProvider (data);
+ using var document = new CGPDFDocument (provider);
+ Assert.That (document.Pages, Is.EqualTo ((nint) 1), "Pages");
+ Assert.That (document.GetCatalog ().GetDictionary ("StructTreeRoot", out _), Is.True, "StructTreeRoot");
+ }
+ }
+}
+
+#endif // !__TVOS__
diff --git a/tests/monotouch-test/CoreGraphics/PdfTagTypeTest.cs b/tests/monotouch-test/CoreGraphics/PdfTagTypeTest.cs
index 078d1c45debe..9723540306c1 100644
--- a/tests/monotouch-test/CoreGraphics/PdfTagTypeTest.cs
+++ b/tests/monotouch-test/CoreGraphics/PdfTagTypeTest.cs
@@ -65,5 +65,15 @@ public void EnumExtension ()
Assert.That (CGPdfTagType.Formula.GetName (), Is.EqualTo ("/Formula"), "Formula");
Assert.That (CGPdfTagType.Form.GetName (), Is.EqualTo ("/Form"), "Form");
}
+
+#if !__TVOS__
+ [Test]
+ public void Artifact ()
+ {
+ TestRuntime.AssertXcodeVersion (27, 0);
+ Assert.That ((int) CGPdfTagType.Artifact, Is.EqualTo (900), "Value");
+ Assert.That (CGPdfTagType.Artifact.GetName (), Is.EqualTo ("/Artifact"), "Name");
+ }
+#endif
}
}
diff --git a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreGraphics.todo b/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreGraphics.todo
deleted file mode 100644
index e83d89640d15..000000000000
--- a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreGraphics.todo
+++ /dev/null
@@ -1,19 +0,0 @@
-!missing-enum-value! CGPdfTagType native value CGPDFTagTypeArtifact = 900 not bound
-!missing-pinvoke! CGPDFContextAddStructureTreeRootChild is not bound
-!missing-pinvoke! CGPDFContextBeginMarkedContentSequence is not bound
-!missing-pinvoke! CGPDFContextBeginNonStructuralMarkedContentSequence is not bound
-!missing-pinvoke! CGPDFContextBeginObjectReference is not bound
-!missing-pinvoke! CGPDFContextEndMarkedContentSequence is not bound
-!missing-pinvoke! CGPDFContextEndObjectReference is not bound
-!missing-pinvoke! CGPDFMarkedContentItemRelease is not bound
-!missing-pinvoke! CGPDFMarkedContentItemRetain is not bound
-!missing-pinvoke! CGPDFStructureElementAddMarkedContentItem is not bound
-!missing-pinvoke! CGPDFStructureElementAddStructureElement is not bound
-!missing-pinvoke! CGPDFStructureElementCreate is not bound
-!missing-pinvoke! CGPDFStructureElementRelease is not bound
-!missing-pinvoke! CGPDFStructureElementRetain is not bound
-!missing-pinvoke! CGPDFStructureElementSetActualText is not bound
-!missing-pinvoke! CGPDFStructureElementSetAlternativeText is not bound
-!missing-pinvoke! CGPDFStructureElementSetExpansionText is not bound
-!missing-pinvoke! CGPDFStructureElementSetLanguageIdentifier is not bound
-!missing-pinvoke! CGPDFStructureElementSetTitle is not bound
diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreGraphics.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreGraphics.todo
deleted file mode 100644
index e83d89640d15..000000000000
--- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreGraphics.todo
+++ /dev/null
@@ -1,19 +0,0 @@
-!missing-enum-value! CGPdfTagType native value CGPDFTagTypeArtifact = 900 not bound
-!missing-pinvoke! CGPDFContextAddStructureTreeRootChild is not bound
-!missing-pinvoke! CGPDFContextBeginMarkedContentSequence is not bound
-!missing-pinvoke! CGPDFContextBeginNonStructuralMarkedContentSequence is not bound
-!missing-pinvoke! CGPDFContextBeginObjectReference is not bound
-!missing-pinvoke! CGPDFContextEndMarkedContentSequence is not bound
-!missing-pinvoke! CGPDFContextEndObjectReference is not bound
-!missing-pinvoke! CGPDFMarkedContentItemRelease is not bound
-!missing-pinvoke! CGPDFMarkedContentItemRetain is not bound
-!missing-pinvoke! CGPDFStructureElementAddMarkedContentItem is not bound
-!missing-pinvoke! CGPDFStructureElementAddStructureElement is not bound
-!missing-pinvoke! CGPDFStructureElementCreate is not bound
-!missing-pinvoke! CGPDFStructureElementRelease is not bound
-!missing-pinvoke! CGPDFStructureElementRetain is not bound
-!missing-pinvoke! CGPDFStructureElementSetActualText is not bound
-!missing-pinvoke! CGPDFStructureElementSetAlternativeText is not bound
-!missing-pinvoke! CGPDFStructureElementSetExpansionText is not bound
-!missing-pinvoke! CGPDFStructureElementSetLanguageIdentifier is not bound
-!missing-pinvoke! CGPDFStructureElementSetTitle is not bound
diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreGraphics.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreGraphics.todo
deleted file mode 100644
index e83d89640d15..000000000000
--- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreGraphics.todo
+++ /dev/null
@@ -1,19 +0,0 @@
-!missing-enum-value! CGPdfTagType native value CGPDFTagTypeArtifact = 900 not bound
-!missing-pinvoke! CGPDFContextAddStructureTreeRootChild is not bound
-!missing-pinvoke! CGPDFContextBeginMarkedContentSequence is not bound
-!missing-pinvoke! CGPDFContextBeginNonStructuralMarkedContentSequence is not bound
-!missing-pinvoke! CGPDFContextBeginObjectReference is not bound
-!missing-pinvoke! CGPDFContextEndMarkedContentSequence is not bound
-!missing-pinvoke! CGPDFContextEndObjectReference is not bound
-!missing-pinvoke! CGPDFMarkedContentItemRelease is not bound
-!missing-pinvoke! CGPDFMarkedContentItemRetain is not bound
-!missing-pinvoke! CGPDFStructureElementAddMarkedContentItem is not bound
-!missing-pinvoke! CGPDFStructureElementAddStructureElement is not bound
-!missing-pinvoke! CGPDFStructureElementCreate is not bound
-!missing-pinvoke! CGPDFStructureElementRelease is not bound
-!missing-pinvoke! CGPDFStructureElementRetain is not bound
-!missing-pinvoke! CGPDFStructureElementSetActualText is not bound
-!missing-pinvoke! CGPDFStructureElementSetAlternativeText is not bound
-!missing-pinvoke! CGPDFStructureElementSetExpansionText is not bound
-!missing-pinvoke! CGPDFStructureElementSetLanguageIdentifier is not bound
-!missing-pinvoke! CGPDFStructureElementSetTitle is not bound