Solved

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

Posted on 2004-08-12
12
363 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
Comment Utility
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
Comment Utility
Tried that, I get the same result;  only the first file read
0
 
LVL 35

Expert Comment

by:mrichmon
Comment Utility
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
Comment Utility
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
Comment Utility
can you show me the syntax you used?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 35

Expert Comment

by:mrichmon
Comment Utility
But it does dump the contents of both to the screen?
0
 

Author Comment

by:jimc5240
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed, with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

11 Experts available now in Live!

Get 1:1 Help Now