c#


Bullet is not working while converting html content to pdf in iTextsharp in C#


I have tried the below code in C#.Html content has bullets but it is not
showing in created PDF file. In the given example , I have added the two types of bullets one is unorderlist & another one is orderlist.
Could you please give me the solution?
Here is the code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DocToPdfConvertor;
using ClosedXML;
using ClosedXML.Excel;
using System.Configuration;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace DocToPdfConvertor.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
// get the HTML code of this view
string htmlToConvert = #"Types of fruits<div><ul><li>Apple</li><li>Mango</li><li>Banana</li></ul><div>Types of Vegetables</div></div><div><ol><li>Onion</li><li>Tomato</li><li>Potato</li></ol></div><div><br></div>";
string filename = "PDFfile" + DateTime.Now.ToString("dd-MM-yyyy(hh-mm-sstt)") + ".pdf";
string filePath = ConfigurationManager.AppSettings["ProfileImages"];
string fullpath = Path.Combine(filePath, filename);
System.IO.File.WriteAllBytes(fullpath, GetPDF(htmlToConvert));
return View();
}
public byte[] GetPDF(string pHTML)
{
byte[] bPDF = null;
MemoryStream ms = new MemoryStream();
TextReader txtReader = new StringReader(pHTML);
// 1: create object of a itextsharp document class
Document doc = new Document(PageSize.A4,25, 25, 25, 25);
FontFactory.RegisterDirectories();
// 2: we create a itextsharp pdfwriter that listens to the document and directs a XML-stream to a file
PdfWriter oPdfWriter = PdfWriter.GetInstance(doc, ms);
// 3: we create a worker parse the document
HTMLWorker htmlWorker = new HTMLWorker(doc);
// 4: we open document and start the worker on the document
doc.Open();
htmlWorker.StartDocument();
// 5: parse the html into the document
htmlWorker.Parse(txtReader);
// 6: close the document and the worker
htmlWorker.EndDocument();
htmlWorker.Close();
doc.Close();
bPDF = ms.ToArray();
return bPDF;
}
}
}

Related Links

Compile error after renaming projects in my solution
Export to .csv with triple header row in ASP.Net
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll. String from Access
Establish communication between Universal app and Standalone app developed with Unity3d
ASP.NET MVC Passing a List of Lists to the ViewBag
EnvDTE - How to get a file path from a ProjectItem via the FileNames property
Binding ListView inside a GridView
Auto-updating GPS location
Graph with uneven intervals on y axis
Compare date from textbox with date in database in ASP.NET using C#
Timer elapse twice
How to load usercontrol in Mainwindow in MVVM WPF?
Uploading file to a Database using ASP.NET MVC [duplicate]
KeyValuePair not working with JsonFx Serialization
Understanding Delegates & Callbacks
xna sound effect failed to load

Categories

HOME
qlikview
twitter-bootstrap
azure-documentdb
intellij-idea
sip
webvr
crash
overrides
country-codes
genexus
openbsd
distinct
tmux
appsettings
dompdf
airbnb
webgl-earth
android-navigation-drawer
struts
android-wear-2.0
nsopenpanel
android-cursorloader
workflow-foundation
epub
android-scrollview
machine-code
headphones
repeat
pygraphviz
azure-web-roles
redbean
peerjs
result
bootstrap-carousel
logan-square
google-chrome-storage
history
riemann
dotnet-cli
hellosign
codesniffer
qudpsocket
firebase-job-dispatcher
scikit-image
class-design
networkstream
avi
mrunit
avaudiorecorder
android-progressbar
ideavim
newlib
event-tracking
dnvm
winforms-interop
consul-template
genome
crtdbg.h
xcode5
apache-pivot
os.walk
growl
worklight-appcenter
disabled-control
object-oriented-database
sygic
xrandr
servicemanager
dnsbl
urlfetch
linear-interpolation
android-memory
ios6-maps
django-1.4
diazo
wxperl
inserthtml
cherokee
method-call
viewdata
simultaneous
chromebug
onresize
weak-typing
paperless

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App