Skip to content
Prev 43223 / 398506 Next

scan() Bug?

Thanks for your suggestions on dealing with binary files, Prof Ripley

I ended up using this method:


PDF = file("file.pdf","a+b")
PDFlines = readLines(PDF)
.
.
.
(Extract Some Information From PDFlines and create some objects to add back
to the PDF file)
.
.
.
writeLines(newobjects, PDF, sep = "\12")
close(PDF)


So I opened the file as binary in read/append mode.
Works fine now...though I have noticed that the sep character that actually
gets written to the file is -2 the value specified.
So I wanted \10 and needed to specify \12 to get it. Am I doing something
wrong here?

I'm working on an R package to add annotations(hyperlinks, popups etc.) to
PDF files that I should release in about 2 weeks.  Should be useful
especially to the bioinformatics
people who use R. Incidentally, the uncompressed PDF files that I have seen
R produce are actually just plain text files---human-readable ascii
characters delimited by CR or CR/LF.  They are binary only in the sense that
a cross-reference table at the end of the file records byte offsets of
individual objects in the file. So insertions and deletions cannot be made
without updating the
cross-reference table.




----- Original Message ----- 
From: "Prof Brian Ripley" <ripley at stats.ox.ac.uk>
To: "Greg Riddick" <gr3k at virginia.edu>
Cc: <r-help at stat.math.ethz.ch>
Sent: Thursday, January 22, 2004 4:52 PM
Subject: Re: [R] scan() Bug?
entry
http://www.R-project.org/posting-guide.html