Which Chunk?  I am generically changing all fonts that come out of the
HTMLWorker, but when the element that comes out is a PdfPTable, the
chunk.size() is zero.  I have also tried to dig into the table, and the
rows, and use the getCells() method, but that throws a null pointer.


Here is code I am using:

ArrayList htmlObjs = HTMLWorker.parseToList(new StringReader(html),
this.styles);
                        for (int k = 0; k < htmlObjs.size(); ++k) {
                                // fix underlining location if necessary.
                                Element ielement = (Element)htmlObjs.get(k);
                                ArrayList<Chunk> chunks = ielement.getChunks();
                                //general cleanup example
                                for (int j = 0; j < chunks.size(); j++) {
                                        if 
(chunks.get(j).getFont().isUnderlined()) {
                                                newfont = new 
Font(chunks.get(j).getFont().getFamily(),
chunks.get(j).getFont().getSize(), Font.NORMAL);
                                                chunks.get(j).setFont(newfont);
                                                
                                                chunks.get(j).setUnderline(1f, 
-1f); // set new underline
                                        }
                                        
chunks.get(j).getFont().setFamily(FontFactory.TIMES_ROMAN);
                                }
                                
                                if (htmlObjs.get(k) instanceof Paragraph) {
                                        // Add space between paragraphs.

                                        }
                                        c1.addElement(p);
                                } else {
                                        c1.addElement((Element)htmlObjs.get(k));
                                }
                        }
                        c1.go(); 

                } catch (Exception e) {
                        throw new RuntimeException("HtmlToPdfParser: Could not 
parse HTML",e);
                }
        }

Thanks!


Paulo Soares-3 wrote:
> 
> You'll to change the font in the Chunk.
> 
> Paulo 
> 
>> -----Original Message-----
>> From: pickm [mailto:[email protected]] 
>> Sent: Monday, March 02, 2009 1:51 PM
>> To: [email protected]
>> Subject: Re: [iText-questions] HTMLWorker tables and fonts
>> 
>> 
>> Any ideas on how to change the font in a PdfPTable after it 
>> has been created? 
>> Is there a way to iterate through it and access each cell?
>> 
>> I attempted to use the newer getCells() method in PdfPRow, 
>> and then change
>> the font of the phrases, but that did not work.
>> 
>> Is there an example in the book that I missed related to this?
>> 
>> Thanks!
>> 
>> 
>> 
>> 
>> pickm wrote:
>> > 
>> > I have a tried a couple different things, and I didn't find anything
>> > specific in the mailing list. 
>> > 
>> > I am parsing HTML text into a PDF and I want to change all 
>> fonts to be the
>> > same.  for most elements coming from HTMLWorker, I simply 
>> iterate through
>> > the Chunks and chunk.getFont().setFamily(FontFactory.TIMES_ROMAN).
>> > 
>> > The problem is with PdfPTables.  I cannot seem to tweak the 
>> font.  I tried
>> > to set the default cell, I tried to dig into the table and 
>> get phrases and
>> > set those.  Nothing seems to be working.
>> > 
>> > I also set the tag style to use ....loadTagStyle(tag, 
>> "face", "times new
>> > roman").
>> > 
>> > Any help on this?
> 
> 
> 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.
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
> CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
> Enterprise
> -Strategies to boost innovation and cut costs with open source
> participation
> -Receive a $600 discount off the registration fee with the source code:
> SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> 

-- 
View this message in context: 
http://www.nabble.com/HTMLWorker-tables-and-fonts-tp22232868p22298266.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to