Quantcast
Channel: NAV Three Tier — mibuso.com
Viewing all articles
Browse latest Browse all 10032

DotNet code in NAV - problems with overloads

$
0
0
Hi,

I'm trying to implement this code in NAV:
(a simple converter from RTF to HTML)
using System;
using System.IO;
using System.Text;
using Microsoft.Dynamics.Framework.UI.Extensibility;
using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Support;
using Itenso.Rtf.Converter.Image;
using Itenso.Rtf.Converter.Html;
using Itenso.Rtf.Interpreter;
using System.Drawing.Imaging;

namespace RTF2HTMLConverter
{
    [ControlAddInExport("RTF2HTMLConverter")] //5a33fb4258a0a66c
    public class Converter
    {
        string HTML;

        public string RTF
        {
           get
           {
               return HTML;
           }
           set
           {
               MemoryStream RTFStream = new MemoryStream(Encoding.UTF8.GetBytes(RTF));
               
               // Parse RTF
               IRtfGroup RTFStructure;
               RtfParserListenerStructureBuilder StructureBuilder = new RtfParserListenerStructureBuilder();
               RtfParser Parser = new RtfParser(StructureBuilder);
               Parser.IgnoreContentAfterRootGroup = true;
               Parser.Parse(new RtfSource(RTFStream));
               RTFStructure = StructureBuilder.StructureRoot;
               RtfVisualImageAdapter imageAdapter = new RtfVisualImageAdapter("C:\\TEMP\\",ImageFormat.Jpeg);
               
               // Interpret RTF
               IRtfDocument RTFDocument;
               RtfInterpreterSettings InterpreterSettings = new RtfInterpreterSettings();
	       InterpreterSettings.IgnoreDuplicatedFonts = true;
	       InterpreterSettings.IgnoreUnknownFonts = true;
               RTFDocument = RtfInterpreterTool.BuildDoc(RTFStructure, InterpreterSettings);

               // Convert RTF to HTML
               RtfHtmlConvertSettings HTMLConvertSettings = new RtfHtmlConvertSettings();
               HTMLConvertSettings.Title = "Converted from RTF";
               HTMLConvertSettings.IsShowHiddenText = true;
               HTMLConvertSettings.UseNonBreakingSpaces = true;
               RtfHtmlConverter HTMLConverter = new RtfHtmlConverter(RTFDocument, HTMLConvertSettings);
               HTML = HTMLConverter.Convert();
           }
        }
    }
}

I'm stuck with this line:
RTFDocument = RtfInterpreterTool.BuildDoc(RTFStructure, InterpreterSettings);

the possible overloads:
public static IRtfDocument BuildDoc(IRtfGroup rtfDocument, params IRtfInterpreterListener[] listeners);
public static IRtfDocument BuildDoc(IRtfSource rtfTextSource, params IRtfInterpreterListener[] listeners);
public static IRtfDocument BuildDoc(Stream rtfTextSource, params IRtfInterpreterListener[] listeners);
public static IRtfDocument BuildDoc(string rtfText, params IRtfInterpreterListener[] listeners);
public static IRtfDocument BuildDoc(TextReader rtfTextSource, params IRtfInterpreterListener[] listeners);
public static IRtfDocument BuildDoc(IRtfGroup rtfDocument, IRtfInterpreterSettings settings, params IRtfInterpreterListener[] listeners);
public static IRtfDocument BuildDoc(IRtfSource rtfTextSource, IRtfInterpreterSettings settings, params IRtfInterpreterListener[] listeners);
public static IRtfDocument BuildDoc(Stream rtfTextSource, IRtfInterpreterSettings settings, params IRtfInterpreterListener[] listeners);
public static IRtfDocument BuildDoc(string rtfText, IRtfInterpreterSettings settings, params IRtfInterpreterListener[] listeners);
public static IRtfDocument BuildDoc(TextReader rtfTextSource, IRtfInterpreterSettings settings, params IRtfInterpreterListener[] listeners);

not matter what I try I get this
"The function call was ambiguous. No matching method was found."

this is the C/AL code
Name	DataType	Subtype	Length
RtfSource	Text		
MemoryStream	DotNet	System.IO.MemoryStream.'mscorlib'	
Encoding	DotNet	System.Text.Encoding.'mscorlib'	
Convert	DotNet	System.Convert.'mscorlib'	
--PARSE	Boolean		
IRtfGroup	DotNet	Itenso.Rtf.IRtfGroup.'Itenso.Rtf.Parser, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748'	
RtfGroup	DotNet	Itenso.Rtf.Model.RtfGroup.'Itenso.Rtf.Parser, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748'	
RtfParserListenerStructureBuilder	DotNet	Itenso.Rtf.Parser.RtfParserListenerStructureBuilder.'Itenso.Rtf.Parser, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748'	
RtfParser	DotNet	Itenso.Rtf.Parser.RtfParser.'Itenso.Rtf.Parser, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748'	
RtfStructureBuilder	DotNet	Itenso.Rtf.Parser.RtfParserListenerStructureBuilder.'Itenso.Rtf.Parser, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748'	
RtfVisualImageAdapter	DotNet	Itenso.Rtf.Converter.Image.RtfVisualImageAdapter.'Itenso.Rtf.Interpreter, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748'	
ImageFormat	DotNet	System.Drawing.Imaging.ImageFormat.'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'	
--INTERPRET	Boolean		
IRtfDocument	DotNet	Itenso.Rtf.IRtfDocument.'Itenso.Rtf.Interpreter, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748'	
RtfDocument	DotNet	Itenso.Rtf.Model.RtfDocument.'Itenso.Rtf.Interpreter, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748'	
RtfInterpreterSettings	DotNet	Itenso.Rtf.Interpreter.RtfInterpreterSettings.'Itenso.Rtf.Interpreter, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748'	
IRtfInterpreterSettings	DotNet	Itenso.Rtf.IRtfInterpreterSettings.'Itenso.Rtf.Interpreter, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748'	
RtfInterpreterTool	DotNet	Itenso.Rtf.Support.RtfInterpreterTool.'Itenso.Rtf.Interpreter, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748'	

Documentation()

OnRun()
RtfSource := '{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang2057{\fonttbl{\f0\fnil\fcharset0 Calibri;}}{\*\generator Riched20 10.0.14393}\viewkind4\uc1\pard\sa200\sl276\slmult1\b\f0\fs22\lang9 TEST\b0\par}';
MemoryStream := MemoryStream.MemoryStream(Convert.ToByte(Encoding.GetEncoding('UTF8').GetBytes(RtfSource)));

// Parse RTF
IRtfGroup := RtfGroup;
RtfParserListenerStructureBuilder := RtfParserListenerStructureBuilder.RtfParserListenerStructureBuilder;
RtfParser := RtfParser.RtfParser;
RtfParser.AddParserListener(RtfParserListenerStructureBuilder);
RtfParser.IgnoreContentAfterRootGroup := TRUE;
RtfParser.Parse(MemoryStream);
RtfStructureBuilder := RtfParserListenerStructureBuilder.StructureRoot;
RtfVisualImageAdapter := RtfVisualImageAdapter.RtfVisualImageAdapter('C:\TEMP\',ImageFormat.Jpeg);

//Interpret RTF
IRtfDocument := RtfDocument;
IRtfInterpreterSettings := RtfInterpreterSettings;
RtfInterpreterSettings := RtfInterpreterSettings.RtfInterpreterSettings;
RtfInterpreterSettings.IgnoreDuplicatedFonts := TRUE;
RtfInterpreterSettings.IgnoreUnknownFonts := TRUE;
RtfDocument := RtfInterpreterTool.BuildDoc(RtfGroup,RtfInterpreterSettings);

any ideas?

Viewing all articles
Browse latest Browse all 10032

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>