none
XPS,有FontRenderingEmSize,OriginX,OriginY,通过什么算法来算出字符串顶点到原点的(Y坐标)的值 RRS feed

  • 问题

  • <Glyphs RenderTransform="0.58703,0,0,0.589198,0,0" Fill="#ff000000" FontUri="/Documents/1/Resources/Fonts/EB3391B4-4F7F-463F-954E-0DD205C1D8A3.odttf" FontRenderingEmSize="40.96" StyleSimulations="BoldSimulation" OriginX="476.64" OriginY="211.04" Indices="5437,99;17241,101;7828,102;7609,99;6265,101;2590,102;2345" UnicodeString="测试测试" />

    例如上面的一段信息我能够获取到了

    话说看英文相关的一些文档,但是很多东西靠有道翻译的模棱两可……

    下面湿提取文字以及坐标信息的方法,但是提取到的Y坐标和屏幕显示的Y坐标并不对称,比如,Y坐标值小反而比Y坐标值大的显示的更靠下面;

    想请教下应该用什么算法来计算出字符顶点相对于文档原点的坐标值?

     XpsDocument xpsOld = new XpsDocument(strXpsFile, FileAccess.Read);
                    IXpsFixedDocumentSequenceReader seqOld = xpsOld.FixedDocumentSequenceReader;

                    LinkedList<XPS_PAGE> Pagelist = new LinkedList<XPS_PAGE>();


                    FixedDocumentSequence FixedDo = xpsOld.GetFixedDocumentSequence();
                   
                   
                    for (int i = 0; i < seqOld.FixedDocuments.Count; i++)
                    {
                        DocumentReference r = FixedDo.References[i];

                        IXpsFixedDocumentReader _docReader = seqOld.FixedDocuments[i];
                        FixedDocument d = r.GetDocument(false);
                       
                        for (int j = 0; j < _docReader.FixedPages.Count; j++)
                        {
                            XPS_PAGE stPage = new XPS_PAGE();
                            LinkedList<XPS_Line> LineList = new LinkedList<XPS_Line>();

                            IXpsFixedPageReader _page = _docReader.FixedPages[j];
                            System.Xml.XmlReader _pageContentReader = _page.XmlReader;


                            if (_pageContentReader != null)
                            {
                                XPS_Line stLine = new XPS_Line();
                                stLine.listData = new LinkedList<XPS_FIELD>();
                                while (_pageContentReader.Read())
                                {
                                   
                                    if (_pageContentReader.Name == "Glyphs")
                                    {
                                        if (_pageContentReader.HasAttributes)
                                        {
                                           
                                            if ((_pageContentReader.GetAttribute("UnicodeString") != null))
                                            {

                                                string strFountUri;
                                               
                                                XPS_FIELD tField = new XPS_FIELD();

                                                tField.strUnicodeString = _pageContentReader.GetAttribute("UnicodeString");
                                                tField.fX = float.Parse(_pageContentReader.GetAttribute("OriginX"));
                                                tField.fY = float.Parse(_pageContentReader.GetAttribute("OriginY"));
                                               
                                                strFountUri = _pageContentReader.GetAttribute("FontUri");
                                                float emSizeInGU = float.Parse(_pageContentReader.GetAttribute("FontRenderingEmSize"));

                                              

                                            

                                                tField.nPage = j + 1;
                                                stLine.listData.AddLast(tField);

                                            }
                                        }
                                    }
                                }
                                LineList.AddLast(stLine);
                            }
                            stPage.nPage = j + 1;
                            stPage.listData = LineList;
                            Pagelist.AddLast(stPage);
                        }
                    }

    2015年7月29日 9:47