Hi,

I am pasting a code below , i want to create a SVG
file of MyTotalPanel so i can create a PDF file from
this SVG file, 
but some how it is not working, can any one please
point out why,
I dont care how big the file is, or if it fits in one
page or not, i want a SVG file so can be viewd on
screen by scrolling

Ashish
/** code here
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.*;
import java.io.*;
import java.awt.print.*;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;

import org.w3c.dom.*;
import org.apache.xerces.dom.*;
//import org.apache.batik.svggen.*;
import java.io.FileOutputStream;
import java.io.Writer;
import java.io.OutputStreamWriter;
import org.apache.batik.svggen.*;
import org.apache.batik.svggen.*;
import java.awt.image.BufferedImage;
import org.apache.batik.dom.GenericDOMImplementation;

public class TestPDFCreation extends JFrame implements
ActionListener
{
        
        private MyTotalPanel totalPanel;
        public TestPDFCreation()
        {
        super("Print Frame");

this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("create svg");
    JMenuItem svg = new JMenuItem("Create SVG");
        svg.addActionListener(this);
        menu.add(svg);
        menuBar.add(menu);
        totalPanel = new MyTotalPanel();
        this.setJMenuBar(menuBar);
        JScrollPane pane = new JScrollPane(totalPanel,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    this.getContentPane().add(pane);
        this.setSize(1000,700);
        show();
        }
                public void actionPerformed(ActionEvent evt)
        {
        //do printing here
                 try
            {
        DOMImplementation domImpl =
        GenericDOMImplementation.getDOMImplementation();
        Document document = domImpl.createDocument(null,
"svg", null);
        SVGGraphics2D svgGenerator = new
SVGGraphics2D(document);
        
        totalPanel.paint(svgGenerator);
       //
svgGenerator.setSVGCanvasSize(totalPanel.getPreferredSize());
        
        String useCssStr =
System.getProperty("useCss", "true");
        boolean useCss =
useCssStr.equalsIgnoreCase("true");

                FileOutputStream fos = new
FileOutputStream("C:\\Fop-0.20.1\\docs\\examples\\svg\\paneltest.svg");
        Writer outWriter = new OutputStreamWriter(fos,
"UTF-8");
        svgGenerator.stream(outWriter, useCss);
        
        }
        
        catch (Exception exc)
        {
     
                exc.printStackTrace();
        }
        }
        
        public class MyTotalPanel extends JPanel
        {
                public MyTotalPanel()
                {
                        this.setBackground(Color.white);
                        this.setOpaque(true);
                        setPreferredSize(new Dimension(1600, 1600) );
                }       
                public void paintComponent(Graphics g)
      {
          super.paintComponent(g);
          g.setColor(Color.blue);
          int x = 0;
          
                for(int i = 0; i < 100 ; i++)
                {       
                x +=60;
                g.drawLine(x, 0, x, 1600);
                g.drawString(String.valueOf(i), x, 10);
                }
                
                
                }
        }
        
        public static void main(String args[])
    {
        new TestPDFCreation();
    
    }
        
        
        
}

 end of code **/

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to