Copying Program Listings from PDF Documents

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

Copying Program Listings from PDF Documents

Postby henry's cat » Wed Sep 13, 2017 10:47 am

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: 2247
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Copying Program Listings from PDF Documents

Postby RWAP » Wed Sep 13, 2017 10:52 am

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
QL Wafer Drive
Posts: 1155
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Copying Program Listings from PDF Documents

Postby tofro » Wed Sep 13, 2017 11:09 am

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


User avatar
NormanDunbar
Gold Card
Posts: 289
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Copying Program Listings from PDF Documents

Postby NormanDunbar » Wed Sep 13, 2017 11:14 am

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?
How come Tarzan never grew a beard?
henry's cat
ROM Dongle
Posts: 7
Joined: Mon Feb 15, 2016 11:51 am

Re: Copying Program Listings from PDF Documents

Postby henry's cat » Thu Sep 14, 2017 10:03 pm

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: 2247
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Copying Program Listings from PDF Documents

Postby RWAP » Thu Sep 14, 2017 10:16 pm

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



Return to “Software & Programming”

Who is online

Users browsing this forum: No registered users and 2 guests