Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » String EncodeHtml (how to understand the vast majority of parameters of this function?)
Re: String EncodeHtml [message #58735 is a reply to message #58732] Thu, 11 August 2022 09:11 Go to previous messageGo to previous message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 227
Registered: June 2011
Experienced Member
Haven't messed with this method before but I gave it a shot.

Problem #1 is you're using a String when the data type for the first parameter is RichText. If you want to convert a String to RichText you need to Add RichEdit to your project and call ParseRTF on it.

I loaded it as a .brc file but that's not relevant:

#include <Core/Core.h>
#include <RichText/RichText.h>
#include <RichEdit/RichEdit.h>

#include "test.brc"

using namespace Upp;

CONSOLE_APP_MAIN {
    String rtfContent(std_tmpl_vfk, std_tmpl_vfk_length);
    RichText rt = ParseRTF(rtfContent);
    
    // Output parameters
    Index<String> css;
    VectorMap<String, String> links;
    VectorMap<String, String> labels;

    // Context, I'm assuming
    HtmlObjectSaver saver;
    
    String result = EncodeHtml(rt, css, links, labels, saver);
    
    Cout() << result;

    // To get the css
    Cout() << AsCss(css);
}


I don't know what the deal is with your .rtf string but it doesn't work. I have been able to render other rtf documents using this method though.
EDIT
Never mind, you didn't terminate each line as such:

	String rtfContent =
	"{\\rtf1\\ansi\\ansicpg1252\\deff0{\\fonttbl{\\f0\\fnil Calibri;}{\\f1\\fnil\\fcharset0 Arial;}}\n"
	"{\\colortbl ;\\red0\\green0\\blue0;\\red0\\green0\\blue128;}\n"
	"\\viewkind4\\uc1\\trowd\\trgaph30\\trleft-30\\clbrdrt\\brdrw15\\brdrs\\clbrdrl\\brdrw15\\brdrs\\clbrdrb\\brdrw15\\brdrs\\clbrdrr\\brdrw15\\brdrs \\cellx647\\clbrdrt\\brdrw15\\brdrs\\clbrdrl\\brdrw15\\brdrs\\clbrdrb\\brdrw15\\brdrs\\clbrdrr\\brdrw15\\brdrs \\cellx1840\\clbrdrt\\brdrw15\\brdrs\\clbrdrl\\brdrw15\\brdrs\\clbrdrb\\brdrw15\\brdrs\\clbrdrr\\brdrw15\\brdrs \\cellx2372\\clbrdrt\\brdrw15\\brdrs\\clbrdrl\\brdrw15\\brdrs\\clbrdrb\\brdrw15\\brdrs\\clbrdrr\\brdrw15\\brdrs \\cellx3644\\clbrdrt\\brdrw15\\brdrs\\clbrdrl\\brdrw15\\brdrs\\clbrdrb\\brdrw15\\brdrs\\clbrdrr\\brdrw15\\brdrs \\cellx4112\\pard\\intbl\\cf1\\lang1046\\f0\\fs22\\cell 14/08/2017\\cell %\\cell 16/12/2019\\cell %\\cell\\row\n"
	"\\intbl L1\\cell 0,656\\cell 58\\cell 0,684\\cell 69\\cell\\row\n"
	"\\intbl L2\\cell 0,663\\cell 55\\cell 0,652\\cell 63\\cell\\row\n"
	"\\intbl L3\\cell 0,602\\cell 50\\cell 0,612\\cell 56\\cell\\row\n"
	"\\intbl L4\\cell 0,693\\cell 58\\cell 0,609\\cell 57\\cell\\row\n"
	"\\intbl colo E\\cell 0,719\\cell 69\\cell 0,625\\cell 74\\cell\\row\n"
	"\\intbl troc\\cell\\cell\\cell 0,555\\cell 75\\cell\\row\n"
	"\\intbl radio\\cell 0,747\\cell 84\\cell 0,591\\cell 85\\cell\\row\n"
	"\\pard\\cf2\\b\\f1\\fs16 CD= Manter com Prolia, visto haver ainda risco de fratura.\\par\n"
	"}\n";



You might be better off using raw string literals: https://www.geeksforgeeks.org/raw-string-literal-c/ or putting your rtf in a separate file in your project, loading it from a .brc like I did: https://www.ultimatepp.org/srcdoc$Core$BRC_en-us.html.

[Updated on: Thu, 11 August 2022 12:25]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message icon14.gif
Previous Topic: Skipping footer/header and page numbering...
Next Topic: Paste Properly Scaled Images Into RichEdit
Goto Forum:
  


Current Time: Sun May 11 09:31:48 CEST 2025

Total time taken to generate the page: 0.03156 seconds