I have a document that is created through our web application. My data is stored in a database that allows HTML tags. There are several sections in my document that has HTML tags. Currently, my document does not "convert" those tags - the actual tags print out and I want to "convert" those tags to display the text accordingly. Can this be accomplished with your product? If so, would you please send me some sample code to get me started?
I have attached a sample document. Thanking you in advance for any help/suggestions that you may offer.
Valerie Davis-Binder
Hi Valerie,
// open the document<o:p></o:p>
Document doc = new Document(MyDir + "val2.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
//Get the html
string html = doc.Range.Bookmarks["bm_html"].Text;
doc.Range.Bookmarks["bm_html"].Text = "";
//Move cursor to bookmark and isnert html
builder.MoveToBookmark("bm_html");
builder.InsertHtml(html);
doc.Save(MyDir + "Out.doc");
I have attached the output Docx file with this post for your kind reference. Please let us know if you have any more queries.
Would you please send above code in vb?
Thank you.
The Out.doc file you attached is exactly what I am looking for. I need the code in vb. We do not use C# in our unit.
Just so that I understand, my HTML tags should go here?
doc.Range.Bookmarks["bm_html"].Text = "
auto fit-centered |
"";
Thank you for your help! Valerie |
I have attached a file with an error message - please advise.
Hi Valerie,
Tahir Manzoor:
I suggest you please insert the html contents inside bookmarks while creating the document via your web application.
Would you please see this code to me in vb? We do not use C# in our office.
// open the document
Document doc = new Document(MyDir + "val2.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
//Get the html <?XML:NAMESPACE PREFIX = O />
string html = doc.Range.Bookmarks["bm_html"].Text;
doc.Range.Bookmarks["bm_html"].Text = "";
//Move cursor to bookmark and isnert html
builder.MoveToBookmark("bm_html");
builder.InsertHtml(html);
doc.Save(MyDir + "Out.doc");
Do you have any sample code that you could share with me on how to insert bookmark while creating the val2.DOC, dynamically? Also, I will need this code in vb, please.
Here is my code where I am creating my *.doc
For i As Integer = 0 To reqIds.Count - 1
AmendmentRequests(i) = reqPntProc.GetRequestData(reqIds(i).ToString(), meetnDate)
Next
Dim wordDocBuilder As New RequestWordMLBuilder()
'Dim reqPrntProc As New RequestPrintingProcess()
wordDocBuilder.BuildPacketDetailDocument(AmendmentRequests, "LEG_packet.xsl")
MemoryStreamHelper.WriteToHttpResponse(PreConditionDoc(wordDocBuilder.Document), Me.Page.Response, ".DOC")
ValerieDavis-Binder:
Would you please see this code to me in vb? We do not use C# in our office.
'open the document
Dim doc As New Document("E:\val2.doc")
Dim builder As New DocumentBuilder(doc)
' Use the indexer of the Bookmarks collection to obtain the desired bookmark.
Dim bookmark As Bookmark = doc.Range.Bookmarks("bm_html")
' Get the name and text of the bookmark.
Dim name As String = bookmark.Name
Dim html As String = bookmark.Text
bookmark.Text = ""
'Move cursor to bookmark and isnert html
builder.MoveToBookmark("bm_html")
builder.InsertHtml(html)
doc.Save("E:\Out.doc")
ValerieDavis-Binder:
Here is my code where I am creating my *.doc
Dim builder As New DocumentBuilder()
builder.StartBookmark("bm_html")
builder.Writeln("Text inside a bookmark.")
builder.EndBookmark("bm_html")
Any idea why I am getting this message "declaration expected" - I am using the code you sent previously. Please see attached file. What am I missing?
Thanks!
Valerie
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'open the document
Dim doc As New Document("E:\val2.doc")
Dim builder As New DocumentBuilder(doc)
' Use the indexer of the Bookmarks collection to obtain the desired bookmark.
Dim bookmark As Bookmark = doc.Range.Bookmarks("bm_html")
' Get the name and text of the bookmark.
Dim name As String = bookmark.Name
Dim html As String = bookmark.Text
bookmark.Text = ""
'Move cursor to bookmark and isnert html
builder.MoveToBookmark("bm_html")
builder.InsertHtml(html)
doc.Save("E:\Out.doc")
End Sub
Is it possible to have more than 1 bookmark in your document with the same name? My document consists of one to many separate files saved into the one "Master File". Each separate file within the "Master File" has a section named "Problem Statement" and I need to have a bookmark for each of those "Problem Statement" sections.
If you can not have multiple bookmarks with identical names, how would you suggest that I accomplish this task? Any sample code would be greatly appreciated.
Also, how would you retrieve all the bookmarks from the "Master File"?
I have attached an example of my "Master File" and you will see the "Problem Statement" sections highlighted in yellow.
Thank you for your continued support!
Valerie
'open the document
Dim doc As New Document("d:\multi.doc")
Dim builder As New DocumentBuilder(doc)
For Each bm As Bookmark In doc.Range.Bookmarks
If bm.Name.StartsWith("html") Then
Dim html As String = bm.Text
bm.Text = ""
builder.MoveToBookmark(bm.Name)
builder.InsertHtml(html)
End If
Next
doc.Save("d:\Out.doc")