However, my Graphics2D doesn't split up the JTextPane in different pages...
I post my code (it's really straightforward). Of course, panelTexto is the
JTextPane I want to split up in different pages (in the case it's
necessary).
private void
menuArchivoExportarAPDFActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_menuArchivoExportarAPDFActionPerformed
try {
JFileChooser fc = new JFileChooser();
// FileNameExtensionFilter filter = new
FileNameExtensionFilter("PDFs", "pdf");
// fc.setFilter(filter); // No va de momento (problema de JDK??)
if (fc.showSaveDialog(panelTexto) ==
JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
*Document document = new Document();
document.setPageSize(new
com.itextpdf.text.Rectangle(panelTexto.getWidth(), panelTexto.getHeight()));
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(file.getCanonicalPath()+".pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
Graphics2D g2 = cb.createGraphics(panelTexto.getWidth(),
panelTexto.getHeight());
panelTexto.print(g2);
g2.dispose();
document.close();*
}
}
catch (Exception exc) {System.out.println("Excepcion en
menuArchivoExportarAPDF");}
}//GEN-LAST:event_menuArchivoExportarAPDFActionPerformed
Thx in advance!!
2010/10/18 Mark Storer <msto...@autonomy.com>
> "the solution using Graphics2D" is what I was referring to.
> PdfGraphics2D doesn't handle page breaking at all. It just has a bounding
> box and tries to fit whatever you render into it.
>
> If what you want to render won't fit, you need to determine that ahead of
> time and use more than one PDFG2D.
>
> --Mark Storer
> Senior Software Engineer
> Cardiff.com
>
> import legalese.Disclaimer;
> Disclaimer<Cardiff> DisCard = null;
>
>
>
> ------------------------------
> *From:* Joaquín Pérez Marco [mailto:joaquinperezma...@gmail.com]
> *Sent:* Friday, October 15, 2010 11:53 AM
> *To:* Post all your questions about iText here
> *Subject:* Re: [iText-questions] Problem creating PDF with JTextPane
> withembeddedcomponents
>
> I haven't found any, could you please give me some links??
>
> BTW, I've found the solution using Graphics2D, but the component is
> stretched to only one page of final PDF, and since it could be a very large
> JTextPane (it's a word processor), I'd like to know how to split it
> (automatically) on different pages...
>
> Thx in advance!! :)
>
> 2010/10/12 Mark Storer <msto...@autonomy.com>
>
>> Can't you just render it to a PdfGraphics2D? There are several samples
>> using it floating around the web.
>>
>> --Mark Storer
>> Senior Software Engineer
>> Cardiff.com
>>
>> import legalese.Disclaimer;
>> Disclaimer<Cardiff> DisCard = null;
>>
>>
>>
>> ------------------------------
>> *From:* Joaquín Pérez Marco [mailto:joaquinperezma...@gmail.com]
>> *Sent:* Monday, October 11, 2010 8:02 AM
>> *To:* itext-questions@lists.sourceforge.net
>> *Subject:* [iText-questions] Problem creating PDF with JTextPane with
>> embeddedcomponents
>>
>> Hi!! I have a JTextPane full of embedded components (all of them are
>> JPanel, with a JLabel with image and a JTextField with text each one). I'd
>> like to create a PDF that reflects exactly the layout of the JTextPane, I
>> have read tutorials, etc. but I don't get much (with only text in a
>> JTextPane is easy, but with embedded components it's not so easy I
>> think...). Someone can help me?? Thx in advance!!
>>
>> Joaquín
>>
>> --
>> Multitud de cosas a la venta o cambio!! http://www.cosasquevendo.es
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com
>> Version: 9.0.862 / Virus Database: 271.1.1/3184 - Release Date: 10/10/10
>> 23:34:00
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Beautiful is writing same markup. Internet Explorer 9 supports
>> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
>> Spend less time writing and rewriting code and more time creating great
>> experiences on the web. Be a part of the beta today.
>> http://p.sf.net/sfu/beautyoftheweb
>> _______________________________________________
>> iText-questions mailing list
>> iText-questions@lists.sourceforge.net
>> 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
>>
>
>
>
> --
> Multitud de cosas a la venta o cambio!! http://www.cosasquevendo.es
>
>
>
> ------------------------------------------------------------------------------
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!
> http://p.sf.net/sfu/adobe-dev2dev
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> 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
>
--
Multitud de cosas a la venta o cambio!! http://www.cosasquevendo.es
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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