I have a solution that uses XpsDocumentWriter to save my report's FixDocument to a xps file and then uses PDFSharp to convert the xsp file to a PDF file. I have another console application that uses PrintServer and PrintQueue to send the bytes of the saved PDF file to a selected printer. The PDF file can be printed on a network RICOH printer, but cannot be printed on a local printer like Lexmark C544 XL, Lexmark E350D or Canon LBP6000/LBP6018. All contents except the bitmap on the PDF file are not printed. I tried a PDF file that was generated by Adobe and it can be printed on the same local printer via my console application. If I open the PDFSharp generated PDF file and manually send it to the local printers, the local printers can print all contents without any problem. Does anybody have any idea about the PDFSharp generated PDF file printing issue? Thanks!
Here is the main program in the console application.
Code:
class Program
{
static void Main(string[] args)
{
string printServerName = string.Empty;
string jobQueueName = string.Empty;
PrintServer printServer = null;
PrintQueue pq;
PrintSystemJobInfo jobInfo;
if (args[0] != "LP") // network printer
{
printServerName = @"\\svuschaprint";
jobQueueName = @"LPUSCHA521C";
printServer = new PrintServer(printServerName);
}
else // local printer
{
printServer = new PrintServer();
jobQueueName = @"Lexmark C544 XL";
}
pq = new PrintQueue(printServer, jobQueueName);
// SIQ Report Package.pdf is generated by Adobe.
// report_20160121161851854.pdf is generated from a xps file by PDFSharp.
Byte[] myByteBuffer = File.ReadAllBytes(@"C:\TEMP\Patient Chartable Report - 20160128_165056.pdf");//SIQ Report Package.pdf");
jobInfo = pq.AddJob(@"Print Screen Report");
using (MemoryStream ms = new MemoryStream(myByteBuffer))
{
ms.CopyTo(jobInfo.JobStream);
jobInfo.JobStream.Close();
}
printServer.Commit();
}
}
}
Here is the PDF file generated by PDFSharp.
http://1drv.ms/1PFK7FtHere is the PDF file generated by Adobe.
http://1drv.ms/1PFKgbL