/*********************************************************************************************
* Copyright 2005 - Volian Enterprises, Inc. All rights reserved.
* Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
* ------------------------------------------------------------------------------
* $Workfile: Form1.cs $ $Revision: 1 $
* $Author: Kathy $ $Date: 12/06/05 12:06p $
*
* $History: Form1.cs $
*
* ***************** Version 1 *****************
* User: Kathy Date: 12/06/05 Time: 12:06p
* Created in $/LibSource/VG/Test
*
* ***************** Version 1 *****************
* User: Kathy Date: 12/06/05 Time: 12:01p
* Created in $/LibSource/VG.root/VG/Test
*********************************************************************************************/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.IO;
using VG;
using C1.C1Pdf;
namespace TestVG
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button2;
private int ConvertToTwips = 1440;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(24, 8);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(72, 32);
this.button1.TabIndex = 0;
this.button1.Text = "SVG To PDF";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// listBox1
//
this.listBox1.Location = new System.Drawing.Point(24, 72);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(584, 381);
this.listBox1.TabIndex = 1;
//
// button2
//
this.button2.Location = new System.Drawing.Point(544, 8);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(56, 32);
this.button2.TabIndex = 2;
this.button2.Text = "Exit";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(752, 494);
this.Controls.Add(this.button2);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
listBox1.Items.Clear();
DirectoryInfo di = new DirectoryInfo("E:\\proms.net\\genmac.xml");
FileInfo[] fis = di.GetFiles("*.svg");
foreach (FileInfo fi in fis)
{
this.listBox1.Items.Add(fi.Name);
//TestSvgToPdf("E:\\proms.net\\genmac.xml",fi.Name);
VG.Page pg = new Page(true, 0.5f * ConvertToTwips, 0.5f * ConvertToTwips);
XmlDocument xmldoc = new XmlDocument();
XmlTextReader reader = new XmlTextReader("E:\\proms.net\\genmac.xml\\"+fi.Name);
xmldoc.Load(reader);
reader.Close();
try
{
GeneratePDFForSVGFile(xmldoc, fi.Name, pg);
}
catch (Exception ex)
{
MessageBox.Show("Error processing: " + fi.Name, ex.Message);
}
}
MessageBox.Show("DONE generating PDF files from SVG");
}
private void GeneratePDFForSVGFile(XmlDocument xmldoc, string fname, VG.Page pg)
{
C1.C1Pdf.C1PdfDocument c1pdf = new C1.C1Pdf.C1PdfDocument();
string rootname = fname.Substring(0,fname.Length-4);
// create a pdf file with a page for each macro (i.e. macro element in xml tree),
// put it into the pdf file.
XmlNode topnode = xmldoc.LastChild;
for (int i=0;i