I’m searching for quite a while how to print “PDF” files in c# , I’m trying to print shipping labels which I get it in a “GZip Stream” string and the format is a pdf, So my question is what’s is the best way to print out the “PDF” label (Not images or any image format), and also be able to set to which printer to print? The best way would be without having to save the label in my computer and then recall the file! it's doesn't make sense that the only way is to install third party classes!
This is what i have done!
private void PrintFDFLabel(string imageLabel)
{
var byteStream = Convert.FromBase64String(imageLabel);
MemoryStream memoryStream = Decompress(byteStream);// i need to Decompress the Gzip
PrintDocument print = new PrintDocument();
print.PrinterSettings.PrinterName = Properties.Settings.Default.DefaultPrimePrinter;
print.Print();
}
private MemoryStream Decompress(byte[] b)
{
MemoryStream memoryStream;
using (var ms = new MemoryStream())
{
using (var bs = new MemoryStream(b))
using (GZipStream gZipStream = new GZipStream(bs, CompressionMode.Decompress))
{
memoryStream = new MemoryStream();
gZipStream.CopyTo(memoryStream);
}
return memoryStream;
}
}