Example #1
0
        public void WriteAttributes(IAccessibleElement element)
        {
            if (element is ListItem)
                WriteAttributes((ListItem) element);
            else if (element is Paragraph)
                WriteAttributes((Paragraph) element);
            else if (element is Chunk)
                WriteAttributes((Chunk) element);
            else if (element is Image)
                WriteAttributes((Image) element);
            else if (element is List)
                WriteAttributes((List) element);
            else if (element is ListLabel)
                WriteAttributes((ListLabel) element);
            else if (element is ListBody)
                WriteAttributes((ListBody) element);
            else if (element is PdfPTable)
                WriteAttributes((PdfPTable) element);
            else if (element is PdfPRow)
                WriteAttributes((PdfPRow) element);
            else if (element is PdfPHeaderCell)
                WriteAttributes((PdfPHeaderCell) element);
            else if (element is PdfPCell)
                WriteAttributes((PdfPCell) element);
            else if (element is PdfPTableHeader)
                WriteAttributes((PdfPTableHeader) element);
            else if (element is PdfPTableFooter)
                WriteAttributes((PdfPTableFooter) element);
            else if (element is PdfPTableBody)
                WriteAttributes((PdfPTableBody) element);
            else if (element is PdfDiv)
                WriteAttributes((PdfDiv) element);
            else if (element is Document)
                WriteAttributes((Document) element);

            if (element.GetAccessibleAttributes() != null)
                foreach (PdfName key in element.GetAccessibleAttributes().Keys)
                {
                    if (key.Equals(PdfName.LANG) || key.Equals(PdfName.ALT) || key.Equals(PdfName.ACTUALTEXT) ||
                        key.Equals(PdfName.E))
                        Put(key, element.GetAccessibleAttribute(key));
                    else
                        SetAttribute(key, element.GetAccessibleAttribute(key));
                }
        }
        private PdfStructureElement OpenMCBlockInt(IAccessibleElement element) {
            PdfStructureElement structureElement = null;
            if (IsTagged()) {
                IAccessibleElement parent = null;
                if (GetMcElements().Count > 0)
                    parent = GetMcElements()[GetMcElements().Count - 1];
                writer.CheckElementRole(element, parent);
                if (element.Role != null) {
                    if(!PdfName.ARTIFACT.Equals(element.Role)) {
                        if(!pdf.structElements.TryGetValue(element.ID, out structureElement)) {
                            structureElement = new PdfStructureElement(GetParentStructureElement(), element.Role);
                        }
                    }
                    if (PdfName.ARTIFACT.Equals(element.Role)) {
                        Dictionary<PdfName, PdfObject> properties = element.GetAccessibleAttributes();
                        PdfDictionary propertiesDict = null;
                        if (properties == null || properties.Count == 0) {
                        }
                        else {
                            propertiesDict = new PdfDictionary();
                            foreach (KeyValuePair<PdfName, PdfObject> entry in properties) {
                                propertiesDict.Put(entry.Key, entry.Value);
                            }
                        }
                        bool inTextLocal = inText;
                        if (inText)
                            EndText();

                        BeginMarkedContentSequence(element.Role, propertiesDict, true);
                        if (inTextLocal)
                            BeginText(true);
                    }
                    else {
                        if (writer.NeedToBeMarkedInContent(element)) {
                            bool inTextLocal = inText;
                            if (inText)
                                EndText();
                            if (null != element.GetAccessibleAttributes() && null != element.GetAccessibleAttribute(PdfName.E))
                            {
                                BeginMarkedContentSequence(structureElement, element.GetAccessibleAttribute(PdfName.E).ToString());
                                element.SetAccessibleAttribute(PdfName.E, null);
                            }
                            else
                            {
                                BeginMarkedContentSequence(structureElement);
                            }
                            if (inTextLocal)
                                BeginText(true);
                        }
                    }
                }
            }
            return structureElement;
        }
Example #3
0
        public virtual void WriteAttributes(IAccessibleElement element)
        {
            // I do remember that these lines were necessary to avoid creation of files which are not valid from Acrobat 10 preflight perspective.
            // Now it seems that in Acrobat 11 there's no such problem (I think Acrobat 10 behavior can be considered as a bug) and we can remove those lines.
            // if(top.Writer.GetPdfVersion().Version < PdfWriter.VERSION_1_7)
            //    return;

            if (element is ListItem)
            {
                WriteAttributes((ListItem)element);
            }
            else if (element is Paragraph)
            {
                WriteAttributes((Paragraph)element);
            }
            else if (element is Chunk)
            {
                WriteAttributes((Chunk)element);
            }
            else if (element is Image)
            {
                WriteAttributes((Image)element);
            }
            else if (element is List)
            {
                WriteAttributes((List)element);
            }
            else if (element is ListLabel)
            {
                WriteAttributes((ListLabel)element);
            }
            else if (element is ListBody)
            {
                WriteAttributes((ListBody)element);
            }
            else if (element is PdfPTable)
            {
                WriteAttributes((PdfPTable)element);
            }
            else if (element is PdfPRow)
            {
                WriteAttributes((PdfPRow)element);
            }
            else if (element is PdfPHeaderCell)
            {
                WriteAttributes((PdfPHeaderCell)element);
            }
            else if (element is PdfPCell)
            {
                WriteAttributes((PdfPCell)element);
            }
            else if (element is PdfPTableHeader)
            {
                WriteAttributes((PdfPTableHeader)element);
            }
            else if (element is PdfPTableFooter)
            {
                WriteAttributes((PdfPTableFooter)element);
            }
            else if (element is PdfPTableBody)
            {
                WriteAttributes((PdfPTableBody)element);
            }
            else if (element is PdfDiv)
            {
                WriteAttributes((PdfDiv)element);
            }
            else if (element is PdfTemplate)
            {
                WriteAttributes((PdfTemplate)element);
            }
            else if (element is Document)
            {
                WriteAttributes((Document)element);
            }

            if (element.GetAccessibleAttributes() != null)
            {
                foreach (PdfName key in element.GetAccessibleAttributes().Keys)
                {
                    if (key.Equals(PdfName.ID))
                    {
                        PdfObject attr = element.GetAccessibleAttribute(key);
                        Put(key, attr);
                        top.PutIDTree(attr.ToString(), Reference);
                    }
                    else if (key.Equals(PdfName.LANG) || key.Equals(PdfName.ALT) || key.Equals(PdfName.ACTUALTEXT) || key.Equals(PdfName.E) || key.Equals(PdfName.T))
                    {
                        Put(key, element.GetAccessibleAttribute(key));
                    }
                    else
                    {
                        SetAttribute(key, element.GetAccessibleAttribute(key));
                    }
                }
            }
        }
        public virtual void WriteAttributes(IAccessibleElement element) {
            // I do remember that these lines were necessary to avoid creation of files which are not valid from Acrobat 10 preflight perspective.
            // Now it seems that in Acrobat 11 there's no such problem (I think Acrobat 10 behavior can be considered as a bug) and we can remove those lines.
            // if(top.Writer.GetPdfVersion().Version < PdfWriter.VERSION_1_7)
            //    return;

            if (element is ListItem)
                WriteAttributes((ListItem) element);
            else if (element is Paragraph)
                WriteAttributes((Paragraph) element);
            else if (element is Chunk)
                WriteAttributes((Chunk) element);
            else if (element is Image)
                WriteAttributes((Image) element);
            else if (element is List)
                WriteAttributes((List) element);
            else if (element is ListLabel)
                WriteAttributes((ListLabel) element);
            else if (element is ListBody)
                WriteAttributes((ListBody) element);
            else if (element is PdfPTable)
                WriteAttributes((PdfPTable) element);
            else if (element is PdfPRow)
                WriteAttributes((PdfPRow) element);
            else if (element is PdfPHeaderCell)
                WriteAttributes((PdfPHeaderCell) element);
            else if (element is PdfPCell)
                WriteAttributes((PdfPCell) element);
            else if (element is PdfPTableHeader)
                WriteAttributes((PdfPTableHeader) element);
            else if (element is PdfPTableFooter)
                WriteAttributes((PdfPTableFooter) element);
            else if (element is PdfPTableBody)
                WriteAttributes((PdfPTableBody) element);
            else if (element is PdfDiv)
                WriteAttributes((PdfDiv) element);
            else if (element is PdfTemplate)
                WriteAttributes((PdfTemplate) element);
            else if (element is Document)
                WriteAttributes((Document) element);

            if (element.GetAccessibleAttributes() != null) {
                foreach (PdfName key in element.GetAccessibleAttributes().Keys) {
                    if (key.Equals(PdfName.ID)) {
                        PdfObject attr = element.GetAccessibleAttribute(key);
                        Put(key, attr);
                        top.PutIDTree(attr.ToString(), Reference);
                    } else if (key.Equals(PdfName.LANG) || key.Equals(PdfName.ALT) || key.Equals(PdfName.ACTUALTEXT) || key.Equals(PdfName.E) || key.Equals(PdfName.T)) {
                        Put(key, element.GetAccessibleAttribute(key));
                    } else
                        SetAttribute(key, element.GetAccessibleAttribute(key));
                }
            }
        }
        public void WriteAttributes(IAccessibleElement element)
        {
            if (element is ListItem)
            {
                WriteAttributes((ListItem)element);
            }
            else if (element is Paragraph)
            {
                WriteAttributes((Paragraph)element);
            }
            else if (element is Chunk)
            {
                WriteAttributes((Chunk)element);
            }
            else if (element is Image)
            {
                WriteAttributes((Image)element);
            }
            else if (element is List)
            {
                WriteAttributes((List)element);
            }
            else if (element is ListLabel)
            {
                WriteAttributes((ListLabel)element);
            }
            else if (element is ListBody)
            {
                WriteAttributes((ListBody)element);
            }
            else if (element is PdfPTable)
            {
                WriteAttributes((PdfPTable)element);
            }
            else if (element is PdfPRow)
            {
                WriteAttributes((PdfPRow)element);
            }
            else if (element is PdfPHeaderCell)
            {
                WriteAttributes((PdfPHeaderCell)element);
            }
            else if (element is PdfPCell)
            {
                WriteAttributes((PdfPCell)element);
            }
            else if (element is PdfPTableHeader)
            {
                WriteAttributes((PdfPTableHeader)element);
            }
            else if (element is PdfPTableFooter)
            {
                WriteAttributes((PdfPTableFooter)element);
            }
            else if (element is PdfPTableBody)
            {
                WriteAttributes((PdfPTableBody)element);
            }
            else if (element is PdfDiv)
            {
                WriteAttributes((PdfDiv)element);
            }
            else if (element is Document)
            {
                WriteAttributes((Document)element);
            }

            if (element.GetAccessibleAttributes() != null)
            {
                foreach (PdfName key in element.GetAccessibleAttributes().Keys)
                {
                    if (key.Equals(PdfName.LANG) || key.Equals(PdfName.ALT) || key.Equals(PdfName.ACTUALTEXT) ||
                        key.Equals(PdfName.E))
                    {
                        Put(key, element.GetAccessibleAttribute(key));
                    }
                    else
                    {
                        SetAttribute(key, element.GetAccessibleAttribute(key));
                    }
                }
            }
        }