Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge RTF files

Tags:

c#

rtf

I have a set of RTF's stored in strings in C# is their a way to merge these into one document for printing as the user wants to print them as one document with the print settings appearing once. I can use office interop if necessary, obviously avoiding this is better.

Edit: A page break would be necessary between each document I think I can just insert \page for this though

like image 405
PeteT Avatar asked Mar 10 '09 00:03

PeteT


People also ask

Can you edit an RTF file in word?

Google Chromebook and Other Android Mobile DevicesTry editing rtf files using Microsoft Office Mobile or Microsoft Word app for Android. Both are available on Google Play. Editing rtf files is also possible using Google Docs.

Is RTF file a word document?

Rich Text Format (RTF) is a file format that lets you exchange text files between different word processors in different operating systems (OSes). For example, you can create a file in Microsoft Word and then open it in another word processor, such as Apple Pages or Google Docs.


1 Answers

You would have to remove the trailing } from the first document.

You would have to remove the {\rtf1... and {fonttbl.. and {colortbl... sections from the second document. Might need to look at any header, margins etc. that you might have.

Separate them by a \page as you say.

This assumes the font and color tables are the same.

Probably better to get the print settings from the user then silently print each document separately, if that's an option.

Document 1:

{\rtf1\ansi\ansicpg1252\deff0\deflang5129
{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}}
{\colortbl;\red0\green0\blue0;}
\margl1134\margr1134\margt1134\margb1134\sectd 
\pard
Document One Content
\line
}

Document 2:

{\rtf1\ansi\ansicpg1252\deff0\deflang5129
{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}}
{\colortbl;\red0\green0\blue0;}
\margl1134\margr1134\margt1134\margb1134\sectd 
\pard
Document Two Content
\line
}

Merged Documents:

{\rtf1\ansi\ansicpg1252\deff0\deflang5129
{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}}
{\colortbl;\red0\green0\blue0;}
\margl1134\margr1134\margt1134\margb1134\sectd 
\pard
Document One Content

\page

\pard

Document Two Content
\line
}
like image 65
MikeW Avatar answered Nov 04 '22 04:11

MikeW