How to print SVG file with .NET

2019-08-14 07:03发布

I understand this is probably a dumb question to ask but i am stuck.

I have one SVG file. The file contains one design which i would like to plot using Graphtec FC8600 plotter.

I have plotter installed on my windows machine.

I am designing one windows form application which will plot the selected SVG file using graphtec plotter.

My initial understanding says, i can do plotting similar to printing. When i try to plot the SVG file using printDocument, the plotter receives the command but plots the SVG unrendered content, not the actual image.

I think i am missing something important here. I have already gone through available resources on google and SO.

Any help would be appreciated.

1条回答
\"骚年 ilove
2楼-- · 2019-08-14 07:09

You can use a WebBrowser control to print your svg file.

You can use Navigate method to navigate to the file path and then using Print method, you can send the file to default printer. If you need to choose the printer, you can use ShowPrintDialog method.

Example

private void PrintFile(string fileName)
{
    using (var wb = new WebBrowser())
    {
        wb.Navigate(fileName);
        while (wb.ReadyState != WebBrowserReadyState.Complete)
        {
            Application.DoEvents();
        }
        wb.Print();
    }
}

MSDN Example

查看更多
登录 后发表回答