Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
2
Answers
At the special characters we are getting ? mark
Mas
5y
550
1
Reply
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
;
}
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Emailing from C#
Copy MySQL database to SQL Server using .Net