Beispiel #1
0
        //UI event, user clicks Load
        //validates the input and loads the chunk, then calls UpdateOutput
        private async void strip_btnLoad_Click(object sender, EventArgs e)
        {
            Range addr;

            if (!TryValidateInput(out addr))
            {
                return;
            }
            IChunkInfo g;

            if (this.outmode == DumpTypes.Gfx)
            {
                g = new GfxChunkInfo(addr, addr.Length.ToString() + " bytes of data");
                //(g as GfxChunkInfo).FormatID = _gfxsettings.Converter;
            }
            else if (this.outmode == DumpTypes.Raw)
            {
                g = new ChunkInfo(addr, addr.Length.ToString() + " bytes of data");
            }
            else
            {
                g = new TextChunkInfo(addr, addr.Length.ToString() + " bytes of data");
            }
            await this.LoadChunk(g);

            //this.CurrentChunk = new DataChunk(g, this.Image);
            //await this.UpdateOutput();
        }
Beispiel #2
0
 public void UpdateFromChunkInfo(TextChunkInfo ChunkInfo)
 {
     if (ChunkInfo.Encoding != null)
     {
         this.SetEncoding(ChunkInfo.Encoding);
     }
 }
Beispiel #3
0
        //Automatically called for each chunk of text in the PDF
        public override void RenderText(TextRenderInfo renderInfo)
        {
            base.RenderText(renderInfo);
            //UNDONE:Need to determine if text is underlined.  How?

            //NOTE: renderInfo.GetFont().FontWeight does not contain any actual information
            var gs            = (GraphicsState)_gsField.GetValue(renderInfo);
            var textChunkInfo = new TextChunkInfo(renderInfo);

            _allLocations.Add(textChunkInfo);
            if (gs.Font.PostscriptFontName.Contains("Bold"))
            {
                //Add this to our found collection
                FoundItems.Add(new TextChunkInfo(renderInfo));
            }

            if (!_lineHeights.Contains(textChunkInfo.LineHeight))
            {
                _lineHeights.Add(textChunkInfo.LineHeight);
            }
        }
Beispiel #4
0
        public override string GetResultantText()
        {
            var sb = new StringBuilder();
            //sb.AppendLine(base.GetResultantText());
            //sb.AppendLine(new string('-', 40));
            TextChunkInfo lastFound = null;
            var           leftEdge  = _allLocations.Min(l => l.StartLocation[Vector.I1]);
            var           rightEdge = _allLocations.Max(l => l.EndLocation[Vector.I1]);

            foreach (var info in FoundItems)
            {
                if (null == lastFound)
                {
                    sb.Append(info.Text);
                }
                else
                {
                    // Combine successive words
                    //  both inline
                    var inline = info.SameLine(lastFound) &&
                                 Math.Abs(info.DistanceFromEndOf(lastFound)) < 12;//HACK: Guessed at maxDistance
                    //TODO:  and split across lines
                    var splitAcrossLines = info.StartLocation[Vector.I1] - leftEdge < 2 &&
                                           rightEdge - lastFound.EndLocation[Vector.I1] < info.CharSpaceWidth + info.EndLocation[Vector.I1] - info.StartLocation[Vector.I1] &&//45
                                           OnNextLine(info, lastFound);
                    if (inline || splitAcrossLines)
                    {
                        sb.Append(" ");
                    }
                    else
                    {
                        sb.Append("\r\n");
                    }
                    sb.Append(info.Text);
                }

                lastFound = info;
            }
            return(sb.ToString());
        }
Beispiel #5
0
 private bool OnNextLine(TextChunkInfo firstChunk, TextChunkInfo lastChunk)
 {
     //TODO: Account for lines not being exactly at the same height
     return(_lineHeights.IndexOf(firstChunk.LineHeight) == _lineHeights.IndexOf(lastChunk.LineHeight) + 1);
 }