Jump to content

Progamatically load a HTML MS Word document into UniDBHTMLMemo


Recommended Posts

I used the forum topic as the start of what I'm doing

Here's my code in the UniFileUploadCompleted event:

  var DestFolder: string := UniServerModule.StartPath + 'UploadFolder\';
  var DestName: string := DestFolder + ExtractFileName(UniFileUpload1.FileName);
  CopyFile(PChar(AStream.FileName), PChar(DestName), False);

  var AFile: TFile;
  var AHtml: string := AFile.ReadAllText(DestName);

  ACmd := '.execCmd(' + '''' + 'InsertHTML' + '''' + ' , ' + '''' + AHtml + '''' + ')';
  UniSession.AddJS(UniDBHTMLMemo1.JSName + ACmd);

I'm getting an Unterminated String Constant error that I haven't been able to figure out. Any ideas what I need to change?  

There is additional code I've got that makes changes to the AHtml variable.  I don't believe that is the source of my problem because I have inspected the variable in debug, copied the contents and then switched the DBHTMLMemo into source edit mode on the toolbar, pasted in the modified HTML and toggled back to "regular" mode everything displays as expected. 

Link to comment
Share on other sites

55 minutes ago, mbierly said:

Here is the test case to get the Unterminated String Constant error.  I've included the MS Word doc in HTML format that I've been trying to get to load. It's located in the project folder.

Try this

1. Uses list:

  , MainModule
  , uniGUIApplication
  , System.IOUtils
  , System.StrUtils
  , ServerModule
  , ExtPascalUtils //<-----------


  ACmd := '.execCmd(' + '''' + 'InsertHTML' + '''' + ' , ' +  StrToJS(AHtml) + ')'; //<-----------

  UniSession.AddJS(UniHTMLMemo1.JSName + ACmd);


  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...