Skip to main content
Participant
December 11, 2007
Question

Multiple RTF to one PDF on the Fly

  • December 11, 2007
  • 6 replies
  • 2669 views
We have a little department that have a lot of our records stored in a SQL db as RTF. We have created a search form that can display the results of the search as links to the individual RTF files. What we would like to do is have a button that would concatenate all the RTF into one PDF file for display or print.

Is there a combination of Adobe products that we can get that would allow us to essentially create a PDF on the fly from multiple RTF files? Or do you have recommendation for other solutions/products that can help us achieve this. We already have CF8.

It is my understanding that if we had PDF files instead of RTF, then one can simply use the tag CFPDF to do the concatenation on the fly. However, this is not an option for us. Right now, since there are a ridiculous amount of archived RTFs and constant additions of new ones, it is not piratical to convert all of them to PDF. Furthermore, since RTF is in ASCII, it is easy to store in SQL, do searches on, and move about.

RTF to PDF on the fly?

-RB
This topic has been closed for replies.

6 replies

Participant
March 16, 2010

Hi,

In my view you may convert each RTF file to PDF in memory and next next merge PDF documents into single PDF:

1. Convert each RTF to PDF in memory

SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

ArrayList pdfs = new ArrayList();

//1st RTF to PDF

byte[] pdf = p.RtfToPdfConvertByte(rtfString1);

pdfs.Add(pdf);

//2nd RTF to PDF

pdf = p.RtfToPdfConvertByte(rtfString2);

//etc, or you may use loop

pdfs.Add(pdf);

2. Merge several PDF to single PDF on fly

  //merge to single PDF
byte[] singlePDF = p.MergePDF(pdfs);

       
        //show PDF
        if (singlePDF != null)
        {
            Response.Buffer = true;
            Response.Clear();
            Response.ContentType = "application/PDF";
            Response.AppendHeader("content-disposition", "attachment; filename=single.pdf");
            Response.BinaryWrite(singlePDF);
            Response.Flush();
            Response.End();
        }

This code uses the .Net component 'PDF Metamorphosis .Net', so it will also work in CF8.

Best wishes,

Max

Inspiring
January 27, 2008
tojoba wrote:
> The new release of itext seems to imply that it can now handle rtf, albeit I
> have not as of yet tried it.
>
> public class RtfWriter2extends DocWriterThe RtfWriter allows the creation of
> rtf documents via the iText system Version: $Id: RtfWriter2.java 2996
> 2007-11-20 22:40:36Z hallm $

it's pretty much *always* been able to *create* RTF files, this problem is about
reading in RTF & writing the text out as a PDF.
Participant
January 26, 2008
The new release of itext seems to imply that it can now handle rtf, albeit I have not as of yet tried it.

public class RtfWriter2extends DocWriterThe RtfWriter allows the creation of rtf documents via the iText system Version: $Id: RtfWriter2.java 2996 2007-11-20 22:40:36Z hallm $

from this page
Inspiring
January 23, 2008
-==cfSearching==- wrote:
> I was wondering about that. So what format would POI parse it into? ie From
> RTF > POI (??) > To iText

i *think* POI will extract just the text. if you need to reproduce the original
formatting you'll need something more heavy-duty which often means commercial.

Inspiring
January 25, 2008
PaulH wrote:
> i *think* POI will extract just the text.

Interestingly POI appears to extract text and style information. Though the documentation is a little sketchy in some areas. From what I can tell POI does not support rtf, only ms word doc files. I think javax.swing.text.rtf does though.

Unless you have the time to devote to it, a commercial product is probably the way to go for now.
Inspiring
January 23, 2008
PaulH wrote:
> as iText ... currently can't read RTF--though somebody's
> working on it:

Cool. That would be a nice addition to to iText.

> or another trick might be to use POI to parse the RTF.

I was wondering about that. So what format would POI parse it into? ie From RTF > POI (??) > To iText
Participant
January 17, 2008
Wow, over a month now and still NO REPLY!?

Is there some other forums for CF on the net that actually have enough active users that a response is likely?

-RB
Inspiring
January 21, 2008
Sorry I do not have an answer for you. I think it is a matter of someone that has done this before seeing your question. While I have not, I suspect it may involve java. The closest I have seen is an entry on majix(convert rtf to xml) and ujac (convert to xml to pdf). It may not be the best way to go. I am just throwing it out as a possibility.

You might also ask over at CF-Talk on houseoffusion.com. If you do get an answer, please post back here. I would be interested to know what you end up doing.
Inspiring
January 22, 2008
they do have <cfpdf> tag in cf8 that can do pdf merging...

---
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com