public virtual void TagStructureRemovingTest03() { PdfWriter writer = new PdfWriter(destinationFolder + "tagStructureRemovingTest03.pdf"); writer.SetCompressionLevel(CompressionConstants.NO_COMPRESSION); PdfDocument document = new PdfDocument(writer); document.SetTagged(); PdfPage page = document.AddNewPage(); TagTreePointer tagPointer = new TagTreePointer(document); tagPointer.SetPageForTagging(page); PdfCanvas canvas = new PdfCanvas(page); tagPointer.AddTag(StandardRoles.P); WaitingTagsManager waitingTagsManager = tagPointer.GetContext().GetWaitingTagsManager(); Object pWaitingTagObj = new Object(); waitingTagsManager.AssignWaitingState(tagPointer, pWaitingTagObj); PdfFont standardFont = PdfFontFactory.CreateFont(StandardFonts.COURIER); canvas.BeginText().SetFontAndSize(standardFont, 24).SetTextMatrix(1, 0, 0, 1, 32, 512); tagPointer.AddTag(StandardRoles.SPAN); canvas.OpenTag(tagPointer.GetTagReference()).ShowText("Hello ").CloseTag(); canvas.SetFontAndSize(standardFont, 30).OpenTag(tagPointer.GetTagReference()).ShowText("World").CloseTag() .EndText(); tagPointer.MoveToParent().MoveToParent(); document.RemovePage(1); PdfPage newPage = document.AddNewPage(); canvas = new PdfCanvas(newPage); tagPointer.SetPageForTagging(newPage); waitingTagsManager.TryMovePointerToWaitingTag(tagPointer, pWaitingTagObj); tagPointer.AddTag(StandardRoles.SPAN); canvas.OpenTag(tagPointer.GetTagReference()).BeginText().SetFontAndSize(standardFont, 24).SetTextMatrix(1, 0, 0, 1, 32, 512).ShowText("Hello.").EndText().CloseTag(); document.Close(); CompareResult("tagStructureRemovingTest03.pdf", "cmp_tagStructureRemovingTest03.pdf", "diffRemoving03_"); }
public virtual void TagStructureFlushingTest06() { PdfWriter writer = new PdfWriter(destinationFolder + "tagStructureFlushingTest06.pdf"); writer.SetCompressionLevel(CompressionConstants.NO_COMPRESSION); PdfDocument document = new PdfDocument(writer); document.SetTagged(); PdfPage page1 = document.AddNewPage(); TagTreePointer tagPointer = new TagTreePointer(document); tagPointer.SetPageForTagging(page1); PdfCanvas canvas = new PdfCanvas(page1); tagPointer.AddTag(StandardRoles.DIV); tagPointer.AddTag(StandardRoles.P); canvas.BeginText(); PdfFont standardFont = PdfFontFactory.CreateFont(StandardFonts.COURIER); canvas.SetFontAndSize(standardFont, 24).SetTextMatrix(1, 0, 0, 1, 32, 512); tagPointer.AddTag(StandardRoles.SPAN); WaitingTagsManager waitingTagsManager = document.GetTagStructureContext().GetWaitingTagsManager(); Object associatedObj = new Object(); waitingTagsManager.AssignWaitingState(tagPointer, associatedObj); canvas.OpenTag(tagPointer.GetTagReference()).ShowText("Hello ").CloseTag(); canvas.SetFontAndSize(standardFont, 30).OpenTag(tagPointer.GetTagReference()).ShowText("World").CloseTag(); canvas.EndText().Release(); page1.Flush(); tagPointer.RelocateKid(0, new TagTreePointer(document).MoveToKid(StandardRoles.DIV).SetNextNewKidIndex(0). AddTag(StandardRoles.P)); tagPointer.RemoveTag(); waitingTagsManager.RemoveWaitingState(associatedObj); document.GetTagStructureContext().FlushPageTags(page1); document.GetStructTreeRoot().CreateParentTreeEntryForPage(page1); document.Close(); CompareResult("tagStructureFlushingTest06.pdf", "cmp_tagStructureFlushingTest06.pdf", "diffFlushing06_"); }