public static void Run() { // ExStart:TextStructureElements // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Create Pdf Document Document document = new Document(); // Get Content for work with TaggedPdf ITaggedContent taggedContent = document.TaggedContent; // Set Title and Language for Documnet taggedContent.SetTitle("Tagged Pdf Document"); taggedContent.SetLanguage("en-US"); // Get Root Structure Elements StructureElement rootElement = taggedContent.RootElement; ParagraphElement p = taggedContent.CreateParagraphElement(); // Set Text to Text Structure Element p.SetText("Paragraph."); rootElement.AppendChild(p); // Save Tagged Pdf Document document.Save(dataDir + "TextStructureElement.pdf"); // ExEnd:TextStructureElements }
static void Main() { var inputFileName = "non-compliant.pdf"; var outputFileName = "compliant.pdf"; // Use some helper functions to create an example non-PDf/UA-compliant PDF Helpers.CreateDemoNonCompliantPdfFile(inputFileName); using (var d = new Document(inputFileName)) { bool isValid = d.Validate("non-compliant-validation-log.xml", Aspose.Pdf.PdfFormat.PDF_UA_1); } var originalDocument = new Document(inputFileName); var pageOne = originalDocument.Pages[1]; // Create our new tagged document var taggedDocument = new Document(); ITaggedContent taggedContent = taggedDocument.TaggedContent; StructureElement rootElement = taggedContent.RootElement; // Set meta data required by PDF/UA taggedContent.SetTitle("Our compliant document."); taggedContent.SetLanguage("en-US"); // Extract from original PDF and create new structured elements for tagged PDF HeaderElement h1 = ExtractToHeaderElement(taggedContent, pageOne, 1, 1); ParagraphElement p = ExtractToParagraphElement(taggedContent, pageOne, 2); FigureElement figureElement = ExtractToFigureElement(taggedContent, pageOne, 1); // Append to new tagged content in desired order, which will build structure tree up from the 'root' rootElement.AppendChild(h1); rootElement.AppendChild(figureElement); rootElement.AppendChild(p); // Save and validate the compliant PDF taggedDocument.Save(outputFileName); using (var d = new Document(outputFileName)) { bool isValid = d.Validate("compliant-validation-log.xml", Aspose.Pdf.PdfFormat.PDF_UA_1); } }
public static void Run() { // ExStart:TextBlockStructureElements // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Create Pdf Document Document document = new Document(); // Get Content for work with TaggedPdf ITaggedContent taggedContent = document.TaggedContent; // Set Title and Language for Documnet taggedContent.SetTitle("Tagged Pdf Document"); taggedContent.SetLanguage("en-US"); // Get Root Structure Element StructureElement rootElement = taggedContent.RootElement; HeaderElement h1 = taggedContent.CreateHeaderElement(1); HeaderElement h2 = taggedContent.CreateHeaderElement(2); HeaderElement h3 = taggedContent.CreateHeaderElement(3); HeaderElement h4 = taggedContent.CreateHeaderElement(4); HeaderElement h5 = taggedContent.CreateHeaderElement(5); HeaderElement h6 = taggedContent.CreateHeaderElement(6); h1.SetText("H1. Header of Level 1"); h2.SetText("H2. Header of Level 2"); h3.SetText("H3. Header of Level 3"); h4.SetText("H4. Header of Level 4"); h5.SetText("H5. Header of Level 5"); h6.SetText("H6. Header of Level 6"); rootElement.AppendChild(h1); rootElement.AppendChild(h2); rootElement.AppendChild(h3); rootElement.AppendChild(h4); rootElement.AppendChild(h5); rootElement.AppendChild(h6); ParagraphElement p = taggedContent.CreateParagraphElement(); p.SetText("P. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean nec lectus ac sem faucibus imperdiet. Sed ut erat ac magna ullamcorper hendrerit. Cras pellentesque libero semper, gravida magna sed, luctus leo. Fusce lectus odio, laoreet nec ullamcorper ut, molestie eu elit. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aliquam lacinia sit amet elit ac consectetur. Donec cursus condimentum ligula, vitae volutpat sem tristique eget. Nulla in consectetur massa. Vestibulum vitae lobortis ante. Nulla ullamcorper pellentesque justo rhoncus accumsan. Mauris ornare eu odio non lacinia. Aliquam massa leo, rhoncus ac iaculis eget, tempus et magna. Sed non consectetur elit. Sed vulputate, quam sed lacinia luctus, ipsum nibh fringilla purus, vitae posuere risus odio id massa. Cras sed venenatis lacus."); rootElement.AppendChild(p); // Save Tagged Pdf Document document.Save(dataDir + "TextBlockStructureElements.pdf"); // ExEnd:TextBlockStructureElements }
public static void Run() { // ExStart:StructureElementsProperties // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Create Pdf Document Document document = new Document(); // Get Content for work with TaggedPdf ITaggedContent taggedContent = document.TaggedContent; // Set Title and Language for Documnet taggedContent.SetTitle("Tagged Pdf Document"); taggedContent.SetLanguage("en-US"); // Create Structure Elements StructureElement rootElement = taggedContent.RootElement; SectElement sect = taggedContent.CreateSectElement(); rootElement.AppendChild(sect); HeaderElement h1 = taggedContent.CreateHeaderElement(1); sect.AppendChild(h1); h1.SetText("The Header"); h1.Title = "Title"; h1.Language = "en-US"; h1.AlternativeText = "Alternative Text"; h1.ExpansionText = "Expansion Text"; h1.ActualText = "Actual Text"; // Save Tagged Pdf Document document.Save(dataDir + "StructureElementsProperties.pdf"); // ExEnd:StructureElementsProperties }
/// <summary> /// This feature is supported by version 19.6 or greater /// </summary> public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Create document Document document = new Document(); ITaggedContent taggedContent = document.TaggedContent; taggedContent.SetTitle("Example table row style"); taggedContent.SetLanguage("en-US"); // Get root structure element StructureElement rootElement = taggedContent.RootElement; // Create table structure element TableElement tableElement = taggedContent.CreateTableElement(); rootElement.AppendChild(tableElement); TableTHeadElement tableTHeadElement = tableElement.CreateTHead(); TableTBodyElement tableTBodyElement = tableElement.CreateTBody(); TableTFootElement tableTFootElement = tableElement.CreateTFoot(); int rowCount = 7; int colCount = 3; int rowIndex; int colIndex; TableTRElement headTrElement = tableTHeadElement.CreateTR(); headTrElement.AlternativeText = "Head Row"; for (colIndex = 0; colIndex < colCount; colIndex++) { TableTHElement thElement = headTrElement.CreateTH(); thElement.SetText(String.Format("Head {0}", colIndex)); } for (rowIndex = 0; rowIndex < rowCount; rowIndex++) { TableTRElement trElement = tableTBodyElement.CreateTR(); trElement.AlternativeText = String.Format("Row {0}", rowIndex); trElement.BackgroundColor = Color.LightGoldenrodYellow; trElement.Border = new BorderInfo(BorderSide.All, 0.75F, Color.DarkGray); trElement.DefaultCellBorder = new BorderInfo(BorderSide.All, 0.50F, Color.Blue); trElement.MinRowHeight = 100.0; trElement.FixedRowHeight = 120.0; trElement.IsInNewPage = (rowIndex % 3 == 1); trElement.IsRowBroken = true; TextState cellTextState = new TextState(); cellTextState.ForegroundColor = Color.Red; trElement.DefaultCellTextState = cellTextState; trElement.DefaultCellPadding = new MarginInfo(16.0, 2.0, 8.0, 2.0); trElement.VerticalAlignment = VerticalAlignment.Bottom; for (colIndex = 0; colIndex < colCount; colIndex++) { TableTDElement tdElement = trElement.CreateTD(); tdElement.SetText(String.Format("Cell [{0}, {1}]", rowIndex, colIndex)); } } TableTRElement footTrElement = tableTFootElement.CreateTR(); footTrElement.AlternativeText = "Foot Row"; for (colIndex = 0; colIndex < colCount; colIndex++) { TableTDElement tdElement = footTrElement.CreateTD(); tdElement.SetText(String.Format("Foot {0}", colIndex)); } // Save Tagged Pdf Document document.Save(dataDir + "StyleTableRow.pdf"); // Checking PDF/UA compliance document = new Document(dataDir + "StyleTableRow.pdf"); bool isPdfUaCompliance = document.Validate(dataDir + "StyleTableRow.xml", PdfFormat.PDF_UA_1); Console.WriteLine(String.Format("PDF/UA compliance: {0}", isPdfUaCompliance)); // ExEnd:1 }
public static void Run() { // ExStart:InlineStructureElements // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Create Pdf Document Document document = new Document(); // Get Content for work with TaggedPdf ITaggedContent taggedContent = document.TaggedContent; // Set Title and Language for Documnet taggedContent.SetTitle("Tagged Pdf Document"); taggedContent.SetLanguage("en-US"); // Get Root Structure Element StructureElement rootElement = taggedContent.RootElement; HeaderElement h1 = taggedContent.CreateHeaderElement(1); HeaderElement h2 = taggedContent.CreateHeaderElement(2); HeaderElement h3 = taggedContent.CreateHeaderElement(3); HeaderElement h4 = taggedContent.CreateHeaderElement(4); HeaderElement h5 = taggedContent.CreateHeaderElement(5); HeaderElement h6 = taggedContent.CreateHeaderElement(6); rootElement.AppendChild(h1); rootElement.AppendChild(h2); rootElement.AppendChild(h3); rootElement.AppendChild(h4); rootElement.AppendChild(h5); rootElement.AppendChild(h6); SpanElement spanH11 = taggedContent.CreateSpanElement(); spanH11.SetText("H1. "); h1.AppendChild(spanH11); SpanElement spanH12 = taggedContent.CreateSpanElement(); spanH12.SetText("Level 1 Header"); h1.AppendChild(spanH12); SpanElement spanH21 = taggedContent.CreateSpanElement(); spanH21.SetText("H2. "); h2.AppendChild(spanH21); SpanElement spanH22 = taggedContent.CreateSpanElement(); spanH22.SetText("Level 2 Header"); h2.AppendChild(spanH22); SpanElement spanH31 = taggedContent.CreateSpanElement(); spanH31.SetText("H3. "); h3.AppendChild(spanH31); SpanElement spanH32 = taggedContent.CreateSpanElement(); spanH32.SetText("Level 3 Header"); h3.AppendChild(spanH32); SpanElement spanH41 = taggedContent.CreateSpanElement(); spanH41.SetText("H4. "); h4.AppendChild(spanH41); SpanElement spanH42 = taggedContent.CreateSpanElement(); spanH42.SetText("Level 4 Header"); h4.AppendChild(spanH42); SpanElement spanH51 = taggedContent.CreateSpanElement(); spanH51.SetText("H5. "); h5.AppendChild(spanH51); SpanElement spanH52 = taggedContent.CreateSpanElement(); spanH52.SetText("Level 5 Header"); h5.AppendChild(spanH52); SpanElement spanH61 = taggedContent.CreateSpanElement(); spanH61.SetText("H6. "); h6.AppendChild(spanH61); SpanElement spanH62 = taggedContent.CreateSpanElement(); spanH62.SetText("Level 6 Header"); h6.AppendChild(spanH62); ParagraphElement p = taggedContent.CreateParagraphElement(); p.SetText("P. "); rootElement.AppendChild(p); SpanElement span1 = taggedContent.CreateSpanElement(); span1.SetText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "); p.AppendChild(span1); SpanElement span2 = taggedContent.CreateSpanElement(); span2.SetText("Aenean nec lectus ac sem faucibus imperdiet. "); p.AppendChild(span2); SpanElement span3 = taggedContent.CreateSpanElement(); span3.SetText("Sed ut erat ac magna ullamcorper hendrerit. "); p.AppendChild(span3); SpanElement span4 = taggedContent.CreateSpanElement(); span4.SetText("Cras pellentesque libero semper, gravida magna sed, luctus leo. "); p.AppendChild(span4); SpanElement span5 = taggedContent.CreateSpanElement(); span5.SetText("Fusce lectus odio, laoreet nec ullamcorper ut, molestie eu elit. "); p.AppendChild(span5); SpanElement span6 = taggedContent.CreateSpanElement(); span6.SetText("Interdum et malesuada fames ac ante ipsum primis in faucibus. "); p.AppendChild(span6); SpanElement span7 = taggedContent.CreateSpanElement(); span7.SetText("Aliquam lacinia sit amet elit ac consectetur. Donec cursus condimentum ligula, vitae volutpat sem tristique eget. "); p.AppendChild(span7); SpanElement span8 = taggedContent.CreateSpanElement(); span8.SetText("Nulla in consectetur massa. Vestibulum vitae lobortis ante. Nulla ullamcorper pellentesque justo rhoncus accumsan. "); p.AppendChild(span8); SpanElement span9 = taggedContent.CreateSpanElement(); span9.SetText("Mauris ornare eu odio non lacinia. Aliquam massa leo, rhoncus ac iaculis eget, tempus et magna. Sed non consectetur elit. "); p.AppendChild(span9); SpanElement span10 = taggedContent.CreateSpanElement(); span10.SetText("Sed vulputate, quam sed lacinia luctus, ipsum nibh fringilla purus, vitae posuere risus odio id massa. Cras sed venenatis lacus."); p.AppendChild(span10); // Save Tagged Pdf Document document.Save(dataDir + "InlineStructureElements.pdf"); // ExEnd:InlineStructureElements }
/// <summary> /// This feature is supported by version 19.6 or greater /// </summary> public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Create document Document document = new Document(); ITaggedContent taggedContent = document.TaggedContent; taggedContent.SetTitle("Example table style"); taggedContent.SetLanguage("en-US"); // Get root structure element StructureElement rootElement = taggedContent.RootElement; // Create table structure element TableElement tableElement = taggedContent.CreateTableElement(); rootElement.AppendChild(tableElement); tableElement.BackgroundColor = Color.Beige; tableElement.Border = new BorderInfo(BorderSide.All, 0.80F, Color.Gray); tableElement.Alignment = HorizontalAlignment.Center; tableElement.Broken = TableBroken.Vertical; tableElement.ColumnAdjustment = ColumnAdjustment.AutoFitToWindow; tableElement.ColumnWidths = "80 80 80 80 80"; tableElement.DefaultCellBorder = new BorderInfo(BorderSide.All, 0.50F, Color.DarkBlue); tableElement.DefaultCellPadding = new MarginInfo(16.0, 2.0, 8.0, 2.0); tableElement.DefaultCellTextState.ForegroundColor = Color.DarkCyan; tableElement.DefaultCellTextState.FontSize = 8F; tableElement.DefaultColumnWidth = "70"; tableElement.IsBroken = false; tableElement.IsBordersIncluded = true; tableElement.Left = 0F; tableElement.Top = 40F; tableElement.RepeatingColumnsCount = 2; tableElement.RepeatingRowsCount = 3; TextState rowStyle = new TextState(); rowStyle.BackgroundColor = Color.LightCoral; tableElement.RepeatingRowsStyle = rowStyle; TableTHeadElement tableTHeadElement = tableElement.CreateTHead(); TableTBodyElement tableTBodyElement = tableElement.CreateTBody(); TableTFootElement tableTFootElement = tableElement.CreateTFoot(); int rowCount = 10; int colCount = 5; int rowIndex; int colIndex; TableTRElement headTrElement = tableTHeadElement.CreateTR(); headTrElement.AlternativeText = "Head Row"; for (colIndex = 0; colIndex < colCount; colIndex++) { TableTHElement thElement = headTrElement.CreateTH(); thElement.SetText(String.Format("Head {0}", colIndex)); } for (rowIndex = 0; rowIndex < rowCount; rowIndex++) { TableTRElement trElement = tableTBodyElement.CreateTR(); trElement.AlternativeText = String.Format("Row {0}", rowIndex); for (colIndex = 0; colIndex < colCount; colIndex++) { TableTDElement tdElement = trElement.CreateTD(); tdElement.SetText(String.Format("Cell [{0}, {1}]", rowIndex, colIndex)); } } TableTRElement footTrElement = tableTFootElement.CreateTR(); footTrElement.AlternativeText = "Foot Row"; for (colIndex = 0; colIndex < colCount; colIndex++) { TableTDElement tdElement = footTrElement.CreateTD(); tdElement.SetText(String.Format("Foot {0}", colIndex)); } // Save Tagged Pdf Document document.Save(dataDir + "StyleTableElement.pdf"); // Checking PDF/UA compliance document = new Document(dataDir + "StyleTableElement.pdf"); bool isPdfUaCompliance = document.Validate(dataDir + "StyleTableElement.xml", PdfFormat.PDF_UA_1); Console.WriteLine(String.Format("PDF/UA compliance: {0}", isPdfUaCompliance)); // ExEnd:1 }
/// <summary> /// This feature is supported by version 19.6 or greater /// </summary> public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Create document Document document = new Document(); ITaggedContent taggedContent = document.TaggedContent; taggedContent.SetTitle("Example table cell style"); taggedContent.SetLanguage("en-US"); // Get root structure element StructureElement rootElement = taggedContent.RootElement; // Create table structure element TableElement tableElement = taggedContent.CreateTableElement(); rootElement.AppendChild(tableElement); TableTHeadElement tableTHeadElement = tableElement.CreateTHead(); TableTBodyElement tableTBodyElement = tableElement.CreateTBody(); TableTFootElement tableTFootElement = tableElement.CreateTFoot(); int rowCount = 4; int colCount = 4; int rowIndex; int colIndex; TableTRElement headTrElement = tableTHeadElement.CreateTR(); headTrElement.AlternativeText = "Head Row"; for (colIndex = 0; colIndex < colCount; colIndex++) { TableTHElement thElement = headTrElement.CreateTH(); thElement.SetText(String.Format("Head {0}", colIndex)); thElement.BackgroundColor = Color.GreenYellow; thElement.Border = new BorderInfo(BorderSide.All, 4.0F, Color.Gray); thElement.IsNoBorder = true; thElement.Margin = new MarginInfo(16.0, 2.0, 8.0, 2.0); thElement.Alignment = HorizontalAlignment.Right; } for (rowIndex = 0; rowIndex < rowCount; rowIndex++) { TableTRElement trElement = tableTBodyElement.CreateTR(); trElement.AlternativeText = String.Format("Row {0}", rowIndex); for (colIndex = 0; colIndex < colCount; colIndex++) { int colSpan = 1; int rowSpan = 1; if (colIndex == 1 && rowIndex == 1) { colSpan = 2; rowSpan = 2; } else if (colIndex == 2 && (rowIndex == 1 || rowIndex == 2)) { continue; } else if (rowIndex == 2 && (colIndex == 1 || colIndex == 2)) { continue; } TableTDElement tdElement = trElement.CreateTD(); tdElement.SetText(String.Format("Cell [{0}, {1}]", rowIndex, colIndex)); tdElement.BackgroundColor = Color.Yellow; tdElement.Border = new BorderInfo(BorderSide.All, 4.0F, Color.Gray); tdElement.IsNoBorder = false; tdElement.Margin = new MarginInfo(8.0, 2.0, 8.0, 2.0); tdElement.Alignment = HorizontalAlignment.Center; TextState cellTextState = new TextState(); cellTextState.ForegroundColor = Color.DarkBlue; cellTextState.FontSize = 7.5F; cellTextState.FontStyle = FontStyles.Bold; cellTextState.Font = FontRepository.FindFont("Arial"); tdElement.DefaultCellTextState = cellTextState; tdElement.IsWordWrapped = true; tdElement.VerticalAlignment = VerticalAlignment.Center; tdElement.ColSpan = colSpan; tdElement.RowSpan = rowSpan; } } TableTRElement footTrElement = tableTFootElement.CreateTR(); footTrElement.AlternativeText = "Foot Row"; for (colIndex = 0; colIndex < colCount; colIndex++) { TableTDElement tdElement = footTrElement.CreateTD(); tdElement.SetText(String.Format("Foot {0}", colIndex)); } // Save Tagged Pdf Document document.Save(dataDir + "StyleTableCell.pdf"); // Checking PDF/UA compliance document = new Document(dataDir + "StyleTableCell.pdf"); bool isPdfUaCompliance = document.Validate(dataDir + "StyleTableCell.xml", PdfFormat.PDF_UA_1); Console.WriteLine(String.Format("PDF/UA compliance: {0}", isPdfUaCompliance)); }
public static void Run() { // ExStart:LinkStructureElements // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); string outFile = dataDir + "LinkStructureElements_Output.pdf"; string logFile = dataDir + "46035_log.xml"; string imgFile = dataDir + "google-icon-512.png"; // Creation document and getting Tagged Pdf Content Document document = new Document(); ITaggedContent taggedContent = document.TaggedContent; // Setting Title and Nature Language for document taggedContent.SetTitle("Link Elements Example"); taggedContent.SetLanguage("en-US"); // Getting Root structure element (Document structure element) StructureElement rootElement = taggedContent.RootElement; ParagraphElement p1 = taggedContent.CreateParagraphElement(); rootElement.AppendChild(p1); LinkElement link1 = taggedContent.CreateLinkElement(); p1.AppendChild(link1); link1.Hyperlink = new WebHyperlink("http://google.com"); link1.SetText("Google"); link1.AlternateDescriptions = "Link to Google"; ParagraphElement p2 = taggedContent.CreateParagraphElement(); rootElement.AppendChild(p2); LinkElement link2 = taggedContent.CreateLinkElement(); p2.AppendChild(link2); link2.Hyperlink = new WebHyperlink("http://google.com"); SpanElement span2 = taggedContent.CreateSpanElement(); span2.SetText("Google"); link2.AppendChild(span2); link2.AlternateDescriptions = "Link to Google"; ParagraphElement p3 = taggedContent.CreateParagraphElement(); rootElement.AppendChild(p3); LinkElement link3 = taggedContent.CreateLinkElement(); p3.AppendChild(link3); link3.Hyperlink = new WebHyperlink("http://google.com"); SpanElement span31 = taggedContent.CreateSpanElement(); span31.SetText("G"); SpanElement span32 = taggedContent.CreateSpanElement(); span32.SetText("oogle"); link3.AppendChild(span31); link3.SetText("-"); link3.AppendChild(span32); link3.AlternateDescriptions = "Link to Google"; ParagraphElement p4 = taggedContent.CreateParagraphElement(); rootElement.AppendChild(p4); LinkElement link4 = taggedContent.CreateLinkElement(); p4.AppendChild(link4); link4.Hyperlink = new WebHyperlink("http://google.com"); link4.SetText("The multiline link: Google Google Google Google Google Google Google Google Google Google Google Google Google Google Google Google Google Google Google Google"); link4.AlternateDescriptions = "Link to Google (multiline)"; ParagraphElement p5 = taggedContent.CreateParagraphElement(); rootElement.AppendChild(p5); LinkElement link5 = taggedContent.CreateLinkElement(); p5.AppendChild(link5); link5.Hyperlink = new WebHyperlink("http://google.com"); FigureElement figure5 = taggedContent.CreateFigureElement(); figure5.SetImage(imgFile, 1200); figure5.AlternativeText = "Google icon"; StructureAttributes linkLayoutAttributes = link5.Attributes.GetAttributes(AttributeOwnerStandard.Layout); StructureAttribute placementAttribute = new StructureAttribute(AttributeKey.Placement); placementAttribute.SetNameValue(AttributeName.Placement_Block); linkLayoutAttributes.SetAttribute(placementAttribute); link5.AppendChild(figure5); link5.AlternateDescriptions = "Link to Google"; // Save Tagged Pdf Document document.Save(outFile); // Checking PDF/UA compliance document = new Document(outFile); bool isPdfUaCompliance = document.Validate(logFile, PdfFormat.PDF_UA_1); Console.WriteLine(String.Format("PDF/UA compliance: {0}", isPdfUaCompliance)); // ExEnd:LinkStructureElements }
public static void Run() { // ExStart:AddStructureElementIntoElement // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); string outFile = dataDir + "AddStructureElementIntoElement_Output.pdf"; string logFile = dataDir + "46144_log.xml"; // Creation document and getting Tagged Pdf Content Document document = new Document(); ITaggedContent taggedContent = document.TaggedContent; // Setting Title and Nature Language for document taggedContent.SetTitle("Text Elements Example"); taggedContent.SetLanguage("en-US"); // Getting Root structure element (Document structure element) StructureElement rootElement = taggedContent.RootElement; ParagraphElement p1 = taggedContent.CreateParagraphElement(); rootElement.AppendChild(p1); SpanElement span11 = taggedContent.CreateSpanElement(); span11.SetText("Span_11"); SpanElement span12 = taggedContent.CreateSpanElement(); span12.SetText(" and Span_12."); p1.SetText("Paragraph with "); p1.AppendChild(span11); p1.AppendChild(span12); ParagraphElement p2 = taggedContent.CreateParagraphElement(); rootElement.AppendChild(p2); SpanElement span21 = taggedContent.CreateSpanElement(); span21.SetText("Span_21"); SpanElement span22 = taggedContent.CreateSpanElement(); span22.SetText("Span_22."); p2.AppendChild(span21); p2.SetText(" and "); p2.AppendChild(span22); ParagraphElement p3 = taggedContent.CreateParagraphElement(); rootElement.AppendChild(p3); SpanElement span31 = taggedContent.CreateSpanElement(); span31.SetText("Span_31"); SpanElement span32 = taggedContent.CreateSpanElement(); span32.SetText(" and Span_32"); p3.AppendChild(span31); p3.AppendChild(span32); p3.SetText("."); ParagraphElement p4 = taggedContent.CreateParagraphElement(); rootElement.AppendChild(p4); SpanElement span41 = taggedContent.CreateSpanElement(); SpanElement span411 = taggedContent.CreateSpanElement(); span411.SetText("Span_411, "); span41.SetText("Span_41, "); span41.AppendChild(span411); SpanElement span42 = taggedContent.CreateSpanElement(); SpanElement span421 = taggedContent.CreateSpanElement(); span421.SetText("Span 421 and "); span42.AppendChild(span421); span42.SetText("Span_42"); p4.AppendChild(span41); p4.AppendChild(span42); p4.SetText("."); // Save Tagged Pdf Document document.Save(outFile); // Checking PDF/UA compliance document = new Document(outFile); bool isPdfUaCompliance = document.Validate(logFile, PdfFormat.PDF_UA_1); Console.WriteLine(String.Format("PDF/UA compliance: {0}", isPdfUaCompliance)); // ExEnd:AddStructureElementIntoElement }
public static void Run() { // ExStart:CreateStructureElementsTree // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Create Pdf Document Document document = new Document(); // Get Content for work with TaggedPdf ITaggedContent taggedContent = document.TaggedContent; // Set Title and Language for Documnet taggedContent.SetTitle("Tagged Pdf Document"); taggedContent.SetLanguage("en-US"); // Get root structure element (Document) StructureElement rootElement = taggedContent.RootElement; // Create Logical Structure SectElement sect1 = taggedContent.CreateSectElement(); rootElement.AppendChild(sect1); SectElement sect2 = taggedContent.CreateSectElement(); rootElement.AppendChild(sect2); DivElement div11 = taggedContent.CreateDivElement(); sect1.AppendChild(div11); DivElement div12 = taggedContent.CreateDivElement(); sect1.AppendChild(div12); ArtElement art21 = taggedContent.CreateArtElement(); sect2.AppendChild(art21); ArtElement art22 = taggedContent.CreateArtElement(); sect2.AppendChild(art22); DivElement div211 = taggedContent.CreateDivElement(); art21.AppendChild(div211); DivElement div212 = taggedContent.CreateDivElement(); art21.AppendChild(div212); DivElement div221 = taggedContent.CreateDivElement(); art22.AppendChild(div221); DivElement div222 = taggedContent.CreateDivElement(); art22.AppendChild(div222); SectElement sect3 = taggedContent.CreateSectElement(); rootElement.AppendChild(sect3); DivElement div31 = taggedContent.CreateDivElement(); sect3.AppendChild(div31); // Save Tagged Pdf Document document.Save(dataDir + "StructureElementsTree.pdf"); // ExEnd:CreateStructureElementsTree }