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

split line in C# Graphics
Write file need to optimised for heavy traffic part 4
LinkButton as a Default Button
C# Specialise instance of a class
Retrieve numeric values which are not with alphanumeric with dot using regular expressions
C# find installation directory of application
File transfer using sockets (C#) - received file doesn't contain full data
How to read a text from DB which has anchor tag embedded into it and display the same in mvc & C#
Cannot get the value of #Html.DropDownList
Could not get the properties of a generic type by using reflection
Using “where”: Cannot convert lambda expression to type 'bool'
Loading 2 iframes at same time
Get Direct Message Reply in Twitter api
.net prevent keyDown on WebBrowser on certain keystrokes
I can copy a file, but my C# console app can't
How to add child element to XElement as a decoded string?

Categories

HOME
oauth-2.0
qlikview
grizzly
botframework
sql-server-2014
c++builder
nagios
skypedeveloper
opc-ua
sugarcrm
multipartform-data
kohana
pdf-generation
jquery-select2
restheart
pyodbc
software-collections
angularjs-ng-repeat
coding-style
exchange-transport-agents
web-parts
md2
lotusscript
beaker-notebook
ps
checkmarx
log4net-configuration
imageprocessor
incapsula
kofax
gstreamer-1.0
console.readline
mediastream
wicket-tester
hdpi
node.js-client
scrollmagic
lightspeed
stringbuilder
fileopendialog
zsh-completion
firebase-polymer
deck.js
tinybox2
objectify
gdi
mrunit
3d-rendering
abstract
sqldataadapter
askbot
wiql
traminer
textblob
avrcp
joomla3.3
skview
connection-timeout
pymol
pysvn
fedena
fxmlloader
cocos2d-x-2.x
drawable
django-tests
dateadd
banana-pi
jsmpp
image-preloader
sqldatasource
connections
windows-phone-store
autofilter
google-mirror-api
aspnet-compiler
ironworker
violation
backbone-views
feincms
junit-rule
waveout
aspmenu-control
github-archive
towerjs
automapper-2
sessiontracking
service-layer
response-time
datarelation
system-analysis
mysql-pconnect
morfik
qlibrary
scalable

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