try
{
// Path to save the Publisher file
string pubPath = Server.MapPath("~/Reports/MyReport.pub");
// Create a new Publisher document
PublisherDocument doc = new PublisherDocument();
// Example: Add a simple text frame
var page = doc.Pages.Add();
var textFrame = page.TextFrames.Add();
textFrame.Text = "This is my ASP.NET generated Publisher report.";
// Save the .pub file
doc.Save(pubPath);
Response.ContentType = "application/vnd.ms-publisher";
Response.AppendHeader("Content-Disposition", "attachment; filename=MyReport.pub");
Response.TransmitFile(pubPath);
Response.End();
}
catch (Exception ex)
{
Response.Write("Error: " + ex.Message);
}
}