This commit is contained in:
@@ -19,7 +19,7 @@ namespace Volian.Svg.Library
|
||||
set { _MyFillSettings.Fill = value; }
|
||||
}
|
||||
[XmlIgnore]
|
||||
protected Color FillColor
|
||||
public Color FillColor
|
||||
{
|
||||
get { return Svg.OverrideColor != System.Drawing.Color.Empty ? Svg.OverrideColor : _MyFillSettings.FillColor; }
|
||||
set { _MyFillSettings.FillColor = value; }
|
||||
|
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
//using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.pdf;
|
||||
@@ -10,7 +9,6 @@ using iTextSharp.text.factories;
|
||||
using Itenso.Rtf;
|
||||
using Itenso.Rtf.Parser;
|
||||
using Itenso.Rtf.Interpreter;
|
||||
//using Itenso.Rtf.Model;
|
||||
using Itenso.Rtf.Support;
|
||||
using Microsoft.Win32;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -73,9 +71,23 @@ namespace Volian.Svg.Library
|
||||
{
|
||||
get { return _MyText; }
|
||||
}
|
||||
public SvgProcessTextArgs(string myText)
|
||||
private SvgText _MySvgText;
|
||||
public SvgText MySvgText
|
||||
{
|
||||
get { return _MySvgText; }
|
||||
set { _MySvgText = value; }
|
||||
}
|
||||
private SvgScale _MySvgScale;
|
||||
public SvgScale MySvgScale
|
||||
{
|
||||
get { return _MySvgScale; }
|
||||
set { _MySvgScale = value; }
|
||||
}
|
||||
public SvgProcessTextArgs(string myText, SvgText mySvgText, SvgScale mySvgScale)
|
||||
{
|
||||
_MyText = myText;
|
||||
_MySvgText = mySvgText;
|
||||
_MySvgScale = mySvgScale;
|
||||
}
|
||||
}
|
||||
public partial class Svg : SvgGroup
|
||||
@@ -89,10 +101,10 @@ namespace Volian.Svg.Library
|
||||
macro.SvgParts.Draw(cb, MyScale.AdjustOrigin(X, Y), this,this);
|
||||
}
|
||||
public event SvgProcessTextEvent ProcessText;
|
||||
internal string OnProcessText(string myText)
|
||||
internal string OnProcessText(string myText, SvgText mySvgText, SvgScale scale)
|
||||
{
|
||||
if (ProcessText != null)
|
||||
return ProcessText(this, new SvgProcessTextArgs(myText));
|
||||
return ProcessText(this, new SvgProcessTextArgs(myText, mySvgText, scale));
|
||||
return myText;
|
||||
}
|
||||
private Dictionary<string, PdfTemplate> _Templates;
|
||||
@@ -102,7 +114,6 @@ namespace Volian.Svg.Library
|
||||
{
|
||||
PdfTemplate tmp = cb.CreateTemplate(100, 100);
|
||||
_Templates.Add(name, tmp);
|
||||
//tmp.BoundingBox = new iTextSharp.text.Rectangle(-200,-200,700,200);
|
||||
}
|
||||
return _Templates[name];
|
||||
}
|
||||
@@ -164,13 +175,11 @@ namespace Volian.Svg.Library
|
||||
RegisterFont(fontName);
|
||||
return FontFactory.GetFont(fontName);
|
||||
}
|
||||
//private void RegisterFonts()
|
||||
//{
|
||||
// //if (!FontFactory.IsRegistered("Arial"))
|
||||
// //{
|
||||
// // RegisterFont("Prestige Elite Tall");
|
||||
// //}
|
||||
//}
|
||||
public static iTextSharp.text.Font GetFont(string fontName, float size, int style, System.Drawing.Color color)
|
||||
{
|
||||
RegisterFont(fontName);
|
||||
return FontFactory.GetFont(fontName, size, style, new iTextSharp.text.Color(color));
|
||||
}
|
||||
public static void RegisterFont(string fontName)
|
||||
{
|
||||
if (!FontFactory.IsRegistered(fontName))
|
||||
@@ -378,12 +387,10 @@ namespace Volian.Svg.Library
|
||||
SetupInheritance(myParent.MyInheritedSettings);
|
||||
cb.SaveState();
|
||||
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(ImagePath);
|
||||
//Console.WriteLine("Before ScaledHeight = {0}", img.ScaledHeight);
|
||||
if (Height.Value != 0)
|
||||
img.ScaleAbsoluteHeight(scale.M(Height));
|
||||
if (Width.Value != 0)
|
||||
img.ScaleAbsoluteWidth(scale.M(Width));
|
||||
//Console.WriteLine("After ScaledHeight = {0}", img.ScaledHeight);
|
||||
img.SetAbsolutePosition(scale.X(X), scale.Y(cb, Y) - scale.M(img.ScaledHeight));
|
||||
cb.AddImage(img);
|
||||
cb.RestoreState();
|
||||
@@ -408,14 +415,12 @@ namespace Volian.Svg.Library
|
||||
bool stroke = LineColor != System.Drawing.Color.Empty;
|
||||
if (stroke)
|
||||
{
|
||||
//cb.SetLineWidth(scale.M(LineWidth));
|
||||
cb.SetLineWidth(LineWidth.Value);
|
||||
cb.SetColorStroke(new Color(LineColor));
|
||||
}
|
||||
cb.SetLineCap(PdfContentByte.LINE_CAP_ROUND);
|
||||
cb.MoveTo(scale.X(X1), scale.Y(cb, Y1));
|
||||
cb.LineTo(scale.X(X2), scale.Y(cb, Y2));
|
||||
//Console.WriteLine("'CB Line',{0},{1},{2},{3},{4}", scale.X(X1), scale.Y(cb, Y1), scale.X(X2), scale.Y(cb, Y2), scale.M(LineWidth));
|
||||
cb.Stroke();
|
||||
cb.RestoreState();
|
||||
}
|
||||
@@ -431,7 +436,6 @@ namespace Volian.Svg.Library
|
||||
}
|
||||
tmp.MoveTo(scale.X(X1), scale.Y(Y1));
|
||||
tmp.LineTo(scale.X(X2), scale.Y(Y2));
|
||||
//Console.WriteLine("'Template Line',{0},{1},{2},{3},{4}", scale.X(X1), scale.Y(tmp, Y1), scale.X(X2), scale.Y(tmp, Y2), scale.M(LineWidth));
|
||||
tmp.Stroke();
|
||||
tmp.RestoreState();
|
||||
Svg.FixBoundingBox(tmp, scale.X(X1), scale.Y(Y1), scale.X(X2), scale.Y(Y2));
|
||||
@@ -483,90 +487,43 @@ namespace Volian.Svg.Library
|
||||
tmp.SetLineWidth(scale.M(OutlineWidth));
|
||||
tmp.SetColorStroke(new Color(OutlineColor));
|
||||
}
|
||||
//tmp.Rectangle(scale.X(X), scale.Y(Y), scale.M(Width), -scale.M(Height));
|
||||
tmp.Rectangle(scale.X(X), scale.Y(Y), scale.M(Width), -scale.M(Height));
|
||||
SvgITextLibrary.StrokeAndFill(tmp, stroke, fill);
|
||||
Svg.FixBoundingBox(tmp, scale.X(X), scale.Y(Y), scale.X(X) + scale.M(Width), scale.Y(Y) - scale.M(Height));
|
||||
tmp.RestoreState();
|
||||
}
|
||||
}
|
||||
//public partial class SvgRtf : SvgShapePart
|
||||
//{
|
||||
// public override void Draw(PdfContentByte cb, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
|
||||
// {
|
||||
// ColumnText ct = new ColumnText(cb);
|
||||
// IRtfDocument myRtf = RtfInterpreterTool.BuildDoc(Rtf);
|
||||
// Rtf2iTextSharp rtf = new Rtf2iTextSharp(myRtf);
|
||||
// Paragraph p = rtf.Convert();
|
||||
// p.SetLeading(0, 1);
|
||||
// float leading = 10;
|
||||
// ct.SetSimpleColumn(scale.X(X), scale.Y(cb, Y) + leading, scale.X(X) + scale.M(Width), scale.Y(cb, Y) - cb.PdfDocument.PageSize.Height);
|
||||
// ct.AddElement(p);
|
||||
// ct.Go();
|
||||
// }
|
||||
// public override void Draw(PdfTemplate tmp, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
|
||||
// {
|
||||
// ColumnText ct = new ColumnText(tmp);
|
||||
// IRtfDocument myRtf = RtfInterpreterTool.BuildDoc(Rtf);
|
||||
// Rtf2iTextSharp rtf = new Rtf2iTextSharp(myRtf);
|
||||
// Paragraph p = rtf.Convert();
|
||||
// p.SetLeading(0, 1);
|
||||
// float leading = 10;
|
||||
// ct.SetSimpleColumn(scale.X(X), scale.Y(Y) + leading, scale.X(X) + scale.M(Width), scale.Y(Y) - tmp.PdfDocument.PageSize.Height);
|
||||
// ct.AddElement(p);
|
||||
// ct.Go();
|
||||
// }
|
||||
//}
|
||||
public partial class SvgText : SvgShapePart
|
||||
{
|
||||
public int Align
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Justify)
|
||||
{
|
||||
case SvgJustify.Left:
|
||||
return Element.ALIGN_LEFT;
|
||||
break;
|
||||
case SvgJustify.Center:
|
||||
return Element.ALIGN_CENTER;
|
||||
break;
|
||||
case SvgJustify.Right:
|
||||
return Element.ALIGN_RIGHT;
|
||||
break;
|
||||
}
|
||||
return Element.ALIGN_LEFT;
|
||||
}
|
||||
}
|
||||
public override void Draw(PdfContentByte cb, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
|
||||
{
|
||||
string text = mySvg.OnProcessText(Text);
|
||||
string text = mySvg.OnProcessText(Text, this, scale);
|
||||
if (text == string.Empty) return;
|
||||
SetupInheritance(myParent.MyInheritedSettings);
|
||||
float yScale = scale.Y(cb, Y);
|
||||
cb.SaveState();
|
||||
bool fill = FillColor != System.Drawing.Color.Transparent;
|
||||
bool stroke = OutlineWidth.Value != 0F && OutlineColor != System.Drawing.Color.Empty;
|
||||
//cb.MoveTo(0, scale.Y(cb, Y));
|
||||
//cb.LineTo(500, scale.Y(cb, Y));
|
||||
//cb.SetColorStroke(Color.BLUE);
|
||||
//cb.Stroke();
|
||||
//cb.BeginText();
|
||||
/*
|
||||
if (fill)
|
||||
cb.SetColorFill(new Color(FillColor));
|
||||
if (stroke)
|
||||
{
|
||||
cb.SetLineWidth(scale.M(OutlineWidth));
|
||||
cb.SetColorStroke(new Color(OutlineColor));
|
||||
}
|
||||
cb.SetColorFill(Color.RED);
|
||||
*/
|
||||
//iTextSharp.text.pdf.ColumnText ct = new ColumnText(cb);
|
||||
iTextSharp.text.Font font = FontFactory.GetFont(Font.Name, scale.M(new SvgMeasurement(Font.SizeInPoints, E_MeasurementUnits.PT)));
|
||||
//BaseFont baseFont = font.BaseFont;
|
||||
//cb.MoveText(scale.X(X), yScale);
|
||||
//cb.SetFontAndSize(baseFont, Font.SizeInPoints);
|
||||
//BaseFont baseFont = BaseFont.CreateFont("Helvetica", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
|
||||
//cb.SetFontAndSize(baseFont, scale.M(new SvgMeasurement(Font.SizeInPoints, E_MeasurementUnits.PT)));
|
||||
//Console.WriteLine("\"FontSize\",{0},{1}", Font.SizeInPoints, scale.M(new SvgMeasurement(Font.SizeInPoints, E_MeasurementUnits.PT)));
|
||||
/*
|
||||
switch ((stroke ? 1 : 0) + (fill ? 2 : 0))
|
||||
{
|
||||
case 0: // No Stroke or Fill
|
||||
cb.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_INVISIBLE);
|
||||
break;
|
||||
case 1: // Stroke
|
||||
cb.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_STROKE);
|
||||
break;
|
||||
case 2: // Fill
|
||||
cb.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL);
|
||||
break;
|
||||
case 3: // Stroke and Fill
|
||||
cb.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
ColumnText ct = new ColumnText(cb);
|
||||
Chunk chk = new Chunk(text, font);
|
||||
float x = scale.X(X);
|
||||
@@ -575,55 +532,38 @@ namespace Volian.Svg.Library
|
||||
{
|
||||
//case SvgJustify.Left:
|
||||
//x=x;
|
||||
//cb.ShowTextAlignedKerned(PdfContentByte.ALIGN_LEFT, Text, scale.X(X), yScale, 0F);
|
||||
//break;
|
||||
case SvgJustify.Center:
|
||||
x-=w/2;
|
||||
//cb.ShowTextAlignedKerned(PdfContentByte.ALIGN_CENTER, Text, scale.X(X), yScale, 0F);
|
||||
break;
|
||||
case SvgJustify.Right:
|
||||
x-=w;
|
||||
//cb.ShowTextAlignedKerned(PdfContentByte.ALIGN_RIGHT, Text, scale.X(X), yScale, 0F);
|
||||
break;
|
||||
}
|
||||
float y = yScale;
|
||||
float xRight = x + w;
|
||||
//float adjustForUnderline = Font.Underline ? Font.Size * .047F / 2 : 0;
|
||||
//float adjustForDescender = font.BaseFont.GetDescentPoint("Almg", font.Size);
|
||||
//float width = font.BaseFont.GetWidthPoint(Text, font.Size);
|
||||
//x -= isCentered ? width / 2 : 0;
|
||||
//xRight = x + font.BaseFont.GetWidthPoint(Text, font.Size) + adjustForUnderline;
|
||||
|
||||
float Offset = 0;
|
||||
if (Font.Underline)
|
||||
{
|
||||
chk.SetUnderline(new Color(FillColor), 0, 0.047F, 0, -.1373F, PdfContentByte.LINE_CAP_ROUND);
|
||||
}
|
||||
Phrase ph = new Phrase(chk);
|
||||
//Paragraph ph = new Paragraph(chk);
|
||||
ct.SetSimpleColumn(x, y + ph.Leading + Offset, xRight + 1F, y + ph.Leading + Offset - 2 * font.Size);
|
||||
ct.AddElement(ph);
|
||||
cb.SaveState();
|
||||
cb.SetColorFill(new Color(FillColor));
|
||||
ct.Go();
|
||||
cb.RestoreState();
|
||||
//Console.WriteLine("'{0}',{1},{2},{3},{4}", Text, scale.X(X), yScale, X, Y);
|
||||
//cb.ShowTextKerned(Text);
|
||||
//cb.EndText();
|
||||
//cb.RestoreState();
|
||||
}
|
||||
public override void Draw(PdfTemplate tmp, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
|
||||
{
|
||||
string text = mySvg.OnProcessText(Text);
|
||||
string text = mySvg.OnProcessText(Text, this, scale);
|
||||
if (text == string.Empty) return;
|
||||
SetupInheritance(myParent.MyInheritedSettings);
|
||||
float yScale = -scale.Y(Y);
|
||||
tmp.SaveState();
|
||||
bool fill = FillColor != System.Drawing.Color.Transparent;
|
||||
bool stroke = OutlineWidth.Value != 0F && OutlineColor != System.Drawing.Color.Empty;
|
||||
//cb.MoveTo(0, scale.Y(cb, Y));
|
||||
//cb.LineTo(500, scale.Y(cb, Y));
|
||||
//cb.SetColorStroke(Color.BLUE);
|
||||
//cb.Stroke();
|
||||
tmp.BeginText();
|
||||
if (fill)
|
||||
tmp.SetColorFill(new Color(FillColor));
|
||||
@@ -632,15 +572,10 @@ namespace Volian.Svg.Library
|
||||
tmp.SetLineWidth(scale.M(OutlineWidth));
|
||||
tmp.SetColorStroke(new Color(OutlineColor));
|
||||
}
|
||||
//iTextSharp.text.pdf.ColumnText ct = new ColumnText(cb);
|
||||
//Console.WriteLine("Font['{0}'].IsRegistered = {1}",Font.Name,FontFactory.IsRegistered(Font.Name));
|
||||
iTextSharp.text.Font font = Svg.GetFont(Font.Name);
|
||||
BaseFont baseFont = font.BaseFont;
|
||||
tmp.MoveText(scale.X(X), yScale);
|
||||
//cb.SetFontAndSize(baseFont, Font.SizeInPoints);
|
||||
//BaseFont baseFont = BaseFont.CreateFont("Helvetica", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
|
||||
tmp.SetFontAndSize(baseFont, scale.M(new SvgMeasurement(Font.SizeInPoints, E_MeasurementUnits.PT)));
|
||||
//Console.WriteLine("\"FontSize\",{0},{1}", Font.SizeInPoints, scale.M(new SvgMeasurement(Font.SizeInPoints, E_MeasurementUnits.PT)));
|
||||
switch ((stroke ? 1 : 0) + (fill ? 2 : 0))
|
||||
{
|
||||
case 0: // No Stroke or Fill
|
||||
@@ -661,148 +596,6 @@ namespace Volian.Svg.Library
|
||||
tmp.RestoreState();
|
||||
}
|
||||
}
|
||||
//public class Rtf2iTextSharp : RtfVisualVisitorBase
|
||||
//{
|
||||
// private IRtfDocument _RtfDoc;
|
||||
// private Paragraph _MyParagraph = new Paragraph();
|
||||
// // public Rtf2iTextSharp(IRtfDocument rtfDoc, Document doc, PdfWriter writer)
|
||||
// public Rtf2iTextSharp(IRtfDocument rtfDoc)
|
||||
// {
|
||||
// if (rtfDoc == null)
|
||||
// throw new ArgumentNullException("rtfDoc");
|
||||
// _RtfDoc = rtfDoc;
|
||||
// }
|
||||
// public Paragraph Convert()
|
||||
// {
|
||||
// _MyParagraph.Clear();
|
||||
// foreach (IRtfVisual visual in _RtfDoc.VisualContent)
|
||||
// visual.Visit(this);
|
||||
// //_MyParagraph.SetLeading(0, 1);
|
||||
// return _MyParagraph;
|
||||
// }
|
||||
// // ----------------------------------------------------------------------
|
||||
// protected override void DoVisitBreak(IRtfVisualBreak visualBreak)
|
||||
// {
|
||||
// switch (visualBreak.BreakKind)
|
||||
// {
|
||||
// case RtfVisualBreakKind.Line:
|
||||
// break;
|
||||
// case RtfVisualBreakKind.Page:
|
||||
// break;
|
||||
// case RtfVisualBreakKind.Paragraph:
|
||||
// //_MyParagraph.Add("\r\n");
|
||||
// break;
|
||||
// case RtfVisualBreakKind.Section:
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// //_MyParagraph.Add(string.Format("<{0}>", visualBreak.BreakKind.ToString()));
|
||||
// }
|
||||
// protected override void DoVisitSpecial(IRtfVisualSpecialChar visualSpecialChar)
|
||||
// {
|
||||
// //_MyParagraph.Add(string.Format("<special {0}>", visualSpecialChar.CharKind.ToString()));
|
||||
// switch (visualSpecialChar.CharKind)
|
||||
// {
|
||||
// case RtfVisualSpecialCharKind.Bullet:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.EmDash:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.EmSpace:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.EnDash:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.EnSpace:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.LeftDoubleQuote:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.LeftSingleQuote:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.NonBreakingHyphen:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.NonBreakingSpace:
|
||||
// _MyParagraph.Add(new Chunk("\u00A0"));
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.OptionalHyphen:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.ParagraphNumberBegin:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.ParagraphNumberEnd:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.QmSpace:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.RightDoubleQuote:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.RightSingleQuote:
|
||||
// break;
|
||||
// case RtfVisualSpecialCharKind.Tabulator:
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// //private static Dictionary<string, BaseFont> _MyBaseFonts = new Dictionary<string, BaseFont>();
|
||||
// //private static BaseFont GetBaseFont(string fontName)
|
||||
// //{
|
||||
// // if (!_MyBaseFonts.ContainsKey(fontName))
|
||||
// // _MyBaseFonts.Add(fontName, BaseFont.CreateFont(FontFind.FullFileName(fontName), BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
|
||||
// // return _MyBaseFonts[fontName];
|
||||
// //}
|
||||
// //private static Dictionary<string, iTextSharp.text.Font> _MyFonts = new Dictionary<string, iTextSharp.text.Font>();
|
||||
// //private static iTextSharp.text.Font GetFont(string fontName, int size, int style)
|
||||
// //{
|
||||
// // string key = string.Format("{0}.{1}.{2}", fontName, size, style);
|
||||
// // if (!_MyFonts.ContainsKey(key))
|
||||
// // _MyFonts.Add(key, new iTextSharp.text.Font(GetBaseFont(fontName), size / 2, style));
|
||||
// // return _MyFonts[key];
|
||||
// //}
|
||||
// //protected override void DoVisitText(IRtfVisualText visualText)
|
||||
// //{
|
||||
// // if (visualText.Format.IsHidden) return;
|
||||
// // //iTextSharp.text.Font font = GetFont(visualText.Format.Font.Name, visualText.Format.FontSize,
|
||||
// // // (visualText.Format.IsBold ? iTextSharp.text.Font.BOLD : 0) + (visualText.Format.IsItalic ? iTextSharp.text.Font.ITALIC : 0));
|
||||
// // iTextSharp.text.Font font = FontFactory.GetFont(visualText.Format.Font.Name, BaseFont.IDENTITY_H, BaseFont.EMBEDDED,
|
||||
// // visualText.Format.FontSize / 2F);// TODO: Don't know why this is 2.4 rather than 2.
|
||||
|
||||
// // font.SetStyle((visualText.Format.IsBold ? iTextSharp.text.Font.BOLD : 0) + (visualText.Format.IsItalic ? iTextSharp.text.Font.ITALIC : 0));
|
||||
// // font.Color = new iTextSharp.text.Color(visualText.Format.ForegroundColor.AsDrawingColor);
|
||||
// // Chunk chk = new Chunk(visualText.Text, font);
|
||||
// // chk.SetBackground(new iTextSharp.text.Color(visualText.Format.BackgroundColor.AsDrawingColor));
|
||||
// // if (visualText.Format.IsStrikeThrough)
|
||||
// // chk.SetUnderline(iTextSharp.text.Color.BLACK, 0, 0.05F, 0, .3F, PdfContentByte.LINE_CAP_ROUND); // Relative Based upon font size
|
||||
// // if (visualText.Format.IsUnderline)
|
||||
// // chk.SetUnderline(iTextSharp.text.Color.BLACK, 0, 0.05F, 0, -.09F, PdfContentByte.LINE_CAP_ROUND); // Relative Based upon font size
|
||||
// // if (visualText.Format.SuperScript == -1)
|
||||
// // chk.SetTextRise(.45F * chk.Font.Size);
|
||||
// // else if (visualText.Format.SuperScript == 1)
|
||||
// // chk.SetTextRise(-.25F * chk.Font.Size);
|
||||
// // //Console.WriteLine("\"RTF FontSize\",{0},{1}", visualText.Format.FontSize / 2,chk.Font.Size);
|
||||
|
||||
// // _MyParagraph.Add(chk);
|
||||
|
||||
// //}// DoVisitText
|
||||
|
||||
// // ----------------------------------------------------------------------
|
||||
// protected override void DoVisitImage(IRtfVisualImage visualImage)
|
||||
// {
|
||||
// _MyParagraph.Add(new Chunk("<Image>"));
|
||||
// //WriteStartElement("rtfVisualImage");
|
||||
|
||||
// //WriteElementString("format", visualImage.Format.ToString());
|
||||
// //WriteElementString("width", visualImage.Width.ToString());
|
||||
// //WriteElementString("height", visualImage.Height.ToString());
|
||||
// //WriteElementString("desiredWidth", visualImage.DesiredWidth.ToString());
|
||||
// //WriteElementString("desiredHeight", visualImage.DesiredHeight.ToString());
|
||||
// //WriteElementString("scaleWidthPercent", visualImage.ScaleWidthPercent.ToString());
|
||||
// //WriteElementString("scaleHeightPercent", visualImage.ScaleHeightPercent.ToString());
|
||||
// //WriteElementString("alignment", visualImage.Alignment.ToString());
|
||||
|
||||
// //WriteElementString("image", visualImage.ImageDataHex.ToString());
|
||||
|
||||
// //WriteEndElement();
|
||||
// } // DoVisitImage
|
||||
|
||||
//}
|
||||
public class SvgPageTotal
|
||||
{
|
||||
public SvgPageTotal(System.Drawing.Font myFont, PdfContentByte cb)
|
||||
@@ -812,17 +605,7 @@ namespace Volian.Svg.Library
|
||||
_MyTemplate.BoundingBox= new Rectangle(-20, -20, 100, 100);
|
||||
}
|
||||
private int _PageCount=1;
|
||||
//public int PageCount
|
||||
//{
|
||||
// get { return _PageCount; }
|
||||
// set { _PageCount = value; }
|
||||
//}
|
||||
private System.Drawing.Font _MyFont;
|
||||
//public System.Drawing.Font MyFont
|
||||
//{
|
||||
// get { return _MyFont; }
|
||||
// set { _MyFont = value; }
|
||||
//}
|
||||
private PdfTemplate _MyTemplate;
|
||||
public PdfTemplate MyTemplate
|
||||
{
|
||||
@@ -843,11 +626,8 @@ namespace Volian.Svg.Library
|
||||
public class SvgPageHelper : PdfPageEventHelper
|
||||
{
|
||||
private Svg _MySvg;
|
||||
//private Svg _MyNextSvg;
|
||||
public Svg MySvg
|
||||
{
|
||||
//get { return _MyNextSvg; }
|
||||
//set { _MyNextSvg = value; }
|
||||
get { return _MySvg; }
|
||||
set { _MySvg = value; }
|
||||
}
|
||||
@@ -877,7 +657,6 @@ namespace Volian.Svg.Library
|
||||
}
|
||||
public SvgPageHelper(Svg mySvg)
|
||||
{
|
||||
//_MySvg = _MyNextSvg = mySvg;
|
||||
_MySvg = mySvg;
|
||||
}
|
||||
public SvgPageHelper()
|
||||
@@ -889,7 +668,6 @@ namespace Volian.Svg.Library
|
||||
get { return _BGPageOffset; }
|
||||
set { _BGPageOffset = value; }
|
||||
}
|
||||
//private Regex regexReplaceTokens = new Regex(@"{[^{}]}");
|
||||
protected virtual string ReplacePageListToken(Match match)
|
||||
{
|
||||
return string.Empty;
|
||||
@@ -946,7 +724,7 @@ namespace Volian.Svg.Library
|
||||
private PdfImportedPage GetBackgroundPage(PdfContentByte cb)
|
||||
{
|
||||
if (BackgroundReader == null) return null;
|
||||
int page = CurrentPageNumber + BackgroundPageOffset;
|
||||
int page = cb.PdfWriter.CurrentPageNumber + BackgroundPageOffset;
|
||||
if (page < 1 || page > BackgroundPageCount) return null;
|
||||
return cb.PdfWriter.GetImportedPage(BackgroundReader, page);
|
||||
}
|
||||
@@ -979,13 +757,15 @@ namespace Volian.Svg.Library
|
||||
}
|
||||
private void DrawPageList(PdfContentByte cb)
|
||||
{
|
||||
cb.SaveState();
|
||||
if (_PageListLayer != null) cb.BeginLayer(_PageListLayer);
|
||||
// Do anything needed to finish off the page
|
||||
_MySvg.Draw(cb);
|
||||
//_MySvg = _MyNextSvg; // After doing to current page update the Svg for the next page.
|
||||
if (_PageListLayer != null) cb.EndLayer();
|
||||
cb.RestoreState();
|
||||
if (_MySvg != null)
|
||||
{
|
||||
cb.SaveState();
|
||||
if (_PageListLayer != null) cb.BeginLayer(_PageListLayer);
|
||||
// Do anything needed to finish off the page
|
||||
_MySvg.Draw(cb);
|
||||
if (_PageListLayer != null) cb.EndLayer();
|
||||
cb.RestoreState();
|
||||
}
|
||||
}
|
||||
private void ZoomOMatic(PdfContentByte cb, float size)
|
||||
{
|
||||
@@ -998,21 +778,6 @@ namespace Volian.Svg.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//private void DrawRectangle(PdfContentByte cb, float x, float y, float w, float h, Color fill, Color stroke)
|
||||
//{
|
||||
// cb.SaveState();
|
||||
// PdfGState gState = new PdfGState();
|
||||
// gState.StrokeOpacity = .95F;
|
||||
// gState.FillOpacity = .75F;
|
||||
// cb.SetGState(gState);
|
||||
// cb.SetColorFill(fill);
|
||||
// cb.SetLineWidth(1F);
|
||||
// cb.SetColorStroke(stroke);
|
||||
// cb.Rectangle(x, cb.PdfWriter.PageSize.Height - y, w, -h);
|
||||
// cb.FillStroke();
|
||||
// cb.RestoreState();
|
||||
//}
|
||||
public override void OnStartPage(PdfWriter writer, Document document)
|
||||
{
|
||||
//base.OnStartPage(writer, document);
|
||||
@@ -1136,8 +901,6 @@ namespace Volian.Svg.Library
|
||||
_ContentByte.SaveState();
|
||||
_ContentByte.BeginText();
|
||||
_ContentByte.SetPatternFill(_PatternPainter);
|
||||
//_ContentByte.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL);
|
||||
//_ContentByte.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_STROKE);
|
||||
_ContentByte.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE);
|
||||
_ContentByte.SetLineWidth(.5F);
|
||||
_ContentByte.SetFontAndSize(_Basefont, _Fontsize);// Set font and size
|
||||
|
Reference in New Issue
Block a user