Print Library, Svg Library, Utils Library, XYPlots
This commit is contained in:
@@ -1,46 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.pdf;
|
||||
using System.IO;
|
||||
using Microsoft.Win32;
|
||||
using Volian.Base.Library;
|
||||
|
||||
namespace Volian.Print.Library
|
||||
{
|
||||
public class pdf
|
||||
{
|
||||
private Document _MyDocument;
|
||||
public Document MyDocument
|
||||
public Document MyDocument { get; set; }
|
||||
public PdfWriter MyWriter { get; set; }
|
||||
public string MyFileName { get; set; }
|
||||
public PdfContentByte ContentByte => MyWriter.DirectContent;
|
||||
public pdf(string myFileName)
|
||||
{
|
||||
get { return _MyDocument; }
|
||||
set { _MyDocument = value; }
|
||||
}
|
||||
private PdfWriter _MyWriter;
|
||||
public PdfWriter MyWriter
|
||||
{
|
||||
get { return _MyWriter; }
|
||||
set { _MyWriter = value; }
|
||||
}
|
||||
private string _MyFileName;
|
||||
public string MyFileName
|
||||
{
|
||||
get { return _MyFileName; }
|
||||
set { _MyFileName = value; }
|
||||
}
|
||||
public PdfContentByte ContentByte
|
||||
{
|
||||
get { return _MyWriter.DirectContent; }
|
||||
}
|
||||
public pdf(string myFileName)
|
||||
{
|
||||
_MyFileName = myFileName;
|
||||
_MyDocument = new Document(PageSize.LETTER);
|
||||
MyFileName = myFileName;
|
||||
MyDocument = new Document(PageSize.LETTER);
|
||||
try
|
||||
{
|
||||
_MyWriter = PdfWriter.GetInstance(_MyDocument, new FileStream(myFileName, FileMode.Create));
|
||||
_MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7);
|
||||
MyWriter = PdfWriter.GetInstance(MyDocument, new FileStream(myFileName, FileMode.Create));
|
||||
MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -49,24 +29,21 @@ namespace Volian.Print.Library
|
||||
}
|
||||
public pdf(string myFileName, Rectangle mySize)
|
||||
{
|
||||
_MyFileName = myFileName;
|
||||
_MyDocument = new Document(mySize);
|
||||
MyFileName = myFileName;
|
||||
MyDocument = new Document(mySize);
|
||||
try
|
||||
{
|
||||
_MyWriter = PdfWriter.GetInstance(_MyDocument, new FileStream(myFileName, FileMode.Create));
|
||||
_MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7);
|
||||
MyWriter = PdfWriter.GetInstance(MyDocument, new FileStream(myFileName, FileMode.Create));
|
||||
MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("{0} - {1}\r\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
|
||||
}
|
||||
}
|
||||
public void Close()
|
||||
{
|
||||
MyDocument.Close();
|
||||
}
|
||||
private Color _WatermarkColor = Color.BLUE;
|
||||
private float _WatermarkOpacity = .10F;
|
||||
public void Close() => MyDocument.Close();
|
||||
private readonly Color _WatermarkColor = Color.BLUE;
|
||||
private readonly float _WatermarkOpacity = .10F;
|
||||
public void WatermarkPageNumber(int pageNumber)
|
||||
{
|
||||
Rectangle pageSize = ContentByte.PdfWriter.PageSize; // Get page size
|
||||
@@ -84,9 +61,11 @@ namespace Volian.Print.Library
|
||||
ContentByte.SetLineWidth(.5F);
|
||||
ContentByte.SetFontAndSize(myBasefont, myFontSize);// Set font and size
|
||||
ContentByte.SetColorStroke(_WatermarkColor);
|
||||
PdfGState gs2 = new PdfGState();
|
||||
gs2.StrokeOpacity = _WatermarkOpacity;
|
||||
ContentByte.SetGState(gs2);
|
||||
PdfGState gs2 = new PdfGState
|
||||
{
|
||||
StrokeOpacity = _WatermarkOpacity
|
||||
};
|
||||
ContentByte.SetGState(gs2);
|
||||
ContentByte.ShowTextAlignedKerned(PdfContentByte.ALIGN_CENTER, strPage, pageSize.Width / 2, 0, 0);// Draw the text
|
||||
ContentByte.EndText();
|
||||
ContentByte.FillStroke(); // Controlled by TextRenderMode above
|
||||
@@ -108,9 +87,11 @@ namespace Volian.Print.Library
|
||||
{
|
||||
PdfPatternPainter myPatternPainter;
|
||||
myPatternPainter = ContentByte.CreatePattern(radius * 4, radius * 2, radius * 4, radius * 2);
|
||||
PdfGState gState = new PdfGState();
|
||||
gState.FillOpacity = _WatermarkOpacity;
|
||||
myPatternPainter.SetGState(gState);
|
||||
PdfGState gState = new PdfGState
|
||||
{
|
||||
FillOpacity = _WatermarkOpacity
|
||||
};
|
||||
myPatternPainter.SetGState(gState);
|
||||
myPatternPainter.SetColorFill(_WatermarkColor);
|
||||
myPatternPainter.Rectangle(0, 0, radius, radius);
|
||||
myPatternPainter.Rectangle(radius * 2, radius, radius, radius);
|
||||
|
||||
Reference in New Issue
Block a user