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

DataGrid gets Index -1 does not have a value when selected row changes
Little guide of Simple Data binding in C#
Change image size with C# in MVC3?
Can I save a postback status and restore it?
Connect passive STS to active STS
display array from XML c# Windows Phone 7 listbox
WebClient in a WP7.1 app called only once
HttpContext.Current return null
How to get window's position? [duplicate]
FileUpload.HasFile() always null
Using regex or string manipulation when creating permalinks
Predict the byte size of a base64 encoded byte[]
docs.descendants is Loading empty
Setting timer to an asynchronous request
Get Sum of Data from BindingSource with Filter
generate xml file from the Output

Categories

HOME
logging
phantomjs
nagios
ebay-api
watson-iot
stdout
pandoc
opengl-es
wavefront
sahi
openbsd
digital
velocity
elastalert
urllib2
ldap-query
versioning
udeploy
spring-webflow
keystone
multipart
mongoose-im
pydub
visual-studio-community
windows-10-mobile
bytebuffer
openoffice-impress
lines
epub
offset
zimbra
hippocms
outlook-2010
scip
console.readline
motion
glide-image-library
anonymous-function
infovis
runner
ionic2-select
dotnet-cli
vertex
jcifs
fckeditor
boost-regex
aot
printer-control-language
nls
timefield
xcode7.1
csc
php-java-bridge
django-celery
mrunit
calc
imageicon
gulp-cdnizer
dpkt
dcg
pdcurses
fileinputstream
ultraedit
applinks
worklight-appcenter
ios-enterprise
angular-file-upload
rails-migrations
xps
iwork
autofilter
randomaccessfile
mobile-robots
cloudmade
cryptarithmetic-puzzle
m3u
mvcmailer
facebook-winjs-sdk
visual-leak-detector
mscorlib
service-layer
auto-compile
cpack
mass-emails
fxcopcmd
arraycollection
xslt-grouping
mysql-pconnect
web-widget
mdd

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