There was another SVG->Graphics2D library mentioned on the list a while
back... you might try that.


But first, some diagnostics.  What, if anything, is in your template?

System.out.println(template.getInternalBuffer().toString());

And what is the bounding box of your template?

Rectangle templRect = template.getBoundingBox();
// toString will give us wid/hei/rot, but we need x,y's
System.out.println( "bl: " + templRect.getLeft() + ", " +
templRect.getBottom() + "\ntr: " + templRect.getRight() + ", " +
templRect.getTop());

I suspect you'll have some content in your internalBuffer, but it's been
drawn outside the viewable area of your template's bounding box.  If I'm
right (not a given by any stretch), you'll need to use the SVGDocument
to figure out the actual bounding box and translate that so it'll fit in
a "0,0/wid,hei" region.

And when I say "translate" I mean that in the AffineTransform sense:


double x = lowerLeftCornerOfTheSVGX(mySVGDoc); // a dreaded "exercise
for
double y = lowerLeftCornerOfTheSVGY(mySVGDoc); // the reader".  Ha!
AffineTransform alignTransform =
AffineTransform.getTranslateInstance(-x, -y);

// Apply the transform BEFORE you render the SVG.
// Heck, before you get the G2D just for paranoia's sake.
template.transform(alignTransform);



--Mark Storer
  Senior Software Engineer
  Cardiff.com
 
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
 

> -----Original Message-----
> From: chechaquo [mailto:[email protected]]
> Sent: Tuesday, July 20, 2010 3:55 AM
> To: [email protected]
> Subject: [iText-questions] empty table when try to insert images
generate
> using jfreechart, batik
> 
> 
> I'm trying to insert chart generated using jfreechart (it should be
svg )
> in
> table, here is the code:
> 
> 
>                            PdfPTable chartTable = new PdfPTable(1);
>                            float width =  200;
>                            float height = 300;
> 
> 
>                             // Batik: Get a DOMImplementation
>                             DOMImplementation domImpl =
> 
> GenericDOMImplementation.getDOMImplementation();
> 
>                             // Batik: Create an instance of
> org.w3c.dom.Document
>                             Document document =
> domImpl.createDocument(null,
> "svg", null);
> 
>                             // Batik: Create an instance of the SVG
> Generator
>                             SVGGraphics2D svgGenerator = new
> SVGGraphics2D(document);
>                             chart.draw(svgGenerator, new
> Rectangle2D.Double(0, 0, width, height));
> 
> 
> 
> 
> 
>                             PdfContentByte cb =
> pdfWriter.getDirectContent();
>                             PdfTemplate template =
> cb.createTemplate(width,
> height);
>                             Graphics2D g2 =
template.createGraphics(width,
> height);
> 
>                             PrintTranscoder printTranscoder = new
> PrintTranscoder();
>                             TranscoderInput transcoderInput = new
> TranscoderInput(svgGenerator.getDOMFactory());
> 
> 
>                             printTranscoder.transcode(transcoderInput,
> null);
> 
>                             PageFormat pageFormat = new PageFormat();
>                             Paper paper = new Paper();
> 
>                             paper.setSize(width, height);
>                             paper.setImageableArea(0, 0, width,
height);
> 
>                             pageFormat.setPaper(paper);
>                             printTranscoder.print(g2, pageFormat, 0);
>                             g2.dispose();
> 
> 
>                            Image img=Image.getInstance(template);
>                            chartTable.addCell(img);
>                            doc.add(chartTable);
> 
> The result is always empty table... can anybody help me?
> 
> 
> --
> View this message in context: http://itext-
> general.2136553.n4.nabble.com/empty-table-when-try-to-insert-images-
> generate-using-jfreechart-batik-tp2295274p2295274.html
> Sent from the iText - General mailing list archive at Nabble.com.
> 
>
------------------------------------------------------------------------
--
> ----
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.itextpdf.com/book/
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
> 
> 
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.839 / Virus Database: 271.1.1/3009 - Release Date:
07/18/10
> 23:36:00

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to