PDFsharp: The name 'Process' does not exist in current context

元气小坏坏 提交于 2020-01-06 04:23:25

问题


I have been trying to install the PDFsharp library for the purpose of writing PDF records and came across a problem. It keeps saying that the Process does not exist in current context. I did a google and had no luck and a tinker to see if I can get it to work and no luck either. Below is the code I am using to test the library (pulled from the PDFsharp wiki)

PdfDocument document = new PdfDocument(); 
document.Info.Title = "Created with PDFsharp"; 
PdfPage page = document.AddPage();  
XGraphics gfx = XGraphics.FromPdfPage(page);     
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic); 
gfx.DrawString("Hello, World!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.Center); 
string filename = "HelloWorld.pdf"; 
document.Save(filename);
process.Start(filename); 

And these are the components I currently have in use.

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using PdfSharp; 
using PdfSharp.Drawing; 
using PdfSharp.Pdf; 
using PdfSharp.Pdf.IO; 

I am probably being daft but can anyone see what I am doing wrong to throw this error?


回答1:


This line is wrong

process.Start(filename);

and it has nothing to do with PDFsharp. You have to resolve that

using System.Diagnostics;
...
Process.Start(filename);



回答2:


If you don't want to add the "using" Directive:

System.Diagnostics.Process.Start(filename);


来源:https://stackoverflow.com/questions/31605767/pdfsharp-the-name-process-does-not-exist-in-current-context

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!