Re: PDFKit Removes Line Breaks in Annotations
Re: PDFKit Removes Line Breaks in Annotations
- Subject: Re: PDFKit Removes Line Breaks in Annotations
- From: Stewart Milberger <email@hidden>
- Date: Mon, 24 Apr 2006 12:29:59 -0600
For the record, I think I found why this is happening, but not a
solution using PDF Kit. I ended up writing code to read the
annotations using Quartz, and found that the function
CGPDFStringCopyTextString converts the '\r' characters to spaces, so
the problem is at a lower level--I'm assuming of course that PDF Kit
is using this function.
I was able to convert the CGPDFStringRef to a NSString by getting the
raw characters with CGPDFStringGetBytePtr, and using +[NSString
stringWithCString: encoding] which preserved the '\r' characters.
I'm not sure what the best encoding to use is, but I guess I'll try
asking on Quartz-dev.
Stewart Milberger
Megaptera, Inc.
On Apr 20, 2006, at 4:55 PM, Stewart Milberger wrote:
I'm having a problem using PDFKit to correctly read text
annotations (PDFAnnotationText) for pages in a PDF document.
I am creating the text annotations in Adobe Acrobat (as notes) and
the text has multiple lines per annotation. When I examine the PDF
file, it has '\r' characters in the appropriate locations in the text.
When I open the PDF in Preview, which I understand uses PDFKit, the
text annotations (notes) are there, but have the carriage returns
are replaced by spaces.
This is also the case in my application which uses PDFKit:
PDFDocument *pdf_document = [[PDFDocument alloc]
initWithURL:url];
.
.
.
PDFPage *page = [pdf_document pageAtIndex:i];
NSArray *annotations = [page annotations];
for (unsigned j = 0; j < [annotations count]; ++j) {
if ([[annotations objectAtIndex:j] isKindOfClass:
[PDFAnnotationText class]]) {
NSString *contents = [[annotations
objectAtIndex:j] contents];
.
.
.
}
The variable contents always has the '\r' characters replaced with
space characters. Anyone have any idea why this is?
Thank you,
Stewart Milberger
Megaptera, Inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden