Solved

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

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to redirect https://www to non-www? 6 75
Intranet and Kerberos Authentication (not sharepoint!) 8 133
Nameserver and MX Record 2 71
http to https 3 62
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 …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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