This commit is contained in:
@@ -3,7 +3,7 @@ using System.Text;
|
||||
using System.Xml;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using C1.C1Pdf;
|
||||
//using C1.C1Pdf;
|
||||
|
||||
namespace fmtxml
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace fmtxml
|
||||
private XmlDocument xmlDoc;
|
||||
private string FileName;
|
||||
private string FilePath;
|
||||
private C1.C1Pdf.C1PdfDocument _c1pdf;
|
||||
//private C1.C1Pdf.C1PdfDocument _c1pdf;
|
||||
|
||||
private string [] FontChoice =
|
||||
{"Times New Roman",
|
||||
@@ -59,23 +59,23 @@ namespace fmtxml
|
||||
|
||||
private void GeneratePDFForFile()
|
||||
{
|
||||
_c1pdf = new C1.C1Pdf.C1PdfDocument();
|
||||
string rootname = FileName.Substring(0,FileName.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;
|
||||
XmlNodeList ndlist = topnode.SelectNodes("/g");
|
||||
for (int i=0;i<topnode.ChildNodes.Count;i++)
|
||||
{
|
||||
XmlNode nd = topnode.ChildNodes[i];
|
||||
if (nd.Name!="desc")
|
||||
{
|
||||
SvgConvertToPdf(nd);
|
||||
_c1pdf.NewPage();
|
||||
}
|
||||
}
|
||||
string outname = "E:\\proms.net\\genmac.xml\\testpdf\\" + rootname + ".pdf";
|
||||
_c1pdf.Save(outname);
|
||||
//_c1pdf = new C1.C1Pdf.C1PdfDocument();
|
||||
//string rootname = FileName.Substring(0,FileName.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;
|
||||
//XmlNodeList ndlist = topnode.SelectNodes("/g");
|
||||
//for (int i=0;i<topnode.ChildNodes.Count;i++)
|
||||
//{
|
||||
// XmlNode nd = topnode.ChildNodes[i];
|
||||
// if (nd.Name!="desc")
|
||||
// {
|
||||
// SvgConvertToPdf(nd);
|
||||
// _c1pdf.NewPage();
|
||||
// }
|
||||
//}
|
||||
//string outname = "E:\\proms.net\\genmac.xml\\testpdf\\" + rootname + ".pdf";
|
||||
//_c1pdf.Save(outname);
|
||||
}
|
||||
|
||||
private string AddRTFBUI(string origStr, string bold, string underline, string italics)
|
||||
@@ -121,7 +121,7 @@ namespace fmtxml
|
||||
pn = new Pen(Brushes.Black,flw);
|
||||
//KBR: TODO - storing page stuff such as portland, vertical offset, tab, etc.
|
||||
RectangleF rc = new RectangleF(LeftMargin+fstx,VerticalOffset+fsty,fex,fey);
|
||||
_c1pdf.DrawRectangle(pn,rc);
|
||||
//_c1pdf.DrawRectangle(pn,rc);
|
||||
break;
|
||||
case "line": // command is LINE startx, starty, endx, endy, lnwidth
|
||||
fstx = (float) System.Convert.ToDouble(cmdele.GetAttribute("x1"));
|
||||
@@ -136,7 +136,7 @@ namespace fmtxml
|
||||
//KBR: TODO - move ablsolute?
|
||||
// if (MoveAbsolute)
|
||||
// {tab = 0;vof = 0;}
|
||||
_c1pdf.DrawLine(pn, LeftMargin+fstx, VerticalOffset+fsty, LeftMargin+fex, VerticalOffset+fey);
|
||||
//_c1pdf.DrawLine(pn, LeftMargin+fstx, VerticalOffset+fsty, LeftMargin+fex, VerticalOffset+fey);
|
||||
break;
|
||||
case "text":
|
||||
fstx = (float) System.Convert.ToDouble(cmdele.GetAttribute("x"));
|
||||
@@ -147,12 +147,12 @@ namespace fmtxml
|
||||
string italics = cmdele.GetAttribute("font-style");
|
||||
Font myfont = new Font(cmdele.GetAttribute("font-family"),FontSize);
|
||||
rc = new Rectangle();
|
||||
rc.Size = _c1pdf.MeasureStringRtf(cmdele.InnerText,myfont,500); // kbr todo: 500?
|
||||
//rc.Size = _c1pdf.MeasureStringRtf(cmdele.InnerText,myfont,500); // kbr todo: 500?
|
||||
rc.X = LeftMargin+fstx;
|
||||
rc.Y = VerticalOffset+fsty-FontSize;
|
||||
// add bold, underline & italics for entire object.
|
||||
string rtfout = AddRTFBUI(cmdele.InnerText,bold,underline,italics);
|
||||
_c1pdf.DrawStringRtf(rtfout,myfont,Brushes.Black,rc);
|
||||
//_c1pdf.DrawStringRtf(rtfout,myfont,Brushes.Black,rc);
|
||||
break;
|
||||
case "gdiadj":
|
||||
break;
|
||||
@@ -163,7 +163,7 @@ namespace fmtxml
|
||||
fey = (float) System.Convert.ToDouble(cmdele.GetAttribute("ry"));
|
||||
flw = (float) System.Convert.ToDouble(cmdele.GetAttribute("stroke-width"));
|
||||
pn = new Pen(Brushes.Black,flw);
|
||||
_c1pdf.DrawEllipse(pn,LeftMargin+fstx, VerticalOffset+fsty, fex, fey);
|
||||
//_c1pdf.DrawEllipse(pn,LeftMargin+fstx, VerticalOffset+fsty, fex, fey);
|
||||
break;
|
||||
case "image":
|
||||
fstx = (float) System.Convert.ToDouble(cmdele.GetAttribute("x"));
|
||||
@@ -178,7 +178,7 @@ namespace fmtxml
|
||||
rc.Width = (((img.Width*scale)*4.8f)/1440f)*72f;
|
||||
rc.X = LeftMargin+fstx;
|
||||
rc.Y = VerticalOffset+fsty;
|
||||
_c1pdf.DrawImage(img, rc, ContentAlignment.MiddleCenter, ImageSizeModeEnum.Scale);
|
||||
//_c1pdf.DrawImage(img, rc, ContentAlignment.MiddleCenter, ImageSizeModeEnum.Scale);
|
||||
break;
|
||||
case "absolute":
|
||||
break;
|
||||
|
Reference in New Issue
Block a user