Re: [iText-questions] ligature implementation for Indian languages / Devanagari script

2011-04-03 Thread 1T3XT BVBA
dilipvs...@hotmail.com wrote:
 Does iText have ligature implementation for Indian languages such as Hindi,
 Gujarati, Marathi, etc?

No, none of the iText developers understand any Indic language.
You are always welcome to contribute code that supports ligatures in 
Indic languages.

--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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


[iText-questions] save all objects in JTextpane in one go

2011-04-03 Thread momomo_o
nbsp;Hello,

I am developing an application with a JTextpane. I want to save all the 
content( including text and image so far) in the JTextpane to a pdf file by 
using iText.

Is there a way that I can save all these objects in the df file in one go? I 
mean, I know how to save text and image respectively, but do I have to first, 
figure out wether the object is a image or text; Second, save them respectively?

If so, how can I figure out what the object is? Image or text?


Thank you soonbsp; much for help~~~

yours, Chennbsp; 
--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Re: [iText-questions] save all objects in JTextpane in one go

2011-04-03 Thread Balder

Hi

On 3/04/2011 14:18, momom...@sina.com wrote:

Hello,

I am developing an application with a JTextpane. I want to save all 
the content( including text and image so far) in the JTextpane to a 
pdf file by using iText.


Is there a way that I can save all these objects in the df file in one 
go? I mean, I know how to save text and image respectively, but do I 
have to first, figure out wether the object is a image or text; 
Second, save them respectively?


If so, how can I figure out what the object is? Image or text?
This all depends on what is written in the JTextPane.I believe you would 
have to convert the content of the JTextPane to iText's pdf objects.



Thank you soo much for help~~~

that's noo problem


yours, Chen



Regards
--
@redlabbe http://twitter.com/redlabbe
redlab-log http://www.redlab.be/blog
--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Re: [iText-questions] save all objects in JTextpane in one go

2011-04-03 Thread 1T3XT BVBA

Op 3/04/2011 14:18, momom...@sina.com schreef:

Hello,

I am developing an application with a JTextpane. I want to save all 
the content( including text and image so far) in the JTextpane to a 
pdf file by using iText.


A JTextPane is a Swing object.
Swing objects can write themselves to a Graphics2D instance.
PdfGraphics2D implements Graphics2D.
Can't you write the JTextPane to a PdfGraphics2D object?

I think I don't understand the question.

--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Re: [iText-questions] save all objects in JTextpane in one go

2011-04-03 Thread Balder



On 3/04/2011 14:41, 1T3XT BVBA wrote:

Op 3/04/2011 14:18, momom...@sina.com schreef:

Hello,

I am developing an application with a JTextpane. I want to save all 
the content( including text and image so far) in the JTextpane to a 
pdf file by using iText.


A JTextPane is a Swing object.
Swing objects can write themselves to a Graphics2D instance.
PdfGraphics2D implements Graphics2D.
Can't you write the JTextPane to a PdfGraphics2D object?
Word! That could indeed be possible. But he would have to get the 
components that make the visuals of the JTextPane, I think. (Which could 
be built up with e.g. an html file. )


I think I don't understand the question.

I think you did, or we both don't understand it :)





Greetings
Balder
--
@redlabbe http://twitter.com/redlabbe
redlab-log http://www.redlab.be/blog
--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Re: [iText-questions] save all objects in JTextpane in one go

2011-04-03 Thread 1T3XT BVBA

Op 3/04/2011 14:59, Balder schreef:



On 3/04/2011 14:41, 1T3XT BVBA wrote:

Op 3/04/2011 14:18, momom...@sina.com schreef:

Hello,

I am developing an application with a JTextpane. I want to save all 
the content( including text and image so far) in the JTextpane to a 
pdf file by using iText.


A JTextPane is a Swing object.
Swing objects can write themselves to a Graphics2D instance.
PdfGraphics2D implements Graphics2D.
Can't you write the JTextPane to a PdfGraphics2D object?
Word! That could indeed be possible. But he would have to get the 
components that make the visuals of the JTextPane, I think. (Which 
could be built up with e.g. an html file. )


Check out the paintToPdf method in this old example from the first book:
https://itext.svn.sourceforge.net/svnroot/itext/examples/src/in_action/chapter12/JTextPaneToPdf.java

If ta is a JTextPane, g2 a PdfGraphics2D object and alloc a Rectangle, 
you can do:

ta.getUI().getRootView(ta).paint(g2, alloc);

--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

[iText-questions] Add signature at right bottom

2011-04-03 Thread Web Specialist
Hi all.

After trying everything(almost :-) ) I'm here. I need to insert a signature
at right bottom PDF file. PdfPCell, rectangle, image nothing works. What can
I do?

Cheers

Marco
--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Re: [iText-questions] Add signature at right bottom

2011-04-03 Thread 1T3XT BVBA
Op 3/04/2011 15:29, Web Specialist schreef:
 Hi all.

 After trying everything(almost :-) ) I'm here.
After trying what? Have you tried coding at the Nord pole?
Please be more specific about what you've tried and about what you're 
trying to achieve.
We can't read your mind, you know.
 I need to insert a signature at right bottom PDF file. PdfPCell, 
 rectangle, image nothing works. What can I do?
Please don't say nothing works; you risk getting it works for us as 
an answer (maybe even as the only answer). That wouldn't help you, would it?
First explain what you mean when you say you want to add a signature.

Do you want to a real digital signature (as in a /Sig field)?
Then why would you use a PdfPCell, rectangle, or image?
Such a signature field is represented by a widget annotation.
Read chapter 12 for mor info.

Or do you want an image of a signature at the bottom of the page?
Doesn't setAbsolutePosition() work?

--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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


[iText-questions] Question about PdfGraphics2D for saving pdf file

2011-04-03 Thread momomo_o

 Hello,

Thank you for reminding me of using  PdfGraphics2D to solve my save pdf file 
problme. Actually I am new to iText and I search some info of  PdfGraphics2D. 
Here are my solutions:

 public void setTexttoPdf(String filePath,JTextPane ta) throws IOException, 
DocumentException{
 Document pdfDoc = new Document();  
 FileOutputStream pdfFile = new FileOutputStream(new File(filePath));  
  
 PdfWriter writer=PdfWriter.getInstance(pdfDoc, pdfFile);
 writer.setStrictImageSequence(true); 
 pdfDoc.open();

 PdfContentByte cb = writer.getDirectContent();
 cb.saveState();
 DefaultFontMapper mapper = new DefaultFontMapper();
 PdfGraphics2D g2 = (PdfGraphics2D)cb.createGraphics(612, 792, mapper);
  
  ta.paint(g2);
  ta.print(g2);
  cb.restoreState();
  pdfDoc.close();
}


Then I insert a picture(jpg) in my Jtextpane and tried to save it as a pdf 
file, but what I got is an empty pdf file.  What's wrong with my code???


Thanks a lot  for your favor~!

Yours Chen
--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

[iText-questions] Arabic slightly off

2011-04-03 Thread David Thielen
Hi;

I am generating Arabic using ColumnText.setSimpleColumn(...). It is working 
fine about 99% of the time. But as shown in the attached, it is not seperating 
2 glyphs on one word. The text for that line is passed in as a single chunk and 
the phrase passed in is just that single text chunk. setArabicOptions(0), 
setRunDirection(PdfWriter.RUN_DIRECTION_RTL).

The correct render is as shown on the right and is how that text is displayed 
in Word and in IntelliJ. What's also weird is copy/paste between Word and 
Acrobat gets the text really screwed up.

Any idea why it might not be displaying this wrong? Do I need to add somethign 
to Acrobat to properly handle Arabic?

thanks - dave
attachment: Arabic.png

arabic_test.pdf
Description: arabic_test.pdf
--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Re: [iText-questions] Arabic slightly off

2011-04-03 Thread Paulo Soares
I need the code to generate the pdf and a word doc with the same words.

Paulo
  - Original Message - 
  From: David Thielen 
  To: itext-questions@lists.sourceforge.net 
  Sent: Sunday, April 03, 2011 5:53 PM
  Subject: [iText-questions] Arabic slightly off


  Hi;

  I am generating Arabic using ColumnText.setSimpleColumn(...). It is working 
fine about 99% of the time. But as shown in the attached, it is not seperating 
2 glyphs on one word. The text for that line is passed in as a single chunk and 
the phrase passed in is just that single text chunk. setArabicOptions(0), 
setRunDirection(PdfWriter.RUN_DIRECTION_RTL).

  The correct render is as shown on the right and is how that text is 
displayed in Word and in IntelliJ. What's also weird is copy/paste between Word 
and Acrobat gets the text really screwed up.

  Any idea why it might not be displaying this wrong? Do I need to add 
somethign to Acrobat to properly handle Arabic?

  thanks - dave--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Re: [iText-questions] Arabic slightly off

2011-04-03 Thread Paulo Soares
Looks like a bug with the Simplified Arabic font as it works correctly with 
Arial Unicode. It may work in Word because Word uses the OTF tables and iText 
doesn't and it will all depend on what's in the GSUB table.

Paulo
  - Original Message - 
  From: David Thielen 
  To: Post all your questions about iText here 
  Sent: Sunday, April 03, 2011 8:33 PM
  Subject: Re: [iText-questions] Arabic slightly off


  Hi Paulo;

  Here you go, thank you for looking at it. The problem appears to be how it's 
rendering two of the glyphs, or how it's treating their being adjacent.

  I also included the word document which displays them correctly according 
to the person in the AUE who flagged this as wrong (I do not know Arabic).

  thanks - dave



--
  From: Paulo Soares [psoa...@glintt.com]
  Sent: Sunday, April 03, 2011 1:09 PM
  To: Post all your questions about iText here
  Subject: Re: [iText-questions] Arabic slightly off


  I need the code to generate the pdf and a word doc with the same words.

  Paulo
- Original Message - 
From: David Thielen 
To: itext-questions@lists.sourceforge.net 
Sent: Sunday, April 03, 2011 5:53 PM
Subject: [iText-questions] Arabic slightly off


Hi;

I am generating Arabic using ColumnText.setSimpleColumn(...). It is working 
fine about 99% of the time. But as shown in the attached, it is not seperating 
2 glyphs on one word. The text for that line is passed in as a single chunk and 
the phrase passed in is just that single text chunk. setArabicOptions(0), 
setRunDirection(PdfWriter.RUN_DIRECTION_RTL).

The correct render is as shown on the right and is how that text is 
displayed in Word and in IntelliJ. What's also weird is copy/paste between Word 
and Acrobat gets the text really screwed up.

Any idea why it might not be displaying this wrong? Do I need to add 
somethign to Acrobat to properly handle Arabic?

thanks - dave--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Re: [iText-questions] Arabic slightly off

2011-04-03 Thread Paulo Soares
Word provides the glyphs in GSUB that may not be the same as the ones described 
in the CMAP (that's what iText uses). I tried with a couple more arabic fonts 
and they all did ok. It looks that the problem is really with the simplified 
arabic font.

Paulo
  - Original Message - 
  From: David Thielen 
  To: Post all your questions about iText here 
  Sent: Sunday, April 03, 2011 10:14 PM
  Subject: Re: [iText-questions] Arabic slightly off


  Hi;

  When I have Word print to Adobe PDF (using Acrobat), then it does look 
correct and is using the Simplified Arabic. Is it possible that Word tells 
Acrobat to use the OTF tables also when it creates the file? (The attached is 
generated from Word.)

  thanks - dave




--
  From: Paulo Soares [psoa...@glintt.com]
  Sent: Sunday, April 03, 2011 2:10 PM
  To: Post all your questions about iText here
  Subject: Re: [iText-questions] Arabic slightly off


  Looks like a bug with the Simplified Arabic font as it works correctly with 
Arial Unicode. It may work in Word because Word uses the OTF tables and iText 
doesn't and it will all depend on what's in the GSUB table.

  Paulo
- Original Message - 
From: David Thielen 
To: Post all your questions about iText here 
Sent: Sunday, April 03, 2011 8:33 PM
Subject: Re: [iText-questions] Arabic slightly off


Hi Paulo;

Here you go, thank you for looking at it. The problem appears to be how 
it's rendering two of the glyphs, or how it's treating their being adjacent.

I also included the word document which displays them correctly according 
to the person in the AUE who flagged this as wrong (I do not know Arabic).

thanks - dave




From: Paulo Soares [psoa...@glintt.com]
Sent: Sunday, April 03, 2011 1:09 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Arabic slightly off


I need the code to generate the pdf and a word doc with the same words.

Paulo
  - Original Message - 
  From: David Thielen 
  To: itext-questions@lists.sourceforge.net 
  Sent: Sunday, April 03, 2011 5:53 PM
  Subject: [iText-questions] Arabic slightly off


  Hi;

  I am generating Arabic using ColumnText.setSimpleColumn(...). It is 
working fine about 99% of the time. But as shown in the attached, it is not 
seperating 2 glyphs on one word. The text for that line is passed in as a 
single chunk and the phrase passed in is just that single text chunk. 
setArabicOptions(0), setRunDirection(PdfWriter.RUN_DIRECTION_RTL).

  The correct render is as shown on the right and is how that text is 
displayed in Word and in IntelliJ. What's also weird is copy/paste between Word 
and Acrobat gets the text really screwed up.

  Any idea why it might not be displaying this wrong? Do I need to add 
somethign to Acrobat to properly handle Arabic?

  thanks - dave--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Re: [iText-questions] Arabic slightly off

2011-04-03 Thread David Thielen
Ok - thanks.



From: Paulo Soares [psoa...@glintt.com]
Sent: Sunday, April 03, 2011 3:45 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Arabic slightly off

Word provides the glyphs in GSUB that may not be the same as the ones described 
in the CMAP (that's what iText uses). I tried with a couple more arabic fonts 
and they all did ok. It looks that the problem is really with the simplified 
arabic font.

Paulo
- Original Message -
From: David Thielenmailto:da...@windward.net
To: Post all your questions about iText 
heremailto:itext-questions@lists.sourceforge.net
Sent: Sunday, April 03, 2011 10:14 PM
Subject: Re: [iText-questions] Arabic slightly off

Hi;

When I have Word print to Adobe PDF (using Acrobat), then it does look 
correct and is using the Simplified Arabic. Is it possible that Word tells 
Acrobat to use the OTF tables also when it creates the file? (The attached is 
generated from Word.)

thanks - dave




From: Paulo Soares [psoa...@glintt.com]
Sent: Sunday, April 03, 2011 2:10 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Arabic slightly off

Looks like a bug with the Simplified Arabic font as it works correctly with 
Arial Unicode. It may work in Word because Word uses the OTF tables and iText 
doesn't and it will all depend on what's in the GSUB table.

Paulo
- Original Message -
From: David Thielenmailto:da...@windward.net
To: Post all your questions about iText 
heremailto:itext-questions@lists.sourceforge.net
Sent: Sunday, April 03, 2011 8:33 PM
Subject: Re: [iText-questions] Arabic slightly off

Hi Paulo;

Here you go, thank you for looking at it. The problem appears to be how it's 
rendering two of the glyphs, or how it's treating their being adjacent.

I also included the word document which displays them correctly according to 
the person in the AUE who flagged this as wrong (I do not know Arabic).

thanks - dave



From: Paulo Soares [psoa...@glintt.com]
Sent: Sunday, April 03, 2011 1:09 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Arabic slightly off

I need the code to generate the pdf and a word doc with the same words.

Paulo
- Original Message -
From: David Thielenmailto:da...@windward.net
To: 
itext-questions@lists.sourceforge.netmailto:itext-questions@lists.sourceforge.net
Sent: Sunday, April 03, 2011 5:53 PM
Subject: [iText-questions] Arabic slightly off

Hi;

I am generating Arabic using ColumnText.setSimpleColumn(...). It is working 
fine about 99% of the time. But as shown in the attached, it is not seperating 
2 glyphs on one word. The text for that line is passed in as a single chunk and 
the phrase passed in is just that single text chunk. setArabicOptions(0), 
setRunDirection(PdfWriter.RUN_DIRECTION_RTL).

The correct render is as shown on the right and is how that text is displayed 
in Word and in IntelliJ. What's also weird is copy/paste between Word and 
Acrobat gets the text really screwed up.

Any idea why it might not be displaying this wrong? Do I need to add somethign 
to Acrobat to properly handle Arabic?

thanks - dave
--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Re: [iText-questions] Question about PdfGraphics2D for saving pdf file

2011-04-03 Thread Bill Ensley

You missed 1T3XT BVBA's earlier post.

 Check out the paintToPdf method in this old example from the first book:
 
https://itext.svn.sourceforge.net/svnroot/itext/examples/src/in_action/chapter12/JTextPaneToPdf.java


 If ta is a JTextPane, g2 a PdfGraphics2D object and alloc a 
Rectangle, you can do:

 ta.getUI().getRootView(ta).paint(g2, alloc);

not

ta.paint(g2) or ta.print(g2)

Neither of those will work.

FYI, I am the author of that original example.

You can definitely to what you want to do here, you just have to follow 
the rules.


-Bill Ensley
www.bearprinting.com

On 4/3/2011 8:43 AM, momom...@sina.com wrote:


Hello,

Thank you for reminding me of using PdfGraphics2D to solve my save pdf 
file problme. Actually I am new to iText and I search some info of 
PdfGraphics2D. Here are my solutions:


public void setTexttoPdf(String filePath,JTextPane ta) throws 
IOException, DocumentException{

Document pdfDoc = new Document();
FileOutputStream pdfFile = new FileOutputStream(new File(filePath));

PdfWriter writer=PdfWriter.getInstance(pdfDoc, pdfFile);
writer.setStrictImageSequence(true);
pdfDoc.open();

PdfContentByte cb = writer.getDirectContent();
cb.saveState();
DefaultFontMapper mapper = new DefaultFontMapper();
PdfGraphics2D g2 = (PdfGraphics2D)cb.createGraphics(612, 792, mapper);

ta.paint(g2);
ta.print(g2);
cb.restoreState();
pdfDoc.close();
}


Then I insert a picture(jpg) in my Jtextpane and tried to save it as a 
pdf file, but what I got is an empty pdf file. What's wrong with my 
code???



Thanks a lot for your favor~!

Yours Chen


--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself;
WebMatrix provides all the features you need to develop and
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf


___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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
--
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
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