Solved

How to combine multiple RTF files into a single file using CF

Posted on 2004-08-12
12
379 Views
Last Modified: 2013-12-24
I need to join multiple RTF files into a single RTF to accomodate a need for batch printing, ect.   I have tried all sorts of things to make this happen and what I keep ending up with is a combined RTF that has only the first file in it.  I have tried things like:

Writing a new blank rtf (combined.rtf)
Reading the first file
Appending the first file to the combined.rtf
Reading the second file
Appending the second file to the combined.rtf ...

When I do this, I only get the first file read or appended

I also tried things around ----

Read the first file into a variable
Read the second file into another variable

<cfset combined = '#firstFile#' & '#SecondFile#'>
Write the combined.rtf with the variable #combined#

I get the same thing.  Which ever file is in the combined string's  first postion is what I see in the resulting rtf

I also tried appending a "/page " to the first file hoping that this would provide a page break.  

It appears to me that the combined rtf is reaching an 'end of file' flag before getting to the second file.  Also, I'm not sure how all the leading formatting stuff might play into this.  

There must be a simple answer to this but I don't see it so, any help is appreciated.

Jim
0
Comment
Question by:jimc5240
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
12 Comments
 
LVL 17

Expert Comment

by:Tacobell777
ID: 11789493
you could use cfexecute and execute the command line
copy file1.txt+file2.txt destinationName.txt

It will combine the two files for you, lots quicker than reading it into memory with CF...
0
 

Author Comment

by:jimc5240
ID: 11793575
Tried that, I get the same result;  only the first file read
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 11794718
I em guessing that there is a end-of-file character that is getting appended - so that even though both files are there it is stopping writing after it encounters the first end-of-file character.

If you do this do you get both files :

<cfoutput>
#file1#
<br>---<br>
#file2#
</cfoutput>
0
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 

Author Comment

by:jimc5240
ID: 11797211
If I do it that way, it doesn't get recognized as an rtf.  I just all the text in the two files dumped to the screen.  I think you are right about the end of file problem.  I just don't know how to handle it.  Can you somehow strip off the end of file marker and insert a page break?

Jim
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 11797440
can you show me the syntax you used?
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 11797505
But it does dump the contents of both to the screen?
0
 

Author Comment

by:jimc5240
ID: 11799693
Yes, I get both pages worth of output dumped to the screen.  I tried it a couple of different ways;

First,
<cfoutput>
#FirstRTF#
<br>---<br>
#SecondRTF#
</cfoutput>

Then I tried assigning it to  a variable

<cfset theCombinedFile = '#FirstRTF#' & '<br>---<br>' & 'SecondRTF'>

I can dump the contents to the screen or try to write it to a file with the same results as above.

 
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 11811106
What if you strip off the last character or try this

cfset theCombinedFile = Left(FirstRTF, (Len(FirstRTF)) & '<br>---<br>' & Left(SecondRTF, (Len(SecondRTF))>
0
 

Author Comment

by:jimc5240
ID: 11811927
It's not really a single character that indicates the end of the file it's a string.  If you manually ceate a two page file you can see where the second page is added to the first page and there is a long string of info connecting the two pages.  So, it appears that combing the two programatically is going to be more than just adding a br at the end of the file.  I have found a utility to do this called ConvertDoc but it's big bucks but at least I know that it is programatically possible.
0
 

Author Comment

by:jimc5240
ID: 11976735
I ended up just throwing in the towel and converting the documents to PDF's before I convert them to rtf's.  Yeah, I know it's not pretty but PDF let you manipulate the paging pretty easily.  It still runs more than acceptably fast so that's what we're running with.

Thanks to all for you input.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12230015
PAQed, with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question