Tuesday, March 23, 2010

Generate RTF file?

I'm trying to just create a simple function I can stick in my
flash remoting cfc file that can generate an rtf file. I will later
be quering a database for text between two dates or orders
submitted and just making an rtf file of the text. This will
prevent typos on ordered products. The rtf can then be opened in
Illustrator.



Here is what I have so far and it doesn't work... Thanks!

Generate RTF file?
After some major research I found this is the best way.
However it doesn't give any errors but I can't find the file?
Doesn't create it...Generate RTF file?
C-Rock wrote:

%26gt; After some major research I found this is the best way.
However it doesn't give

%26gt; any errors but I can't find the file? Doesn't create
it...



first off you're not var scoping your private variables,
you're going to have

problems under a load.





%26gt; %26lt;cfset thisFolder =
getDirectoryFromPath(getCurrentTemplatePath())%26gt;



this means the dir where the *CFC* is located.


This is the code I found in the Macromedia Coldfusion MX 7
book. I tried it on my server as well. It works but just doesn't
create the file, I know that doesn't make much sense but it's
acting like there's a permission wrong, but I allowed it locally
and online. Or it's acting like the path is wrong.



Normally if the code doesn't execute Flash will give an
error, and it's not.



There will only be on user at a time on this so a load is not
a problem.



Any other code that can do this? What am I missing?
C-Rock wrote:

%26gt; This is the code I found in the Macromedia Coldfusion MX
7 book. I tried it on

%26gt; my server as well. It works but just doesn't create the
file, I know that



did you look where the CFC is located?



%26gt; Normally if the code doesn't execute Flash will give an
error, and it's not.



flash?



%26gt; There will only be on user at a time on this so a load
is not a problem.



doesn't matter, *always* var scope your private variables.


Yes, searched everywhere. Tried it locally and online,
neither worked. It's acting like the path is wrong?



Yes, Flash, I'm using Flash Remoting to call the function
that's all. If there is an error in the CF code Flash will give an
error and it doesn't give one.



I will scope the variable but that's not why this isn't
working...correct?



This is how it is in the book I purchased on CF 7, what's
different with 8?



Does anyone know how to do this simple rtf file of the text?



Thanks,
C-Rock wrote:

%26gt; Yes, searched everywhere. Tried it locally and online,
neither worked. It's

%26gt; acting like the path is wrong?



looking at your 2nd set of code, the modified RTF ''file''
never hits the server

(it's streamed back). try calling this from a cf page %26amp;
see what happens (not

sure how you're handling this in flash).


I'd like to have it just save to the directory. The link will
always be the same, so once it's created and has overwritten the
existing file, Flash will get a response and then I'll prompt the
user of the control panel to download the new rtf file.



How do I get what I have to save to the disk?
C-Rock wrote:

%26gt; How do I get what I have to save to the disk?



cffile with write action. ditch the cfheader %26amp; cfcontent
bits.




that helped, but now i may be even more confused. :)



below is my code. how do i loop until the query is finished
and it displays all the text the same as the first id, which i only
what it's doing now.



how do i add formatting? as you can see my page_break doesn't
work...



thanks!!!




C-Rock wrote:

%26gt; below is my code. how do i loop until the query is
finished and it displays

%26gt; all the text the same as the first id, which i only what
it's doing now.



rather than monkeying around w/more code, you're on cf8?
installed report

builder on your dev w/s? if so, you can use it to create
fairly nice looking

dynamic reports that you can write out using cfreport tag to
PDF, FlashPaper,

Excel, RTF, HTML %26amp; XML formats. this is what it's there
for.



btw we use flashpaper for help, etc. in all our flex/cf apps
a a ''native'' part

of the app.



%26gt; how do i add formatting? as you can see my page_break
doesn't work...



i suggest using cfreport.



your page break doesn't work maybe because the special char
for page breaks is

''\page'', ''\par'' forces a new paragraph.




I actually have tried to use cf report and it does too much
formatting and ideally i need to send the font save for the text to
apply formatting.



This is for a design app creating designs in flash. The text
and font of each order is written to the database. I want
coldfusion to pull it back out and put it in a text document so
that there are no mistakes in typing from the art department.



The rtf file can be opened from Illustrator and used
immediately if I can pull this off. Report builder won't allow me
to name the font of the text on the fly. Most documents will use
many different fonts per line of text...



I just need to figure out how to make the ''text'' string get
the formatting and add it to the document and the document actually
read it.



I have the ''\par'' now and it doesn't work, do I need
both?
C-Rock wrote:

%26gt; The rtf file can be opened from Illustrator and used
immediately if I can pull

%26gt; this off. Report builder won't allow me to name the font
of the text on the

%26gt; fly. Most documents will use many different fonts per
line of text...



sure it can. crack open report builder help %26amp; search for
''Overriding report

styles at run time'' %26amp; ''Creating, editing, and deleting
report styles''.



%26gt; I just need to figure out how to make the ''text'' string
get the formatting and

%26gt; add it to the document and the document actually read
it.



what formatting? don't see any formatting in your code.



%26gt; I have the ''\par'' now and it doesn't work, do I need
both?



as i said, that's a paragraph break *not* a page break.



from your code, not really following what you're trying to do
but maybe start

w/this:



%26lt;!--- old code over-wrote this immediately ---%26gt;

%26lt;cffile action=''read'' file=''#templatePath#''
variable=''content''%26gt;

%26lt;cfset
modifiedRTF=''C:\ColdFusion8\wwwroot\AR-EN\hello2.rtf''%26gt;

%26lt;cfset pageBreak = ''\page''%26gt;

%26lt;cfset paragraphBreak = ''\par''%26gt;

%26lt;cfset revisedContent=''''%26gt;

%26lt;!--- build db-derived content, could also use
cfsavecontent---%26gt;

%26lt;cfoutput query=''testQuery''%26gt;

%26lt;cfset text=''''%26gt;

%26lt;cfset text=text %26amp; text_one_type %26amp;
paragraphBreak%26gt;

%26lt;cfset text=text %26amp; text_two_type %26amp;
paragraphBreak%26gt;

%26lt;cfset text=text %26amp; text_three_type %26amp;
paragraphBreak%26gt;

%26lt;cfset revisedContent=text %26amp; pageBreak%26gt;

%26lt;/cfoutput%26gt;

%26lt;!--- assuming there's a place-holder for this goop
---%26gt;

%26lt;cfset content=replace(content,''your placeHolder goes
here'',revisedContent)%26gt;

%26lt;cffile action=''write'' file=modifiedRTF output=''#content#''
addnewline=''yes''

nameconflict=''overwrite''/%26gt;






What do you mean by place holder?
Here is what the text looks like in the output, it's not
actually formatting the page. I would like to add text formatting
later...



Wednesday, October 31, 2007test\pageno textno texttest text
new\page

No comments:

Post a Comment