Solved

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

Posted on 2004-08-12
12
378 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

Suggested Solutions

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

820 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