Quantcast

Question about PdfPCell and setHorizontalAlignment

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Question about PdfPCell and setHorizontalAlignment

Andrew_McLaren

In the iText by example samples, you have the following snippet for setting
the horizontal alignment of a cell:

                  Paragraph p = new Paragraph("Quick brown fox jumps over
the lazy dog. Quick brown fox jumps over the lazy dog.");
                  ...
                  cell = new PdfPCell(p);
                  cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                  table.addCell(cell);

Works great.

However, this does not work:

                  cell = new PdfPCell();
                  cell.addElement(new Phrase("Quick brown fox jumps over
the lazy dog. Quick brown fox jumps over the lazy dog.");
                  cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                  table.addCell(cell);

It will come out aligned to the left.

Am I missing something?

Thanks

Andrew





------------------------------------------------------------------------------
**********
The information contained in this communication is confidential, private, proprietary, or otherwise privileged and is intended only for the use of the addressee.  Unauthorized use, disclosure, distribution or copying is strictly prohibited and may be unlawful.  If you have received this communication in error, please notify the sender immediately at (312)653-6000 in Illinois; (972)766-6900 in Texas; or (800)835-8699 in New Mexico.
**********
==============================================================================



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question about PdfPCell and setHorizontalAlignment

willegy
is your problem had resolved?
Your problem also happened in my code.
If you know how to resolve, send mail to me . thank you very much
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question about PdfPCell and setHorizontalAlignment

willegy
In reply to this post by Andrew_McLaren
I have find the problem from this link behind. Thanks also.
http://stackoverflow.com/questions/12573962/how-to-center-align-template-element-in-pdfpcell
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question about PdfPCell and setHorizontalAlignment

iText Info
In reply to this post by willegy
On 2/28/2014 8:54 AM, willegy wrote:
> is your problem had resolved?
That was a question dating from 2005.
Please don't reopen a thread that old.
In any case: I see that you've found the solution on StackOverflow.

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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
Loading...