Discussion:
[itextsharp-questions] Text is superimposed on image by default when converting html using HTMLWorker
tommyp
2009-08-24 11:19:15 UTC
Permalink
Hi everyone,
I'm having a really annoying problem converting html to pdf. I'm using
HTMLWorker and no stylesheet, trying to convert a rather simple html page
with images.
My problem is, that the text on the page is superimposed on the images, as
if the images were background images, or underlying.
I am not changing any attributes etc. during my HTMLWorker processing, and
the alignment attribute is 0.

Any ideas about what could be the problem - any ideas are appreciated.

Thanks
Tommy
--
View this message in context: http://www.nabble.com/Text-is-superimposed-on-image-by-default-when-converting-html-using-HTMLWorker-tp25114277p25114277.html
Sent from the itextsharp-questions mailing list archive at Nabble.com.
s***@regard-solutions.com
2009-08-24 13:29:18 UTC
Permalink
Try using this one....
document.SetMargins(40, 50, 25, 30)
dim tempPath as string= Some path
dim strPDFpath = Server.MapPath("~/PDFS/TempPDFS/") & tempPath
Dim styles As New
iTextSharp.text.html.simpleparser.StyleSheet()
'styles.LoadTagStyle("ol", "leading", "16,0")
Dim fs As New FileStream(strPDFpath,
FileMode.Create, FileAccess.Write)
PdfWriter.GetInstance(document, fs)
Dim path As String =
Server.MapPath("~/App_Themes/MainTheme/")
path = path & "main.css"
document.Add(New
Header(iTextSharp.text.html.Markup.HTML_ATTR_STYLESHEET, path))

Dim objects As ArrayList

styles.LoadTagStyle("li", "face", "garamond")
styles.LoadTagStyle("span", "size", "8px")
styles.LoadTagStyle("body", "font-family", "times
new roman")
styles.LoadTagStyle("body", "font-size", "10px")
'styles.LoadTagStyle("HR", "page-break-after",
"always")
document.Open()

document.NewPage()
'Add footer
Dim footer As New HeaderFooter(New Phrase(" "),
False)
footer.Border = 0
footer.Alignment =
iTextSharp.text.Element.ALIGN_CENTER
document.Footer = footer

'Dim headerPhrase As New Phrase("-")
'Dim header As New HeaderFooter(headerPhrase,
False)
'header.Border =
iTextSharp.text.Rectangle.NO_BORDER
'header.Alignment =
iTextSharp.text.Element.ALIGN_LEFT
'header.BackgroundColor =
iTextSharp.text.Color.WHITE
'document.Header = header

'doc.Add(headerPhrase)
'objects=itextsharp.text .html .simpleparser
.HTMLWorker .
objects =
iTextSharp.text.html.simpleparser.HTMLWorkerExtended.ParseToList(New
StreamReader(strHTMLpath, Encoding.[Default]), styles)

For k As Integer = 0 To objects.Count - 1
document.Add(DirectCast(objects(k), IElement))
Next
document.Close()


----------------------------------------
From: "tommyp" <***@krapo.dk>
Sent: Monday, August 24, 2009 6:17 AM
To: itextsharp-***@lists.sourceforge.net
Subject: [itextsharp-questions] Text is superimposed on image by default
when converting html using HTMLWorker

Hi everyone,
I'm having a really annoying problem converting html to pdf. I'm using
HTMLWorker and no stylesheet, trying to convert a rather simple html page
with images.
My problem is, that the text on the page is superimposed on the images, as
if the images were background images, or underlying.
I am not changing any attributes etc. during my HTMLWorker processing, and
the alignment attribute is 0.

Any ideas about what could be the problem - any ideas are appreciated.

Thanks
Tommy
--
View this message in context:
http://www.nabble.com/Text-is-superimposed-on-image-by-default-when-converti
ng-html-using-HTMLWorker-tp25114277p25114277.html
Sent from the itextsharp-questions mailing list archive at Nabble.com.

----------------------------------------------------------------------------
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day

trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
s***@regard-solutions.com
2009-08-24 13:31:19 UTC
Permalink
Hai Tommy,

Try using this one....

document.SetMargins(40, 50, 25, 30)
dim tempPath as string= Some path
dim strPDFpath = Server.MapPath("~/PDFS/TempPDFS/") & tempPath
Dim styles As New
iTextSharp.text.html.simpleparser.StyleSheet()
'styles.LoadTagStyle("ol", "leading", "16,0")
Dim fs As New FileStream(strPDFpath,
FileMode.Create, FileAccess.Write)
PdfWriter.GetInstance(document, fs)
Dim path As String =
Server.MapPath("~/App_Themes/MainTheme/")
path = path & "main.css"
document.Add(New
Header(iTextSharp.text.html.Markup.HTML_ATTR_STYLESHEET, path))

Dim objects As ArrayList

styles.LoadTagStyle("li", "face", "garamond")
styles.LoadTagStyle("span", "size", "8px")
styles.LoadTagStyle("body", "font-family", "times
new roman")
styles.LoadTagStyle("body", "font-size", "10px")
'styles.LoadTagStyle("HR", "page-break-after",
"always")
document.Open()

document.NewPage()
'Add footer
Dim footer As New HeaderFooter(New Phrase(" "),
False)
footer.Border = 0
footer.Alignment =
iTextSharp.text.Element.ALIGN_CENTER
document.Footer = footer

'Dim headerPhrase As New Phrase("-")
'Dim header As New HeaderFooter(headerPhrase,
False)
'header.Border =
iTextSharp.text.Rectangle.NO_BORDER
'header.Alignment =
iTextSharp.text.Element.ALIGN_LEFT
'header.BackgroundColor =
iTextSharp.text.Color.WHITE
'document.Header = header

'doc.Add(headerPhrase)
'objects=itextsharp.text .html .simpleparser
.HTMLWorker .

objects =
iTextSharp.text.html.simpleparser.HTMLWorkerExtended.ParseToList(New
StreamReader(strHTMLpath, Encoding.[Default]), styles)

For k As Integer = 0 To objects.Count - 1
document.Add(DirectCast(objects(k), IElement))
Next
document.Close()

Happy Coding..
Satyendra Singh

----------------------------------------
From: "tommyp" <***@krapo.dk>
Sent: Monday, August 24, 2009 6:17 AM
To: itextsharp-***@lists.sourceforge.net
Subject: [itextsharp-questions] Text is superimposed on image by default
when converting html using HTMLWorker

Hi everyone,
I'm having a really annoying problem converting html to pdf. I'm using
HTMLWorker and no stylesheet, trying to convert a rather simple html page
with images.
My problem is, that the text on the page is superimposed on the images, as
if the images were background images, or underlying.
I am not changing any attributes etc. during my HTMLWorker processing, and
the alignment attribute is 0.

Any ideas about what could be the problem - any ideas are appreciated.

Thanks
Tommy
--
View this message in context:
http://www.nabble.com/Text-is-superimposed-on-image-by-default-when-converti
ng-html-using-HTMLWorker-tp25114277p25114277.html
Sent from the itextsharp-questions mailing list archive at Nabble.com.

----------------------------------------------------------------------------
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day

trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
tommyp
2009-08-25 12:00:50 UTC
Permalink
Thanks for your answer.
However, had some problems working out exactly what would make your solution
fix my problems.
Now I found that when the img-tag is lacking the align attribute I get the
problems - when I add the align attribute I do not have the problem.
Now, using my CMS we normally do not use align's and try to position
everything using css stylesheets instead.
Any ideas about how to handle this? I'm thinking some css-tricks forcing
iTextSharp to react like if an align were present, or maybe some special
handling in the HTMLWorker processing?
Tommy
--
View this message in context: http://www.nabble.com/Text-is-superimposed-on-image-by-default-when-converting-html-using-HTMLWorker-tp25114277p25132903.html
Sent from the itextsharp-questions mailing list archive at Nabble.com.
Madhura Raj
2009-08-25 14:11:51 UTC
Permalink
Hi,

Please do unsubscribe me.

Thanks,
Mauna


Yahoo! recommends that you upgrade to the new and safer Internet Explorer 8. http://downloads.yahoo.com/in/internetexplorer/
Loading...