Copying Program Listings from PDF Documents

Anything QL Software or Programming Related.
Post Reply
henry's cat
ROM Dongle
Posts: 9
Joined: Mon Feb 15, 2016 11:51 am

Copying Program Listings from PDF Documents

Post by henry's cat »

I have been trying to get a long program listing in a PDF version of QL Today to be able to load into QPC2 and have had partial success. The method I use is to highlight the text that I want in Acrobat Reader then coy it, open Notepad and paste the text into it. I then save it as a text file then rename the file with a _bas file extension. When I load it as a Superbasic program I get error messages complaining about syntax erros etc. Is there a way to format the text before loading into Superbasic such as getting rid of DOS carriage returns and line feeds? The errors seem to occur on long lines of text with REMark statements.


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Copying Program Listings from PDF Documents

Post by RWAP »

I use Total Edit Pro (freeware) from http://www.codertools.com/

This allows you to format the text to change line endings, or set them when you save the file (using Save As)


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Copying Program Listings from PDF Documents

Post by tofro »

A useful tool for larger listings would be pdftotext.exe, part of the pdftools set and downloadable from http://www.xpdfreader.com/download.html - This can extract text from all or selected pages of a pdf document into a txt file (you can also set the line endings to "unix" which prepares the file for QL processing).

Any Windows editor that understands Unix line endings (I prefer Sublime text, but you can also use other free text editors like the great Notepad++) can be used to eliminate OCR errors and other formatting quirks, then.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
NormanDunbar
Forum Moderator
Posts: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Copying Program Listings from PDF Documents

Post by NormanDunbar »

Another couple of problems copying code from pdfs, are:
  • Unicode. You get the code OK, but there are spaces between each character. A nightmare to fix.
  • Double spaced lines. Again, a pain to fix, especially on long listing.
  • Code that spans two or more pages, gets the headers, footers, footnotes, page numbers etc, all of which has to be edited out.
  • This was the weirdest though, upside down code when pasted into an editor!
Speaking as someone who doesn't use Windows, except for work when I absolutely must, notepad is pretty useless. There's a far better editor called Notepad++ which I have used for years. It does what the one Rich uses does - and is free. Try both, pick the one you like best.

What I like about it is that if my pc crashes, this is windows remember, unsaved files are still present when I next open the editor

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
henry's cat
ROM Dongle
Posts: 9
Joined: Mon Feb 15, 2016 11:51 am

Re: Copying Program Listings from PDF Documents

Post by henry's cat »

Thanks for all the replies, I will investigate. The download part of the Codertools site seems to be down at the moment.


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Copying Program Listings from PDF Documents

Post by RWAP »

henry's cat wrote:Thanks for all the replies, I will investigate. The download part of the Codertools site seems to be down at the moment.
Yes - the downloads aren't working - but can be found on archive.org - https://web.archive.org/web/20161227042 ... n_v5_7.msi


Post Reply