Update Text And Shape Color
View as MarkdownUpdates text and shape color of PSD image and saves to PDF file.
Code Snippet
var psdProcessor = new PsdProcessor();
var psName = psdProcessor.FontResolver.FontRegistry.Add("ARIALUNI.TTF")[0].PostscriptName;
psdProcessor.FontResolver.FontRegistry.FallbackFonts.Add(psName);
psdProcessor.TextCallback = (processor, textFrame, textString) =>
{
var text = processor.ProcessText(textFrame);
text.String = textString;
text.Brush = new SolidBrush(RgbColor.DarkRed);
return text;
};
psdProcessor.FrameCallback = (processor, frame) =>
{
if (frame.Type != FrameType.Shape)
{
return processor.ProcessFrame(frame);
}
var shapeFrame = (PsdShapeFrame)frame;
var graphicsContainer = new GraphicsContainer(frame.X + frame.Width, frame.Y + frame.Height, frame.DpiX, frame.DpiY);
using (var graphics = graphicsContainer.GetGraphics())
{
graphics.FillPath(new SolidBrush(RgbColor.DarkGreen), shapeFrame.VectorMask);
}
return graphicsContainer;
};
psdProcessor.Render("Seal.psd", "UpdateTextAndShapeColor.pdf");
Input
Seal.psd
DownloadOutput
UpdateTextAndShapeColor.pdf
DownloadUpdateTextAndShapeColor.png
Used APIs
- Aurigma.GraphicsMill.Codecs.Frame.DpiX
- Aurigma.GraphicsMill.Codecs.Frame.DpiY
- Aurigma.GraphicsMill.Codecs.Psd.FrameType
- Aurigma.GraphicsMill.Codecs.Psd.PsdFrame.Type
- Aurigma.GraphicsMill.Codecs.Psd.PsdFrame.VectorMask
- Aurigma.GraphicsMill.Codecs.Psd.PsdFrame.X
- Aurigma.GraphicsMill.Codecs.Psd.PsdFrame.Y
- Aurigma.GraphicsMill.Codecs.Psd.PsdShapeFrame
- Aurigma.GraphicsMill.Drawing.CustomFontRegistry.Add(String)
- Aurigma.GraphicsMill.Drawing.FontAddResult.PostscriptName
- Aurigma.GraphicsMill.Drawing.FontRegistry.FallbackFonts
- Aurigma.GraphicsMill.Drawing.Graphics.FillPath(Brush,Path)
- Aurigma.GraphicsMill.Drawing.GraphicsContainer
- Aurigma.GraphicsMill.Drawing.GraphicsContainer.GetGraphics
- Aurigma.GraphicsMill.Drawing.SolidBrush
- Aurigma.GraphicsMill.Drawing.Text.Brush
- Aurigma.GraphicsMill.Drawing.Text.String
- Aurigma.GraphicsMill.Templates.FontResolver.FontRegistry
- Aurigma.GraphicsMill.Templates.PsdProcessor