프로젝트

일반

사용자정보

개정판 08811885

ID08811885e0b41ff5566cab4e92305bd005a2cfce
상위 af52cf95
하위 9b75788a

백흠경이(가) 4년 이상 전에 추가함

issue #569: 텍스트가 없을 경우 오류 발생 수정

Change-Id: I3dfb0eeb1ae4eacc5737900273be3012e7a400ae

차이점 보기:

DTI_PID/PDF_TO_IMAGE/ConvertImage.cs
230 230
                                PageWordMap[word.PageNumber].Add(word);
231 231
                                //Switch to the next word
232 232
                                currentWord = pdp.NextWord();
233
                            }
                            /// up to here

233
                            }
234
                            /// up to here
235

  
234 236
                            splashScreenManager1.ShowWaitForm();
235 237
                            splashScreenManager1.SetWaitFormCaption("Convert Pdf File to Image Files");
236 238
                            try
......
287 289
                                    }
288 290

  
289 291
                                    /// save text to file
290
                                    System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
291
                                    System.Xml.XmlNode xmlRoot = xmlDoc.CreateElement("Texts");
292
                                    foreach(PageWord word in PageWordMap[i + 1])
292
                                    if (PageWordMap.ContainsKey(i + 1))
293 293
                                    {
294
                                        System.Xml.XmlNode xmlText = xmlDoc.CreateElement("Text");
295
                                        System.Xml.XmlAttribute pos = xmlDoc.CreateAttribute("Position");
296
                                        PointF[] array = { new PointF((float)(word.Left * dScale), (float)(word.Top * dScale)) };
297
                                        mat.TransformPoints(array);
298
                                        pos.Value = $"{System.Math.Abs(array[0].X)},{System.Math.Abs(array[0].Y)}";
299
                                        xmlText.Attributes.Append(pos);
300
                                        System.Xml.XmlAttribute angle = xmlDoc.CreateAttribute("Angle");
301
                                        double dAngle = (word.Angle - page.Rotate) >= 0 ? (word.Angle - page.Rotate) : 360 + (word.Angle - page.Rotate);
302
                                        angle.Value = $"{dAngle}";
303
                                        xmlText.Attributes.Append(angle);
304
                                        System.Xml.XmlAttribute xmlWidth = xmlDoc.CreateAttribute("Width");
305
                                        xmlWidth.Value = $"{word.Width * dScale}";
306
                                        xmlText.Attributes.Append(xmlWidth);
307
                                        System.Xml.XmlAttribute xmlHeight = xmlDoc.CreateAttribute("Height");
308
                                        xmlHeight.Value = $"{word.Height * dScale}";
309
                                        xmlText.Attributes.Append(xmlHeight);
310
                                        xmlText.InnerText = word.Text;
311

  
312
                                        xmlRoot.AppendChild(xmlText);
294
                                        System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
295
                                        System.Xml.XmlNode xmlRoot = xmlDoc.CreateElement("Texts");
296
                                        foreach (PageWord word in PageWordMap[i + 1])
297
                                        {
298
                                            System.Xml.XmlNode xmlText = xmlDoc.CreateElement("Text");
299
                                            System.Xml.XmlAttribute pos = xmlDoc.CreateAttribute("Position");
300
                                            PointF[] array = { new PointF((float)(word.Left * dScale), (float)(word.Top * dScale)) };
301
                                            mat.TransformPoints(array);
302
                                            pos.Value = $"{System.Math.Abs(array[0].X)},{System.Math.Abs(array[0].Y)}";
303
                                            xmlText.Attributes.Append(pos);
304
                                            System.Xml.XmlAttribute angle = xmlDoc.CreateAttribute("Angle");
305
                                            double dAngle = (word.Angle - page.Rotate) >= 0 ? (word.Angle - page.Rotate) : 360 + (word.Angle - page.Rotate);
306
                                            angle.Value = $"{dAngle}";
307
                                            xmlText.Attributes.Append(angle);
308
                                            System.Xml.XmlAttribute xmlWidth = xmlDoc.CreateAttribute("Width");
309
                                            xmlWidth.Value = $"{word.Width * dScale}";
310
                                            xmlText.Attributes.Append(xmlWidth);
311
                                            System.Xml.XmlAttribute xmlHeight = xmlDoc.CreateAttribute("Height");
312
                                            xmlHeight.Value = $"{word.Height * dScale}";
313
                                            xmlText.Attributes.Append(xmlHeight);
314
                                            xmlText.InnerText = word.Text;
315

  
316
                                            xmlRoot.AppendChild(xmlText);
317
                                        }
318
                                        xmlDoc.AppendChild(xmlRoot);
319
                                        xmlDoc.Save($"{sPathWithoutExt}_Page{i + 1}.xml");
313 320
                                    }
314
                                    xmlDoc.AppendChild(xmlRoot);
315
                                    xmlDoc.Save($"{sPathWithoutExt}_Page{i + 1}.xml");
316 321
                                    /// up to here
317 322

  
318

  
319 323
                                    iPercent = (i + 1) * 100 / iPage;
320 324
                                    splashScreenManager1.SetWaitFormDescription((i + 1) + " / " + sPage + " Pages ( " + iPercent + "% )");
321 325
                                }

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)