I am having trouble using a Brother QL-570 with Aspose.Words.
I’m using a model 205 continuous tape cartridge with the printer, which automatically cuts the tape to the print job’s length (e.g., 6"). I can open my Word document and manually print from MS Word 10, but see “Error - Paused - Printing” as the status in my printer’s job list.
My solution involves opening the Word document, merging in table data, saving to a .doc or .pdf file, and then printing using Doc.Print(PrinterSettings).
I suspect part of the problem is that the printer needs some additional guidance about the page size. If I double-click on the failed print job, I get a properties dialog. The “Paper” tab shows the “Format” to be “Normal” instead of some other appropriate option. I even created a custom format and saved it, but can’t figure out how to specify it when printing via Aspose.Words. The default “Width” property says ‘1-1/7" x 3-1/2"’ and shows the “Length” property to be ‘3.54"’ and “Feed” property to be ‘0.12"’. In any case, this would apply to a different kind of label cartridge than the one I have in the printer. I can choose ‘2-3/7"’ as the “Width” option instead, but again, it doesn’t “stick”.
I need some way to drive this label printer to print custom-cut-length labels or I don’t have a solution. I’m open to considering other label printers with continuous tapes and built-in cutters, but this one costs about $100, a compelling factor.
Suggestions on how to deal with this problem? Thank you.
Hi Jim,
Thanks for your inquiry. Could you please attach your input Word document, you’re getting this problem with, here for testing? I will investigate the issue on my side and provide you more information.
Best Regards,
Template is attached.
When I edit the template, I also use the printer setup area in Word to select the most appropriate settings. Unfortunately, this is an odd kludge by Microsoft and doesn’t really save everything to the document.
I should point out that I have found a hack way to get the labels I want printed, but it’s not elegant and is limited in use.
The essence of the solution is to have Aspose.Words save a .BMP file and to print that BMP file using code like below. The reason for this approach is that it is just about the only way I have found that allows me in code to control not only which printer is chosen, but also what sort of paper to use. See, the QL-570 has a continuous-feed tape and cutter. You specify the length you want as part of the print job. It should be automatically determined based on the width (or height, if rotated 90’), but their driver is a bit screwy. My solution involves defining one custom paper size in Brother’s driver dialog for each length I want for my labels (e.g., 6"). Using the System.Drawing.Printing.PrintDocument class allows me to specify a lot of the settings a human user could manually select from Printer Setup prior to printing. Most notably, I can set (or select) based on the “paper name”. One thing I don’t like about this is that the target machine must have the predefined paper name set up in advance of printing, but my client has a closed target environment we can control.
I’m wondering if Aspose.Words supports the ability to specify which predefined paper to use with the selected printer. If not, you might want to consider adding that and perhaps integration with the System.Drawing.Printing mechanisms that allow for customization of print settings.
- Jim
PrintDocument PrintDoc = new PrintDocument();
PrintDoc.PrinterSettings.PrinterName = Spec["DestinationPrinter"].ValueAsString;
System.Drawing.Printing.PaperSize PaperSize = null;
foreach(System.Drawing.Printing.PaperSize PaperSize2 in PrinterSettings.PaperSizes)
{
if (PaperSize2.PaperName == Spec["PaperSize"].ValueAsString)
{
PaperSize = PaperSize2;
break;
}
}
if (PaperSize == null) throw new Exception("Predefined paper size named '" + Spec["PaperSize"].ValueAsString + "Æ not found.");
PrintDoc.DefaultPageSettings.PaperSize = PaperSize;
PrintDoc.DefaultPageSettings.Landscape = true;
PrintDoc.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
Spec["PrintFile"].Value = BmpFile;
PrintDoc.DocumentName = BmpFile;
PrintDoc.PrintPage += new PrintPageEventHandler(PrintDoc_PrintPage);
PrintDoc.Print();
…
private void PrintDoc_PrintPage(object sender, PrintPageEventArgs e)
{
PrintDocument PrintDoc = (PrintDocument) sender;
System.Drawing.Image Bmp = System.Drawing.Image.FromFile(TempFilePath + "/Docs/" + PrintDoc.DocumentName);
e.Graphics.DrawImage(Bmp, new System.Drawing.Point(0, 0));
}
I also figured out how to save high resolution BMPs. The files were too low res by default. The bar codes were blurry. The key was to use the ImageSaveOptions class instead of the SaveOptions class. E.g.:
ImageSaveOptions SaveOptions = new ImageSaveOptions(SaveFormat.Bmp);
SaveOptions.Resolution = 300;
Doc.Save(TempFilePath + "Label.bmp", SaveOptions);
Hi Jim,
Thanks for the additional information. I was unable to reproduce this issue on my side. Could you please upgrade to latest version of Aspose.Words i.e. v11.7.0 and let us know how it goes on your side? You can download it from the following link:
https://releases.aspose.com/words/net
Also, in case you have any other printer available on your side, could you please test the scenario on that printer and share here your findings?
Best Regards,
Are you saying you actually got a QL-570 to test with? And used it with a continuous tape label? And that using Aspose.Words to print to it just worked? If so, please do tell me how.
Anyway, I do have the latest version and posted details about how I solved this problem using hacks. I thought others would benefit from that knowledge. I also asked several specific questions and made a minor suggestion. I’m hoping you give this thread a more thorough read.
Your product is a really good one, but there’s always room for improvement on something complex like this. Cheers.
- Jim
Hi Jim ,
Thanks for your inquiry.
No, I didn’t test the scenario using QL-570; instead, I used different soft printers for investigation and all produced the output as expected. Does the problem occur only with this particular document? I think, rendering this document to images and then printing those image is a fine solution. For example:
[Test]
public void Test001()
{
// Open source document.
Document doc = new Document(@"Test001\in.doc");
// Save the document as an image.
using (MemoryStream imageStream = new MemoryStream())
{
doc.Save(imageStream, SaveFormat.Tiff);
// Load the image back into another document
imageStream.Position = 0;
Document imageDoc = LoadImage(imageStream);
// Print the document.
imageDoc.Print();
}
}
///
/// Loads an image into Aspose.Words.Document object.
///
/// Stream with an image.
public Document LoadImage(Stream inputStream)
{
// Create Aspose.Words.Document and DocumentBuilder.
// The builder makes it simple to add content to the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Read the image from file, ensure it is disposed.
using (Image image = Image.FromStream(inputStream))
{
// Get the number of frames in the image.
int framesCount = image.GetFrameCount(FrameDimension.Page);
// Loop through all frames.
for (int frameIdx = 0; frameIdx < framesCount; frameIdx++)
{
// Insert a section break before each new page, in case of a multi-frame TIFF.
if (frameIdx != 0)
builder.InsertBreak(BreakType.SectionBreakNewPage);
// Select active frame.
image.SelectActiveFrame(FrameDimension.Page, frameIdx);
// We want the size of the page to be the same as the size of the image.
// Convert pixels to points to size the page to the actual image size.
PageSetup ps = builder.PageSetup;
ps.PageWidth = ConvertUtil.PixelToPoint(image.Width, image.HorizontalResolution);
ps.PageHeight = ConvertUtil.PixelToPoint(image.Height, image.VerticalResolution);
// Insert the image into the document and position it at the top left corner of the page.
Shape shape = builder.InsertImage(image,
RelativeHorizontalPosition.Page,
0,
RelativeVerticalPosition.Page,
0,
ps.PageWidth,
ps.PageHeight,
WrapType.None);
}
}
return doc;
}
And of course you can specify resolution via ImageSaveOptions during rendering Word document to Image.
Best Regards,