The printer couldn't print node print job - printing

I'm using the "electron-printer" package to RAW print from my electron app. The document makes it to the printer quee but it goes to error and the system shows a "The printer couldn't print node print job" message. I'm attaching my code for reference.
var printer = require('electron-printer');
function printString(str){
printer.printDirect({
data: str,
printer: printer.getDefaultPrinterName(),
type: 'RAW',
success:function(jobID){
console.log("Succesfully sent to printer. Job id is: "+jobID);
},
error:function(err){console.log(err);}
});
}

Related

Preset output filename & Bypass 'Save As' dialogue after sending document to pdf printer VB6

Working on a legacy application. im looking for a way to preset the output filename & Bypass 'Save As' dialogue after sending document to pdf printer VB6. Im printing a report but i want to programmatically set the filename and avoid seeing the 'save as' common dialog. Pls help
'Determine Default Printer
Dim PrintData As Printer
Dim defprinterpos%
Lstprinter.Clear
For Each PrintData In Printers
' Add printer name and port to list
Lstprinter.AddItem PrintData.DeviceName '& " at: " & PrintData.Port
' Check for default printer
If PrintData.DeviceName = Printer.DeviceName Then defprinterpos = Lstprinter.NewIndex
Next
Lstprinter.ListIndex = defprinterpos%
frmmain.lblPrinter.Caption = Lstprinter.List(Lstprinter.ListIndex)
' SetPrinter ("Microsoft Print to PDF")
If Check4.Value = 1 Then
Dim PrinterName As String
PrinterName = "Microsoft Print to PDF" '"CutePDF Writer"
Dim w As New WshNetwork
w.SetDefaultPrinter (PrinterName)
Set w = Nothing
End If
' print the Sales Invoice
rptsales.printreport

How to get printer where report was printed

If PROMPT calsue is used in report
REPORT FORM xxx to PRINT PROMPT
User can select printer where report is printed.
How to get this printer name for logging?
https://support.microsoft.com/en-us/help/162798/how-to-use-the-set-printer-to-name-command-to-print-to-a-specified-printer-in-visual-foxpro
Show hot to use GetPrinter() for this. This requires removing PROMPT clause from REPORT
How to get printer where report was printed using PROMPT clause:
REPORT FORM xxx TO PRINT PROMPT
If this possbible, maybe thereis some sys() function or somethis other or is it possible to get printer name during report print ?
Or should this command re-factored not to use PROMPT clause like:
cPrinter = getprinter()
set printer to name (cPrinter)
REPORT FORM xxx TO PRINT
insert into logfile (PrinterUsedForPrinting) values (cPrinter)
I would suggest using your solution of calling GETPRINTER prior to running the report (without the PROMPT clause). In my long experience using FoxPro/VFP I don't think I've come across a way to determine the printer via REPORT FORM...PROMPT.
Here's an example wrapper function that you may find useful. I typically call "PickPrinter" prior to running a report. If PickPrinter returns an empty string, I abort the report run.
FUNCTION PickPrinter
IF APRINTERS(a_printers) < 1
MESSAGEBOX("No printers defined.")
RETURN ""
ELSE
lcPrnChoice = ""
lcPrnChoice = GETPRINTER()
IF EMPTY(lcPrnChoice)
RETURN ""
ELSE
*** Include quotes around the printer name
*** in case there are spaces in the name
lcPrnChoice = "NAME [" + lcPrnChoice + "]"
SET PRINTER TO &lcPrnChoice
RETURN lcPrnChoice
ENDIF
ENDIF
ENDFUNC

Print with PDFBox

Im new here and have a Problem with PDFBox.
Im trying to print a single PDF Document, but it doesnt work so far.
I found some examples in the internet, but dont get it run, so I hope someone here has an idea, where my mystake is.
The Code I have so far is:
File datei = new File("D:\\161413070_00-76-150-1803_FIP_170109.pdf");
if(datei.exists())
{
try(PDDocument doc = PDDocument.load(datei)) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(doc));
if(job.printDialog())
{
job.print();
}
doc.close();
}catch(InvalidPasswordException ivpwe)
{
Logger.getLogger(WinScanJ.class.getName()).log(Level.SEVERE, null, ivpwe);
}
catch(IOException | PrinterException ioe)
{
Logger.getLogger(WinScanJ.class.getName()).log(Level.SEVERE, null, ioe);
}
}
The program is opening the print dialog which is fine and it seems to send out a print job. I can see a Print Job in the print queue in windows for about a second, but the printer isnt printing something.
I have a network printer here and it works fine.
I guess my program is sending an empty print advice, but dont know why. The specified PDF Document exists and isn`t empty.
Does anybody have an idea what the problem could be?
Thanks in advice
TDO

Xojo Print Without Printer Dialog

I would like to print directly to an attached label printer without showing the print dialog.
I have searched to see if such a thing is possible but it seems it is not. So, I thought I would ask here in case someone knows a way to do it.
You have to save the Printer SetupString. Then the next time you go to print use that SetupString to initialize the PrinterSetup object. See actual code copied from working project below:
'Now print the mail barcode
dim ps as PrinterSetup
dim page as Graphics
ps = LabelPrinter //See below
if ps<>nil then
page = OpenPrinter(ps)
if page<>nil then
//send stuff to the printer here
Public Function LabelPrinter() as PrinterSetup
if gLabelSetup<>"" then //gLabelSetup is saved in preferences
dim ps as new PrinterSetup
ps.SetupString = gLabelSetup
return ps
else
return nil
end if
End Function

active reports always sends to default printer

I want to print to a network printer from active reports but it always prints to default printer without throwing error.
Once I try to print with the .net printdocument library it print to specified printer.
I don't know why it is printing to default printer when using activereports.
Set the PrinterName property of the Printer object. Something like the following:
viewer.Document.Printer.PrinterName = "TheNetworkPrinterName";
viewer.Print();
The value of the PrinterName property should be the exact name from windows. To get a list of the valid printer names on a given system you can enumerate the list of printers using PrinterSettings.InstalledPrinters. An example of enumerating the available printers is in the MSDN documentation here.
If you try something and find it doesn't work give us more detailed information and we'll try to help you.
Change printer in end user designer.
Grapecityteam answer:
For a SectionReport, you could inject a Script to change the default printer when the report is loaded, in the LayoutChanged event of the Designer as given below:
private void OnLayoutChanged(object sender, LayoutChangedArgs e)
{
if (e.Type == LayoutChangeType.ReportLoad || e.Type == LayoutChangeType.ReportClear)
{
reportToolbox.Reorder(reportDesigner);
reportToolbox.EnsureCategories();
reportToolbox.Refresh();
RefreshExportEnabled();
CreateReportExplorer();
splitContainerMiddle.Panel2Collapsed = reportDesigner.ReportType == DesignerReportType.Section;
if (reportDesigner.ReportType == DesignerReportType.Section)
{
string script = string.Empty;
script += "public void ActiveReport_ReportStart()";
script += "{";
script += "rpt.Document.Printer.PrinterSettings.PrinterName = System.Drawing.Printing.PrinterSettings.InstalledPrinters[3];";
script += "}";
(reportDesigner.Report as SectionReport).ScriptLanguage = "C#";
(reportDesigner.Report as SectionReport).Script = script;
}
}
thanks to Grapecity Sales and Support

Resources