Tips for getting RTF printing working?

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

Tips for getting RTF printing working?

Postby matthewd » Wed Sep 28, 2016 11:45 pm

I have a customer trying to print an RTF file (a rather simple file with four paragraphs) and our program crashes on the call to VpeRenderRTF (7.1, 32-bit, Windows platform, Windows 10 OS). When this has happened in the past, the usual fix is to load the document in WordPad instead of Word and resave it, or reconstruct the document from scratch in WordPad (usually by copying the text into a Text Editor to remove all formatting, then pasting into WordPad and reapplying any formatting), WordPad seems to create much simpler RTF files than Word, and we have had more success getting VPE to print files saved by WordPad. Of course, this is the first time I'm doing this under Windows 10.

I tried this technique in this case, but noticed two problems: The first word in the 2nd/3rd/4th paragraphs was dropped, and a hyperlink which WordPad automatically and unconditioanlly formats with blue text and underlined is not printed either. I know enough about RTF files to be dangerous: I pulled it up in a text editor and noticed that the first paragraph has a markup code of \pard\sa200\sl276\slmult1 but the other three do not; I added this to the other three paragraphs, and that took care of the missing first word problem. (As if VPE is expecting the next thing to appear after a \par code is another markup code and it is eating the next word that appears instead of printing it?) I also removed the hyperlink codes around the web address, and that took care of the web address not printing.

Of course if I load the file again in WordPad, it automatically applies the formatting to the hyperlink and if I save the file it does not retain the markup codes at the beginning of paragraphs 2/3/4.

Should VPE be able to handle a simple file like this? Or is perhaps Word and WordPad both generating invalid RTF files? I created an RTF file with both the non-working and working codes and have a screenshot here showing the RTF file in WordPad, the VPE preview window, and the RTF file in NotePad++ (the RTF code that doesn't work appears first, then I pasted in my edited lines): Image

Since in this case we don't need any fancy formatting, I will probably just add code to handle a plain text file to do the job now, but it might be helpful for future reference to get more details on the compatibility/limitations of VPE RTF printing...
matthewd
 
Posts: 5
Joined: Wed Sep 28, 2016 10:54 pm

Re: Tips for getting RTF printing working?

Postby matthewd » Thu Sep 29, 2016 1:42 am

Ok nevermind about the problem with the first word in the paragraphs 2/3/4 not printing--that was due to a boneheaded bug in our own software not reading in the RTF file correctly.

The problem with the hyperlink persists though. Starting with the desired text in NotePad++ and copying/pasting into WordPad and Word:

In Word, as long as the hyperlink doesn't get formatted with the blue text and an underline, it is ok. But once Word applies that formatting (when I press Enter at the end of the link) and I resave the RTF file, there is a crash at VpeRenderRTF. My guess is the color is the problem. As soon as I change the color of any text in the RTF file and save it in Word, it crashes. The automatic formatting Word applies to the hyperlink of course changes the color to blue.

In WordPad, the markup for the automatic formatting that it applies to the hyperlink does not seem to be recognized by VPE. It doesn't print any of the text for the link. WordPad seems to be very aggressive in recognizing any type of web address or link and applying formatting to it that can't be overridden. But at least it doesn't crash if I change the color of any text within WordPad and save the document.

Perhaps there is a better standalone RTF editor someone can recommend?
matthewd
 
Posts: 5
Joined: Wed Sep 28, 2016 10:54 pm

Re: Tips for getting RTF printing working?

Postby matthewd » Thu Sep 29, 2016 2:03 am

Followup: I tried Angel Writer from angelicsoftware.com and it 1) does not do the aggressive hyperlink formatting that WordPad does and 2) saves a "VPE safe" RTF file when changing the text color. It does apply the same type of markup to a hyperlink if you press Enter after it that WordPad does. When I did this VPE stopped printing the hyperlink. But at least it doesn't force anything that looks like a link to use this markup.
matthewd
 
Posts: 5
Joined: Wed Sep 28, 2016 10:54 pm

Re: Tips for getting RTF printing working?

Postby IDEAL Software Support » Mon Oct 03, 2016 9:16 am

We are currently working on an enhancement of our RTF parser, so that field results are displayed by VPE.

Hyperlinks in RTF are fields, which are not recognized by VPE in the current version, so it skips them.

If you are using VPE v7.10, we can provide you a beta version for testing - just drop us an e-mail.

Of course under no circumstances VPE may crash on any kind of RTF you supply. In case of a crash, please send us a sample RTF file that makes the problem reproducible.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Re: Tips for getting RTF printing working?

Postby matthewd » Thu Oct 27, 2016 10:22 pm

Thank you I will get some examples together of RTF files that cause crashes.

One other question: Are right-justisfied tab stops in an RTF file supposed to be handled correctly?

They seem to be treated as left justified tabs when VPE prints them. In WordPad and Angel Writer, it doesn't seem to let you create a right-justified tab stop, so I can't compare behavior between Word and those programs.
matthewd
 
Posts: 5
Joined: Wed Sep 28, 2016 10:54 pm

Re: Tips for getting RTF printing working?

Postby IDEAL Software Support » Mon Oct 31, 2016 9:34 am

Right justified and centered tabs are not supported.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 13 guests

cron