TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mas
NA
478
70.5k
At the special characters we are getting ? mark
Jan 30 2020 7:57 PM
Hello All,
Hope you are doing good!!
How can we remove the ? at the special charterers from the preview of document..
Here we are converting the file to HTML and using the microsoft interop we are previewing the file..
Here am adding the code and screenshot issues.
public
partial
class
Default : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
string
res_url =
"https://s3-us-west-2.amazonaws.com/talpal/candidate_resume/52935_1530807980AnilKumar-Sr.devops.docx"
;
show_resume(res_url);
}
public
void
show_resume(
string
resume_url)
{
object
documentFormat = 8;
string
randomName = DateTime.Now.Ticks.ToString();
object
htmlFilePath = Server.MapPath(
"~/Temp/"
) + randomName +
".htm"
;
string
directoryPath = Server.MapPath(
"~/Temp/"
) + randomName +
"_files"
;
object
fileSavePath = Server.MapPath(
"~/Temp/"
) + Path.GetFileName(resume_url);
string
extension = Path.GetExtension(resume_url).ToLower();
if
(extension ==
".pdf"
)
{
resume_viewer.Src =
"doc Path"
;
}
else
{
//If Directory not present, create it.
if
(!Directory.Exists(Server.MapPath(
"~/Temp/"
)))
{
Directory.CreateDirectory(Server.MapPath(
"~/Temp/"
));
}
// Create a new WebClient instance.
using
(WebClient myWebClient =
new
WebClient())
{
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(resume_url, fileSavePath.ToString());
}
//Open the word document in background.
_Application applicationclass =
new
Microsoft.Office.Interop.Word.Application();
applicationclass.Documents.Open(
ref
fileSavePath);
applicationclass.Visible =
false
;
Document document = applicationclass.ActiveDocument;
//Save the word document as HTML file.
document.SaveAs(
ref
htmlFilePath,
ref
documentFormat);
//Close the word document.
document.Close();
//Read the saved Html File.
string
wordHTML = System.IO.File.ReadAllText(htmlFilePath.ToString(), System.Text.Encoding.ASCII);
/* using (FileStream fs = File.Open(htmlFilePath.ToString(), FileMode.Open, FileAccess.ReadWrite))
{
using (StreamReader sr = new StreamReader(fs))
{
wordHTML = sr.ReadToEnd();
}
}*/
// dvWord.InnerHtml = wordHTML;
System.Data.DataTable dtjd = (System.Data.DataTable)Session[
"jd_cand_details"
];
string
mandatory_skills =
"html,javascript,java,.net"
;
string
[] arrskills = mandatory_skills.Split(
','
);
for
(
int
i = 0; i < arrskills.Length; i++)
{
TextInfo myTI =
new
CultureInfo(
"en-US"
,
false
).TextInfo;
string
skill_lower = myTI.ToLower(arrskills[i]);
string
skill_upper = myTI.ToUpper(arrskills[i]);
string
skill_title_case = myTI.ToTitleCase(arrskills[i]);
string
strhtml = wordHTML.Trim();
// string lowerhtml = wordHTML.ToLower();
// < font style = "background-color:yellow" >
wordHTML = wordHTML.Replace(skill_lower.Trim(),
""
+ skill_lower +
""
);
wordHTML = wordHTML.Replace(skill_upper.Trim(),
""
+ skill_upper +
""
);
wordHTML = wordHTML.Replace(skill_title_case.Trim(),
""
+ skill_title_case +
""
);
}
System.IO.File.WriteAllText(htmlFilePath.ToString(), wordHTML, System.Text.Encoding.ASCII);
string
filename =
"http://localhost:61950/Temp/"
+ randomName +
".htm"
;
resume_viewer.Src = filename;
}
}
}
}
.wrap
{
width
:
500px
;
height
:
750px
;
padding
:
0
;
overflow
:
hidden
;
}
.frame
{
width
:
650px
;
height
:
750px
;
border
:
0
;
-ms-transform: scale(
0.75
);
-moz-transform: scale(
0.75
);
-o-transform: scale(
0.75
);
-webkit-transform: scale(
0.75
);
transform: scale(
0.75
);
-ms-transform-origin:
0 0
;
-moz-transform-origin:
0 0
;
-o-transform-origin:
0 0
;
-webkit-transform-origin:
0 0
;
transform-origin:
0 0
;
}
Reply
Answers (
2
)
Emailing from C#
Copy MySQL database to SQL Server using .Net