开发者

Adobe Reader Text Drag&Drop issue

开发者 https://www.devze.com 2023-02-05 06:19 出处:网络
I\'ve discovered issues with the Adobe Reader and the Drag&Drop feature for simple text. When I simply select some text and drop it into some of my .NET applications (or any texteditor like notep

I've discovered issues with the Adobe Reader and the Drag&Drop feature for simple text.

When I simply select some text and drop it into some of my .NET applications (or any texteditor like notepad++ or Visua开发者_JAVA百科lStudio) the text gets random characters attached to it.

I tried hard and observed the problem and as far as my observation goes I can say the following:

  1. It does not happend twice whith the same text selected for dragging.
  2. The attached text is always just a few characters long (at least ten)
  3. Sometimes it seems like that the attached characters are the fragments of text dargged and dropped earlier
  4. Some other times the attached characters are not alphanumeric characters which makes it hard to recognize
  5. The selected text could be anywhere (not just a whole paragraph)

I compare the dropped text with other texts in my application and this obviously fails since there are some characters which I did not dragged.

On the .NET side of things I use the standard IDataObject interface and tried multiple Formats but the behaviour is always the same. It can be reproduced but it is not predictable because it occurs randomly.

So my questions are: Is this a buffer filling issue of Adobe Reader (btw it happends in version 8,9, X with turned off secure mode)? Is this dependend on which third party program created the pdf? Has someone experienced the same behaviour (since I can find nothing on this)?

In advance I must say no other pdf-Reader is an option beacause it is a business policy here :).

Big thanks in advance for the one who could answer this questions.


Days and days of researching led me to the following conclusion:

It's a bug on both sides (adobe/.Net). At first the string contained in the OleDataObject dragged off of Adobe Reader is not null terminated which is a very unsafe way of exchanging data. No wonder this feature is turned off in the standard configuration of adobe reader X (But you can unlock it). On the .Net side every string must be terminated to work properly. Well you get a pointer and a new string instance is created which runs through the memory until it finds the '\0' character and that adds the wrong characters (or characters of previously dragged text). The solution to this mess is to query the size of the text part contained in the OleDataObject. This size (obviously smaller or equal than the result string size) could be used to do a substring operation on the original string. With all this in palce the string has no more wrong characters attached to it. -solved

0

精彩评论

暂无评论...
验证码 换一张
取 消