Thanks for your help dear Paulo,
that was so helpful and now we can see the table.
but still there exist some problems in rendering HTML to PDF.
(of course I found these bugs in Arabic)
1. <img src="..." width="50" height="100"> this will work correct.
but <img src="..." style=" width:50px; height:100px;"> won't work.
2. the contents of <ul> or <ol> are visible. but the bullets are missed.
the indentation is also missed. when i set style like
st.loadTagStyle("ul", "indent", "10");
st.loadTagStyle("li", "leading", "14");
the result doesn't change.
3. the table which came from HTML (in Arabic) is in RTL direction, but the
resulting PdfPTable in PDF is in LTR and I found no way to change the
direction.
also in <td style=" ... ">, the styles will be missed after rendering.
I found no solution for these problems,
any help is appreciable.
Thanks,
Pedram.
On Tue, Jan 11, 2011 at 2:39 PM, Paulo Soares <[email protected]> wrote:
> See http://article.gmane.org/gmane.comp.java.lib.itext.general/19921.
>
> Paulo
>
> ------------------------------
> *From:* pedram farzaneh [mailto:[email protected]]
> *Sent:* Tuesday, January 11, 2011 10:58 AM
> *To:* Post all your questions about iText here
> *Subject:* Re: [iText-questions] HELP NEEDED - render HTML snippet which
> contains Arabic text
>
> thanks for your help dear,
>
> but the font is true, because it works with a pure ColumnText and arabic
> characters are being shown.
> and I added the returned elements in a PdfPTable.
> but the problems remains.
> in fact my problem is with HTML parsing.
> when I have HTML <table> tag and it contains Arabic characters, after
> parsing, the table exists in pdf file but the characters doesn't.
>
> I think there is lack of support for this case.(html code snippet with
> Arabic content).
> I will put my code here,
>
>
> List<Element> objects =
> HTMLWorker.parseToList(new StringReader(""
> + "<p dir=\"ltr\" style=\"text-align: right;\">"
> + " </p>"
> + "<table border=\"1\" cellpadding=\"1\"
> cellspacing=\"1\" style=\"width: 500px;\">"
> + " <tbody> <tr> <td>"
> + " سلام</td>"
> + " <td dir=\"ltr\">"
> + " asdadsasdasdasd</td>"
> + " </tr> <tr>"
> + " <td dir=\"ltr\">"
> + " <strong>asdasdasd</strong></td>"
> + " <td dir=\"ltr\">"
> + " <span style=\"color: rgb(255, 0, 0);\">"
> + "<span style=\"background-color: rgb(255, 255,
> 0);\">dasdasdasdasd</span></span></td>"
> + " </tr> <tr>"
> + " <td> </td>"
> + " <td> </td>"
> + " </tr> </tbody>"
> + "</table>"
> + ""),
> null, providers);
>
> PdfPTable tblHtmlPage = new PdfPTable(1);
> tblHtmlPage.setTotalWidth((float) (pageSize.getWidth() * 0.8));
> tblHtmlPage.setLockedWidth(true);
> tblHtmlPage.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
> tblHtmlPage.setHorizontalAlignment(Element.ALIGN_LEFT);
>
> for (Element element : objects) {
>
> PdfPTable tbl = (PdfPTable) element;
> tbl.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
> tbl.setHorizontalAlignment(Element.ALIGN_LEFT);
>
> tblHtmlPage.addCell(tbl);
> }
>
> tblHtmlPage.writeSelectedRows(0, -1,
> (float) (pageSize.getWidth() - (pageSize.getWidth() *
> 0.1) - tblHtmlPage.getTotalWidth()),
> (float) (pageSize.getTop() - ((pageSize.getHeight() *
> 0.20))),
> contentByte);
>
>
> Thanks for your attention and help.
>
>
>
> On Mon, Jan 10, 2011 at 3:30 PM, 1T3XT BVBA <[email protected]> wrote:
>
>> Op 10/01/2011 12:17, pedram farzaneh schreef:
>> > I have a HTML code snippet which contains <table> in which the columns
>> > contain Arabic text.
>> > after rendering the html snippet by "HTMLWorker" class the resulting
>> > element
>> > is instance of a PdfPTable which is shown in the pdf file but the text
>> > is missed.
>> >
>> > I will appreciate any help.
>> You're experiencing two problems:
>> 1. You're using the wrong font, create a FontProvider as documented in
>> chapter 9.
>> 2. HTMLWorker currently doesn't support the R2L writing system and
>> Arabic Ligaturization. You'll have to work around this, for instance by
>> adding the objects returned by HTMLWorker to a PdfPTable or a ColumnText
>> object for which the R2L parameter is set.
>>
>>
>> ------------------------------------------------------------------------------
>> Gaining the trust of online customers is vital for the success of any
>> company
>> that requires sensitive data to be transmitted over the Web. Learn how
>> to
>> best implement a security strategy that keeps consumers' information
>> secure
>> and instills the confidence they need to proceed with transactions.
>> http://p.sf.net/sfu/oracle-sfdevnl
>> _______________________________________________
>> iText-questions mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>>
>> Many questions posted to this list can (and will) be answered with a
>> reference to the iText book: http://www.itextpdf.com/book/
>> Please check the keywords list before you ask for examples:
>> http://itextpdf.com/themes/keywords.php
>>
>
> ------------------------------
> Aviso Legal:
> Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
> informação confidencial ou legalmente protegida. A incorrecta transmissão
> desta mensagem não significa a perca de confidencialidade. Se esta mensagem
> for recebida por engano, por favor envie-a de volta para o remetente e
> apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o
> destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.
>
> Disclaimer:
> This message is destined exclusively to the intended receiver. It may
> contain confidential or legally protected information. The incorrect
> transmission of this message does not mean the loss of its confidentiality.
> If this message is received by mistake, please send it back to the sender
> and delete it from your system immediately. It is forbidden to any person
> who is not the intended receiver to use, distribute or copy any part of this
> message.
>
>
> ------------------------------------------------------------------------------
> Gaining the trust of online customers is vital for the success of any
> company
> that requires sensitive data to be transmitted over the Web. Learn how to
> best implement a security strategy that keeps consumers' information secure
> and instills the confidence they need to proceed with transactions.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Many questions posted to this list can (and will) be answered with a
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples:
> http://itextpdf.com/themes/keywords.php
>
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php