接收'打开'提示,每次我打开pdf

本文关键字:pdf 打开 提示 接收 | 更新日期: 2023-09-27 18:09:33

c# 2008 Express, Winforms。使用iTextSharp,每次我从存储在服务器上的模板创建pdf时,我都会得到"Open With"提示,询问我想使用什么程序来打开pdf,显然是Acrobat,这是打开任何pdf的默认程序。如果我对存储在本地驱动器上的pdf进行同样的操作,我不会收到该消息,当我打开任何pdf时也不会收到此消息。由于我要发布这个程序,我不希望用户每次都收到这个提示。

string pdfTemplate = @"''server'files'Temp'invoice.pdf";
string newFile = @"''server'files'Temp'completed_invoice";
PdfReader pdfReader = new PdfReader(pdfTemplate);
PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create));
AcroFields pdfFormFields = pdfStamper.AcroFields;
pdfFormFields.SetField("Name", invoiceName);
pdfFormFields.SetField("Date", invoiceDate);
pdfFormFields.SetField("Address", invoiceAddress);
pdfFormFields.SetField("City", invoiceCity);
pdfFormFields.SetField("State", invoiceState);
pdfFormFields.SetField("Zip", invoiceZip);
pdfStamper.FormFlattening = false;
pdfStamper.Close();
Process.Start(newFile);

接收'打开'提示,每次我打开pdf

Try

string pdfTemplate = @"''server'files'Temp'invoice.pdf";
string newFile = @"''server'files'Temp'completed_invoice";
PdfReader pdfReader = new PdfReader(pdfTemplate);
PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create));
AcroFields pdfFormFields = pdfStamper.AcroFields;
pdfFormFields.SetField("Name", invoiceName);
pdfFormFields.SetField("Date", invoiceDate);
pdfFormFields.SetField("Address", invoiceAddress);
pdfFormFields.SetField("City", invoiceCity);
pdfFormFields.SetField("State", invoiceState);
pdfFormFields.SetField("Zip", invoiceZip);
pdfStamper.FormFlattening = false;
pdfStamper.Close();

ProcessStartInfo start = new ProcessStartInfo(newFile); //or any other file name.
start.ErrorDialog = false;
start.UseShellExecute = false;
Process.Start(start);