No subject
Tue Jul 27 07:17:13 PDT 2010
number of columns of the page, Iam able to sort the blocks. So that the
selection is very good.
Right now in poppler the selection is bit a problem. After doing all these
its almost look like Adobe Reader's Selection.
Please give me suggestions on improving this.
I attached two files with this mail.
getcol.c is able to sort the blocks in single/multicolumn pdfs.
getcolumn.c is based on the above sorting used to do the selection.
*I sent patch about getting the PDF ID from the document before. Albert said
it was ok. But he asked carlos ?
Please give me the status about it. *
Thanks
--
A Srinivas
--0016364583a252ae9e048c5f54cf
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi all,<br><br>=A0=A0=A0=A0=A0=A0=A0 I used the poppler_page_get_selection_=
<div id=3D":208" class=3D"ii gt">region() to find the line rectangles of ea=
ch and every line in a page.<br>From
that I find the blocks, then I find the columns of the page. From the
number of columns of the page, Iam able to sort the blocks. So that the
selection is very good.<br>
<br>Right now in poppler the selection is bit a problem. After doing all th=
ese its almost look like Adobe Reader's Selection.<br><br>Please give m=
e suggestions on improving this.<br><br>I attached two files with this mail=
. <br>
<br>getcol.c is able to sort the blocks in single/multicolumn pdfs. <br>get=
column.c is based on the above sorting used to do the selection.<br><br><br=
><u>I sent patch about getting the PDF ID from the document before. Albert =
said it was ok. But he asked carlos ? <br>
<br>Please give me the status about it. </u><br><br><br>Thanks<br><font col=
or=3D"#888888">-- <br>A Srinivas</font></div>
--0016364583a252ae9e048c5f54cf--
--0016364583a252aea8048c5f54d1
Content-Type: text/x-csrc; charset=US-ASCII; name="getcol.c"
Content-Disposition: attachment; filename="getcol.c"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gc4ueiau0
I2luY2x1ZGUgPHBvcHBsZXIuaD4KI2luY2x1ZGUgPHBvcHBsZXItZG9jdW1lbnQuaD4KI2luY2x1
ZGUgPHBvcHBsZXItcGFnZS5oPgojaW5jbHVkZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDxzdGRsaWIu
aD4KI2luY2x1ZGUgPGd0ay9ndGsuaD4KCmludCBw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Vzcy1l
dmVudCIsIEdfQ0FMTEJBQ0sgKGJ1dHRvbl9wcmVzc19ldmVudF9jYiksIGFyZ3YgWzFdKTsKCWd0
a193aWRnZXRfYWRkX2V2ZW50cyAoZHJhdywgR0RLX0FMTF9FVkVOVFNfTUFTSyk7CglnX3NpZ25h
bF9jb25uZWN0IChHX09CSkVDVCAod2luZG93KSwgImRlc3Ryb3kiLCBndGtfbWFpbl9xdWl0LCBO
VUxMKTsKCWdfc2lnbmFsX2Nvbm5lY3QgKEdfT0JKRUNUIChidXR0b24xKSwgImNsaWNrZWQiLCBH
X0NBTExCQUNLIChidXR0b24xX2NsaWNrZWQpLCBkcmF3KTsKCWdfc2lnbmFsX2Nvbm5lY3QgKEdf
T0JKRUNUIChidXR0b24yKSwgImNsaWNrZWQiLCBHX0NBTExCQUNLIChidXR0b24yX2NsaWNrZWQp
LCBkcmF3KTsKCWdfc2lnbmFsX2Nvbm5lY3QgKEdfT0JKRUNUIChidXR0b24zKSwgImNsaWNrZWQi
LCBHX0NBTExCQUNLIChidXR0b24zX2NsaWNrZWQpLCBkcmF3KTsKCQoJZ3RrX21haW4gKCk7CQp9
Cg==
--0016364583a252aea8048c5f54d1
Content-Type: text/x-csrc; charset=US-ASCII; name="getcolumn.c"
Content-Disposition: attachment; filename="getcolumn.c"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gc4uensv1
I2luY2x1ZGUgPHBvcHBsZXIuaD4KI2luY2x1ZGUgPHBvcHBsZXItZG9jdW1lbnQuaD4KI2luY2x1
ZGUgPHBvcHBsZXItcGFnZS5oPgojaW5jbHVkZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDxzdGRsaWIu
aD4KI2luY2x1ZGUgPGd0ay9ndGsuaD4KI2luY2x1ZGUgPHN5cy90aW1lLmg+CgppbnQgcGFnZV9u
bzsgLy8gcGFnZW5vCmludCBucGFnZXM7ICAvLyBudW0gcGFnZXMKaW50IHBkZl9jb2x1bW4gPSAx
OyAvLyBkZWZhdWx0IH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