Pasting Text from PDF into LiveCode Fields

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
billenright123
Posts: 5
Joined: Thu Apr 04, 2013 11:08 am

Pasting Text from PDF into LiveCode Fields

Post by billenright123 » Thu Apr 04, 2013 1:53 pm

I have several PDFs (mostly text) that I need to paste into fields for formatted.
However, the fields will not accept the info via Paste command (this works perfectly well in Revolution 4.0).

I can get it to accept if i do the following:
1 Paste text into MS Word.
2 Copy text from MS Word.

Any thoughts?

Thanks

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Pasting Text from PDF into LiveCode Fields

Post by dunbarx » Thu Apr 04, 2013 2:03 pm

Hi.

When you copy the text from the pdf, what does the clipBoardData have in it? Is the clipBoardData empty?

What I mean is that LC should not care what the source of the data is.

You see what I am getting at.

Craig Newman

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Pasting Text from PDF into LiveCode Fields

Post by Simon » Thu Apr 04, 2013 6:43 pm

Hi billenright123,
There are methods of locking pdf documents that prevent people from copying and pasting. You should try to copy and paste just into notepad or textedit to remove LC from the equation.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Pasting Text from PDF into LiveCode Fields

Post by jacque » Thu Apr 04, 2013 7:16 pm

The same problem used to happen when copying from Word, so you are one step ahead. :) It was a bug that RR fixed a while back. I believe there was another app as well that also loaded the clipboard with unusual content but I can't remember which one it was.

That said, I just tried copying from a PDF here and it pastes fine into a LiveCode field. Are you doing a manual paste, or trying to script it?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

wje123
Posts: 5
Joined: Wed May 27, 2009 2:19 pm

Re: Pasting Text from PDF into LiveCode Fields

Post by wje123 » Fri Jun 21, 2013 11:47 pm

Following up on this topic (after being side-tracked for a while).

1 – Only certain PDFs cause this problem (one is attached).
2 – The PDFs are not Locked.
3 – The data readily pastes into Word and other programs.
4 – I have tried clipboardData["text"], etc. None work.
5 – “Put the clipboard data” (in messagebox) does not return anything. Yet the data is there if I go to Word and paste.

I also have strange results pasting in data from Excel.

I know there are work arounds (pasted into Word first, etc.), but it should not be that complicated.

Thanks in advance for any suggestions.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Pasting Text from PDF into LiveCode Fields

Post by jacque » Sat Jun 22, 2013 1:48 am

You could test what's in the clipboard:

Code: Select all

on cliptest
  put the keys of the clipboarddata into tKeys
  repeat for each line k in tKeys
    put the clipboarddata[k] & cr after tList
  end repeat
  put tlist
end cliptest
Copy a small bit of the problem text and then run that handler, see what you get. It should at least tell you if anything is transferring over at all.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

wje123
Posts: 5
Joined: Wed May 27, 2009 2:19 pm

Re: Pasting Text from PDF into LiveCode Fields

Post by wje123 » Sun Jun 23, 2013 4:57 pm

This is the result (whether 1 char or the entire PDF is copied)


REVO5500
{\rtf1\mac {\colortbl;\red0\green0\blue0;}
\pard
}

Thanks
Bill

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Pasting Text from PDF into LiveCode Fields

Post by jacque » Mon Jun 24, 2013 8:20 pm

It looks like it is capturing some RTF info but no text and nothing else. Probably worth a bug report.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Pasting Text from PDF into LiveCode Fields

Post by Mark » Tue Jun 25, 2013 8:43 am

Hi,

Apparently, LiveCode is treating the PDF data as an object, which contains an RTF snippet. Try this: in the message box:

Code: Select all

put the clipboarddata["object"]
What do you get? If you get the same as what you pasted in your previous message, then this is a bug, although at this point I'm not sure whether this bug would be in the PDF reader or in LiveCode.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

wje123
Posts: 5
Joined: Wed May 27, 2009 2:19 pm

Re: Pasting Text from PDF into LiveCode Fields

Post by wje123 » Wed Jun 26, 2013 11:54 am

Unfortunately, nothing is returned.

As an interim solution, I have created a macro in Keyboard Maestro.
It pastes the clipboard into TextEdit and then copies the pasted text back to the clipboard.
Not elegant, but fast.

Thanks for the suggestion.
Bill

rinzwind
Posts: 135
Joined: Tue May 01, 2012 10:44 am

Re: Pasting Text from PDF into LiveCode Fields

Post by rinzwind » Sat Jul 25, 2015 12:30 pm

Somehow copying pasting from the vba editor in Excel (alt+f11) doesn't show up in the clipboarddata too...
Don't know why... pasting into notepad works. And copying in from notepad works too. But directly from the VBA editor does not work.

Post Reply