I am using ImageMagick dll in my ASP.NET MVC application. In our case we are getting SVG images from UI after that in the backend we are converting SVG to PDF in C# using ImageMagick. But some times I am getting black Bars. Any solution for this.
Code: Select all
public void SVGtoPDF(string svg, string pdf)
{
string text = System.IO.File.ReadAllText(svg);
byte[] bytes = Encoding.UTF8.GetBytes(text);
MagickReadSettings settings = new MagickReadSettings()
{
Density = new PointD(3000, 3000),
//ColorSpace= ColorSpace.RGB,
Format = MagickFormat.Svg
};
string pdfFileName = pdf;
using (MagickImage image = new MagickImage(bytes, settings))
{
MagickImage i = new MagickImage();
//image.ColorSpace = ColorSpace.RGB;
image.Format = MagickFormat.Pdf;
image.Density = new PointD(150, 150);
image.CompressionMethod = CompressionMethod.JPEG;
image.Resize(1240, 1753);
image.ResolutionUnits = Resolution.PixelsPerInch;
image.Write(pdfFileName);
}
}