Generate Resume Experience Summary (parse HTML string)

Source: Internet
Author: User

In the process of generating resumes, my approach is to first design a word resume template, set up bookmarks, read data from the database, call Aspose to populate. There is no problem with general data items including picture files.

The problem is on the HTML string. Because there are several data items in the CV are collected using rich text boxes, the result of the collection is in the format of the HTML string into the database, if you directly from the database to extract such a string to fill word, word is displayed in the HTML string, it is clearly not the result I want. We need to parse the HTML string into text. A simple way is to remove HTML tags directly in the text, the result is to stay is really the user input data content, but only the data content, text format does not have, such as font size, color, space, line wrapping and so on have no, so insert word inside, Poor readability; Find a lot of information on the Internet, found a good way, that is called SautinSoft.HtmlToRtf.dll, this DLL file can handle the full page HTML document conversion to Word files, you can also convert HTML string to RTF string.

in order to convert the HTML string to formatted text, my approach is that the first step, The HTML string is converted to a RTF string through the method inside the SautinSoft.HtmlToRtf.dll, and the second step is to save the RTF string as a Word file, so that the word file is formatted word text, and the third step is to read the generated Word file using Aspose. The text of the polygon, inserted into the resume document that I eventually want to generate.

One of the issues to be particularly aware of here is that I used the SautinSoft.HtmlToRtf.dll is not authorized, there is a conversion of the number of characters limit (1000000), and in the converted RTF string has their copyright tag, I analyzed the RTF characters, the RTF string in the part of the copyright related to the removal of the solution The problem was decided.

private string Htmltranslate (String strhtmlcode)
{
String temp = "";
if (Strhtmlcode! = "")
{
Sautinsoft.htmltortf h = new Sautinsoft.htmltortf ();
H.pagestyle.pagesize.letter ();
H.PAGESTYLE.PAGEMARGINLEFT.MM (20f);

String htmlstring = "";
String rtfstring = "";

htmlstring = strhtmlcode;//html string

rtfstring = h.convertstring (htmlstring);//html string converted to RTF string
rtfstring = Rtfstring.remove (rtfstring.length-454, 453);//rtf string Remove copyright information

String tname = Server.MapPath (@ "~/info/test1.doc");

WriteFile (Tname, rtfstring);//rtf string saved to Word file

Document Tempdoc = new Document (Server.MapPath (@ "~/info/test1.doc"));//Read the generated Word file
temp = Tempdoc. GetText ();//Get text content in a Word file
}
return temp;
}

Generate Resume Experience Summary (parse HTML string)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.