Solved

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

Posted on 2004-08-12
12
368 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
 

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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now