This commit is contained in:
Peter Tribe 2019-03-05 12:25:28 -08:00
Родитель 9a6a1480ec
Коммит a893098592
2 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -7,7 +7,7 @@ namespace EquinoxLabs.SVGSharpie.DynamicPDF
public static class Renderer
{
public static PageElement CreateSvgImagePageElement(SvgDocument document, Rectangle bounds, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, PdfSpotColor spotColorInk)
public static PageElement CreateSvgImagePageElement(SvgDocument document, Rectangle bounds, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, PdfSpotColor spotColorOverride)
{
var svg = document.RootElement;
var boundsWidth = (float)bounds.Width;
@ -29,7 +29,7 @@ namespace EquinoxLabs.SVGSharpie.DynamicPDF
}
var svgElement = new SvgPageElement(document, bounds, horizontalAlignment, verticalAlignment);
svgElement.SpotColorOveride = spotColorInk;
svgElement.SpotColorOveride = spotColorOverride;
var shouldClip = horizontalAlignment == HorizontalAlignment.Stretch || verticalAlignment == VerticalAlignment.Stretch;
return shouldClip ? (PageElement)new ClippingGroup(bounds, svgElement) : svgElement;
}

Просмотреть файл

@ -14,21 +14,21 @@ namespace EquinoxLabs.SVGSharpie.DynamicPDF.Tests
[Fact]
public void QuickTest()
{
var svgFilePath = System.IO.Path.Combine(Utils.TestFolder, "Test", "Tiger.svg");
Debug.WriteLine($"Testing QuickTest: {System.IO.Path.GetFileName(svgFilePath)} in {System.IO.Path.GetDirectoryName(svgFilePath)}");
var svgFilePath = Path.Combine(Utils.TestFolder, "Test", "Tiger.svg");
Debug.WriteLine($"Testing QuickTest: {Path.GetFileName(svgFilePath)} in {Path.GetDirectoryName(svgFilePath)}");
Document document = new Document
{
Creator = "PNI",
Author = "PNI"
};
var spotColorInk = new PdfSpotColorInk("MyCol", new ceTe.DynamicPDF.CmykColor(0, 255, 0, 0));
var spotColorInk = new PdfSpotColorInk("MyCol", new CmykColor(0, 255, 0, 0));
var spotColor = new PdfSpotColor(1, spotColorInk);
Page page = new Page( PageSize.Letter, PageOrientation.Portrait, 54.0f );
var svgDocument = SvgDocument.Parse(File.ReadAllText(svgFilePath));
var pageElement = Renderer.CreateSvgImagePageElement(svgDocument, new Rectangle(0, 0, 300, 300), HorizontalAlignment.Center, VerticalAlignment.Center, spotColor);
page.Elements.Add(pageElement);
document.Pages.Add(page);
document.Draw(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(svgFilePath), System.IO.Path.GetFileNameWithoutExtension(svgFilePath) + ".pdf"));
document.Draw(Path.Combine(Path.GetDirectoryName(svgFilePath), Path.GetFileNameWithoutExtension(svgFilePath) + ".pdf"));
}
}
}