RTF File Size / Memory

  • I am running a process that appends multiple documents into 1 rtf text box. It works fine, but now the documents are getting larger in size and quantity. I am at a point where all of the memory is consumed resulting in an error. I need to find a way around this.

    I am assuming that the rtf file being built is stored in memory. Is there a way to have it stream to disk?

    I have considered breaking it into pieces, but then I have to merge the pieces back together (have not found a good way to do that yet).

    Any help would be appreciated.

    • Offizieller Beitrag

    Hi,

    it is not possible to stream the files to disk and work with that file instead.

    To load back the documents you can use LoadFromFile - that appends to CursorPosition.

    It would be good to work chapter wise and then, at print time, use PrintParameter.BeginPrint/EndPrint to make sure all pages go into the same printer cue.

    Julian

  • Thanks for your reply.

    My situation is a little different than that. I am not printing the file, just creating it. The file will be printed later or emailed. So, my preference is to have 1 file, if at all possible. If I used loadfromfile to load multiple "pieces", the resulting file would still be too large in regards to memory (unless I am missing something) using a richtext box.

    I tested splitting the file into multiple pieces and each is saved resulting in multiple individual rtf files. I just can't find an easy way to put them back together again.

    • Offizieller Beitrag

    Hi,

    to put the files together you will need to load them - that will cause the large memory consumption, so LoadFromFile will not help.

    Unfortunately RTF files cannot be simply concatenated.

    So I can only think that you create a large PDF file by printing several documents into the same file, wPDF will do that if you call

    wPDF.BeginDoc;
    for i:=0 to docs.Count-1 to
    begin
    WPRichText.Clear;
    WPRichText.LoadFromFile( docs[i] )
    wPDF.Print;
    end;
    wPDF.EndDoc;

    Julian

  • Thanks for the reply.

    Unfortunately I have to keep them in RTF.

    I have created a component that seems to work concatenating the files together. I am going to test it more, but so far it has worked surprisingly well.

    Thanks again.