I have a document which I will load it from MemoryStream and try to print. The problem is that the MemoryStream has 815KB but when I look in the printer dialog the size of the document grows to 21 MB, which take a long time for printer to load it in memory. Inside this document I have 30 barcodes as images draw on canvas, which I need them in high resolution.
Why this happens?
Code I used to print the stream:
- Code: Select all
// SablonCompletat is a MemoryStream of 815KB in size
using Spire.Pdf.PdfDocument pdf = new(SablonCompletat);
// pdf.SaveToFile(fileToPrintTo); it creates a file with the same size as MemoryStream.
Printing.PrinterSettings ps = new();
Printing.PageSettings pgs = new();
Printing.PrintDocument prtdoc = new();
//Set printer name
ps.PrinterName = PrinterName;
ps.Copies = PrinterCopies;
//Set PageSize (if required)
pgs.PaperSize = new Printing.PaperSize("A4", 827, 1169);
// Set PageMargins (if required)
pgs.Margins = new Printing.Margins(0, 0, 0, 0);
// Print document using printer and page settings
pdf.PrintSettings.PaperSize = pgs.PaperSize;
pdf.PrintSettings.Copies = PrinterCopies;
pdf.PrintSettings.PrinterName = PrinterName;
pdf.PrintSettings.SetPaperMargins(5, 5, 0, 0);
//pdf.PrintSettings.PrinterResolutionKind = Spire.Pdf.Print.PdfPrinterResolutionKind.Draft; // I've tried different values, same out size
pdf.PrintSettings.PrintController = new StandardPrintController();
pdf.Print();