Print To Different Tray/Bin Not Working
Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3992
Printed Date: 22 Nov 24 at 7:11AM Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com
Topic: Print To Different Tray/Bin Not Working
Posted By: m_alam
Subject: Print To Different Tray/Bin Not Working
Date Posted: 13 Sep 22 at 1:18AM
Greeting,
i am trying to print to different tray/bin..
i have tried to set paper tray number using following code:
objRPDF.SetupCustomPrinter(strPrinterConfig, 9, Convert.ToInt32(PrinterTrayTextbox.Text)); // REM Printer Tray/Bin |
my printer has 4 trays.. i tried 1 to number 4 that didn't work..
so, i made a demo tool to list the printer trays, but strangely it shows same trays number for most of my printers :(
but still when i try to print tray 15 and 257 (using 1st printer name), both print to same/default tray :(
and more strange is that the 2nd printer on the list only have 1 tray, but qpl also shows same trays number for that one too? :(
so? what i am doing wrong here?
thanks in advance for upcoming help
best regards
|
Replies:
Posted By: Ingo
Date Posted: 13 Sep 22 at 10:16PM
Hi Hassan,
To check about the real printer names i use: GetPrinterNames. To check about existing printer bins i use: GetPrinterBins.
Doing the output the following syntax should help:
if ( prname = 'default' ) Then PriName := QP.GetDefaultPrinterName;
if ( prname <> 'default' ) then PriName := prname;
// . . .
propt := QP.PrintOptions(pscal, rotate, fname); if ( bin > 0 ) Then begin cPriName := QP.NewCustomPrinter(PriName); QP.SetupCustomPrinter(cPriName, 9, bin); end; if ( pend = 9999 ) then pend := pc; // pagecount for i := 1 to copies do begin if ( bin > 0 ) Then QP.PrintDocument(cPriName, pstart, pend, propt) // with bin else QP.PrintDocument(PriName, pstart, pend, propt); // without bin end;
------------- Cheers, Ingo
|
Posted By: m_alam
Date Posted: 14 Sep 22 at 12:50AM
Ingo wrote:
Hi Hassan,
To check about the real printer names i use: GetPrinterNames. To check about existing printer bins i use: GetPrinterBins.
Doing the output the following syntax should help:
if ( prname = 'default' ) Then PriName := QP.GetDefaultPrinterName;
if ( prname <> 'default' ) then PriName := prname;
// . . .
propt := QP.PrintOptions(pscal, rotate, fname); if ( bin > 0 ) Then begin cPriName := QP.NewCustomPrinter(PriName); QP.SetupCustomPrinter(cPriName, 9, bin); end; if ( pend = 9999 ) then pend := pc; // pagecount for i := 1 to copies do begin if ( bin > 0 ) Then QP.PrintDocument(cPriName, pstart, pend, propt) // with bin else QP.PrintDocument(PriName, pstart, pend, propt); // without bin end;
|
that's what exactly my code does, though in different language.. but it just not working :(
|
Posted By: Ingo
Date Posted: 14 Sep 22 at 7:21PM
not really "exactly" cause my code works for me ;-)
------------- Cheers, Ingo
|
Posted By: m_alam
Date Posted: 17 Sep 22 at 3:09AM
Ingo wrote:
not really "exactly" cause my code works for me ;-)
|
strPrinterConfig = objRPDF.NewCustomPrinter(PrinterName); objRPDF.SetupCustomPrinter(strPrinterConfig, 1, 0); // REM custom paper size objRPDF.SetupCustomPrinter(strPrinterConfig, 2, intHeight); // REM custom paper height objRPDF.SetupCustomPrinter(strPrinterConfig, 3, intWidth); // REM custom paper width objRPDF.SetupCustomPrinter(strPrinterConfig, 5, 1); // REM quality 1 = high, 2 = medium, 3 = low, 4 = draft, Or Exact DPI objRPDF.SetupCustomPrinter(strPrinterConfig, 6, 2); // REM Color 1 = monochrome, 2 = Color objRPDF.SetupCustomPrinter(strPrinterConfig, 9, Convert.ToInt32(PrinterTrayTextbox.Text)); // REM Printer Tray/Bin objRPDF.SetupCustomPrinter(strPrinterConfig, 11, PageLayout); // REM 1 = portrait, 2 = landscape
|
that is the code i am using to setup printer tray, what i am doing wrong here? can you please tell me?
thanks in advance
best regards
|
Posted By: Ingo
Date Posted: 28 Sep 22 at 9:43PM
Do you read all at "for default source" (New Value)? https://www.debenu.com/docs/pdf_library_reference/SetupCustomPrinter.php
There should be a problem... After each code line you can check the returning value of the call from one line before. 1 means okay / 0 means error
Perhaps this helps one step further?
------------- Cheers, Ingo
|
Posted By: jack97119
Date Posted: 01 Jan 24 at 5:04PM
Before printing, you can set the paper box that the printer will use in advance.The following example achieves a more flexible function: changing the paper box used during the printing process. If you only need to set up the paper box before printing, you can modify the code yourself. ============================== code: Printer.BeginDoc; //dosomething...print
//--------- Changing Trays .... ----------------- Printer.GetPrinter(device, driver, port, hDMode); if (hDMode <> 0) then begin pDMode := GlobalLock(hDMode); if Assigned(pDMode) then begin pDMode.dmFields := pDMode.dmFields or DMBIN_MANUAL; pDMode.dmDefaultSource :=GetTraysID(); winapi.Windows.EndPage( Printer.Handle ); If ResetDC( Printer.canvas.Handle, pDMode^ ) = 0 Then showmessage( 'ResetDC failed, '+SysErrorMessage(GetLastError)); GlobalUnlock( hDMode ); winapi.Windows.StartPage( Printer.Handle ); Printer.Canvas.Refresh; end; //--------------------------------------------------
//dosomething...print Printer.EndDoc; end;
function GetTraysID()(TraysName: string; adevice, aport: PWideChar): Word; var i, rslt: Integer; tBinNames: array of Tbinname; BinCodes: array of Word; begin Result := DM_DEFAULTSOURCE; rslt := devicecapabilitiesW(adevice, aport, dc_binnames, nil, nil); if rslt > 0 then begin setlength(tBinNames, rslt); setlength(BinCodes, rslt); try if devicecapabilitiesW(adevice, aport, dc_binnames, @tBinNames[0], nil) = -1 then begin setlength(BinCodes, 0); setlength(tBinNames, 0); raise exception.Create('error tbinnames'); end; if devicecapabilitiesW(adevice, aport, DC_BINS, @BinCodes[0], nil) = -1 then begin setlength(BinCodes, 0); setlength(tBinNames, 0); raise exception.Create('error BinCodes'); end;
for i := 0 to rslt - 1 do begin if TraysName = tBinNames then begin Result := BinCodes; Break; end; end; finally setlength(BinCodes, 0); setlength(tBinNames, 0); end; end; end;
|
|