Visual Studio で実行すると、ローカルで正常に印刷される RDLC レポートがあります。プロジェクトをサーバーにアップロードすると、印刷されません。私はいくつかの調査を行っていて、プロジェクトがサーバーにある場合、クライアント マシンではなくサーバーで印刷しようとすることを知りました。クライアントマシンに印刷する方法はありますか?
private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
{
Stream stream = new MemoryStream();
m_streams.Add(stream);
return stream;
}
private void Export(LocalReport report)
{
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>EMF</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.01in</MarginTop>" +
" <MarginLeft>0.02in</MarginLeft>" +
" <MarginRight>0.25in</MarginRight>" +
" <MarginBottom>0.25in</MarginBottom>" +
"</DeviceInfo>";
Warning[] warnings;
m_streams = new List<Stream>();
report.Render("Image", deviceInfo, CreateStream, out warnings);
foreach (Stream stream in m_streams)
{
stream.Position = 0;
}
}
private void PrintPage(object sender, PrintPageEventArgs ev)
{
Metafile pageImage = new Metafile(m_streams[currentPageIndex]);
ev.Graphics.DrawImage(pageImage,ev.PageBounds);
currentPageIndex++;
ev.HasMorePages = (currentPageIndex < m_streams.Count);
}
private void Print_Ticket()
{
const string printerName = "HP DeskJet";
if (m_streams == null || m_streams.Count == 0)
return;
PrintDocument printDoc = new PrintDocument();
printDoc.PrinterSettings.PrinterName = printerName;
if (!printDoc.PrinterSettings.IsValid)
{
string msg = String.Format("Can't find printer \"{0}\".", printerName);
Console.WriteLine(msg);
return;
}
printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
printDoc.Print(); //Prints Document
}
public void WriteTicket(string ticket_number, string queue)
{
LocalReport report = new LocalReport();
//Displays ticket letter and number in ticket
report.ReportPath = "PrintTicket.rdlc";
ReportParameter ticket_parameter = new ReportParameter();
ticket_parameter.Name = "Ticket";
ticket_parameter.Values.Add(ticket_number);
report.SetParameters(new ReportParameter[] { ticket_parameter });
//Displays date and time in ticket
ReportParameter date = new ReportParameter();
date.Name = "Date_Time";
date.Values.Add(System.DateTime.Now.ToString());
report.SetParameters(new ReportParameter[] { date });
//Displays branch location in ticket
ReportParameter location_parameter = new ReportParameter();
location_parameter.Name = "Location";
location_parameter.Values.Add(queue);
report.SetParameters(new ReportParameter[] { location_parameter });
Export(report);
currentPageIndex = 0;
Print_Ticket();
}
//Clears stream
public new void Dispose()
{
if (m_streams != null)
{
foreach (Stream stream in m_streams)
stream.Close();
}
}