Esempio n. 1
0
 internal FormLine(TextLine textLine, int pageNumber)
     : base(new FieldBoundingBox(textLine.BoundingBox), pageNumber, textLine.Text)
 {
     Words      = ConvertWords(textLine.Words, pageNumber);
     Appearance = textLine.Appearance;
 }
Esempio n. 2
0
 internal FormLine(TextLine textLine, int pageNumber)
     : base(new BoundingBox(textLine.BoundingBox), pageNumber, textLine.Text)
 {
     Words = ConvertWords(textLine.Words, pageNumber);
 }
        internal static ReadResult DeserializeReadResult(JsonElement element)
        {
            int        page   = default;
            float      angle  = default;
            float      width  = default;
            float      height = default;
            LengthUnit unit   = default;
            Optional <IReadOnlyList <TextLine> >      lines          = default;
            Optional <IReadOnlyList <SelectionMark> > selectionMarks = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("page"))
                {
                    page = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("angle"))
                {
                    angle = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("width"))
                {
                    width = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("height"))
                {
                    height = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    unit = property.Value.GetString().ToLengthUnit();
                    continue;
                }
                if (property.NameEquals("lines"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TextLine> array = new List <TextLine>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextLine.DeserializeTextLine(item));
                    }
                    lines = array;
                    continue;
                }
                if (property.NameEquals("selectionMarks"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        selectionMarks = null;
                        continue;
                    }
                    List <SelectionMark> array = new List <SelectionMark>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SelectionMark.DeserializeSelectionMark(item));
                    }
                    selectionMarks = array;
                    continue;
                }
            }
            return(new ReadResult(page, angle, width, height, unit, Optional.ToList(lines), Optional.ToList(selectionMarks)));
        }