• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Writing extremely large RTF or .doc files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing extremely large RTF or .doc files


  • Subject: Re: Writing extremely large RTF or .doc files
  • From: Ken Tozier <email@hidden>
  • Date: Sat, 18 Jun 2011 01:15:34 -0400

Is there some reason the text needs to be RTF? Is it just that you want to view this text formatted nicely at a future date? Or do you plan on distributing the monster RTF?

If it's just nicely formatted text you're after would HTML with CSS serve just as well? If so, you could write an aggregator that did something like the following:

- Write HTML head with CSS to dest file
- Query DB for next piece of text
- NSData	*chunk		= [[NSStringWithFormat: @"<p style='header'>%@<p style='body'>%@", chunkHeaderString, chunkBodyString] dataUsingEncoding: NSUTF*StringEncoding];
- [fileHandle writeData: chunk]
- write <body> and <html> close tags to the end of the file

Done.




On Jun 18, 2011, at 12:43 AM, Dave DeLong wrote:

> Hey List,
>
> I'm writing a little app for myself to take a database full of text and format it into either a Word Document or an RTF document (either one is fine for my purposes).  I've got it working for small datasets, but I'm running in to performance issues when trying to generate files larger than a couple of megabytes.
>
> Ideally, I'd like to create my thousands and thousands of NSAttributedStrings, convert them to NSData objects, and stream them out to disk.  Unfortunately, the APIs in AppKit require me to build a single NSAttributedString and convert it into an NSData all at once; no streaming is possible.  For my purposes, this is impractical because of the memory implications of keeping tens of thousands of NSAttributedStrings alive for the duration of the generation process.
>
> The only thought I had to work around this was to generate my RTF data and strip out the document-level attributes before streaming it out to disk.  Barring a superior solution, I'll end up doing this.
>
> I surely can't be the first person to want to do  this, so I ask: what have I missed?  How can I generate extremely large rich-text files without having to build the entire file in memory before writing it out?
>
> Thanks,
>
> Dave
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Writing extremely large RTF or .doc files
      • From: Dave DeLong <email@hidden>
References: 
 >Writing extremely large RTF or .doc files (From: Dave DeLong <email@hidden>)

  • Prev by Date: Writing extremely large RTF or .doc files
  • Next by Date: Re: Writing extremely large RTF or .doc files
  • Previous by thread: Writing extremely large RTF or .doc files
  • Next by thread: Re: Writing extremely large RTF or .doc files
  • Index(es):
    • Date
    • Thread