Page 1 of 1

Copying Program Listings from PDF Documents

Posted: Wed Sep 13, 2017 10:47 am
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.

Re: Copying Program Listings from PDF Documents

Posted: Wed Sep 13, 2017 10:52 am
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)

Re: Copying Program Listings from PDF Documents

Posted: Wed Sep 13, 2017 11:09 am
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

Re: Copying Program Listings from PDF Documents

Posted: Wed Sep 13, 2017 11:14 am
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.

Re: Copying Program Listings from PDF Documents

Posted: Thu Sep 14, 2017 10:03 pm
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.

Re: Copying Program Listings from PDF Documents

Posted: Thu Sep 14, 2017 10:16 pm
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