0

I have an iPad app that creates Word Documents from data entered.

Originally i was using html word documents but these wont open in Pages.

I switch to using a RTF file which works for both.

I have a template where i replace sections of text like so:

[template replaceOccurrencesOfString:@"**DATE**" withString:[NSString stringWithFormat:@"%@",startDate] options:NSCaseInsensitiveSearch range:NSMakeRange(0, [template length])];

I can replace the text fine and save as expected.

However the carriage return \n new line character is ignored. I have tried replacing the \n with \r \r\n and \par to no avail

What do i need to replace the carriage return so that it works once saved. Currently it is ignored.

Thank

Dan

Failure of that - a way to create Word documents that work on Both Pages and Word would be great

vascowhite
  • 18,120
  • 9
  • 61
  • 77
Dan
  • 1,447
  • 2
  • 14
  • 30

2 Answers2

0

In word \r and \n should be replaced by the ASCII characters 10 and 13. I'm not sure what language you are using, but chr(10) and chr(13) are likely candidates.

http://www.asciitable.com/

vascowhite
  • 18,120
  • 9
  • 61
  • 77
0

Since you asked for possible alternatives, there is a web service you can call (Docmosis) which provides the ability to create doc/rtf/other documents from Objective-C and stream back to the device (and/or email/store etc). You need to be net-connected and happy with the external dependency but it can save you a lot of time (they have an Objective-C sdk). Please note I work for the company that created Docmosis.

Paul Jowett
  • 6,513
  • 2
  • 24
  • 19
  • Thanks for your input. Does the SDK enable you to download files direct to the iPad? Does the pricing increase with your users or do you have to pick a pricing group straight of? – Dan Sep 12 '12 at 08:34
  • Yes you can stream/download files directly to the ipad. You'd have to contact them to ask how the pricing bands work. – Paul Jowett Sep 12 '12 at 09:11