mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 10:39:53 +01:00 
			
		
		
		
	printer4lazarus: cups: check PrintFile result and show error
git-svn-id: trunk@50174 -
This commit is contained in:
		
							parent
							
								
									a46caecea3
								
							
						
					
					
						commit
						937c594c3f
					
				@ -28,7 +28,6 @@ unit OSPrinters;
 | 
			
		||||
 | 
			
		||||
interface
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{$IFDEF UNIX}
 | 
			
		||||
  {$IFDEF DARWIN}
 | 
			
		||||
    {$IFDEF LCLCarbon}
 | 
			
		||||
 | 
			
		||||
@ -467,7 +467,7 @@ begin
 | 
			
		||||
end;
 | 
			
		||||
{$ENDIF}
 | 
			
		||||
 | 
			
		||||
//Print the file aFileName with a selected printer an options
 | 
			
		||||
//Print the file aFileName with a selected printer and options
 | 
			
		||||
function TCUPSPrinter.PrintFile(aFileName: String): longint;
 | 
			
		||||
var
 | 
			
		||||
  aPrinterName : string;
 | 
			
		||||
@ -498,6 +498,11 @@ begin
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function TCUPSPrinter.GetLastError: string;
 | 
			
		||||
begin
 | 
			
		||||
  Result:=ippErrorString(cupsdyn.cupsLastError());
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function TCUPSPrinter.IsOptionValueValid(AKeyword, AValue: pchar): boolean;
 | 
			
		||||
var
 | 
			
		||||
  Option: pppd_option_t;
 | 
			
		||||
@ -896,6 +901,8 @@ end;
 | 
			
		||||
//If not aborted, send PostScript file to printer.
 | 
			
		||||
//After, delete this file.
 | 
			
		||||
procedure TCUPSPrinter.DoEndDoc(aAborted: Boolean);
 | 
			
		||||
var
 | 
			
		||||
  CupsResult: LongInt;
 | 
			
		||||
begin
 | 
			
		||||
  inherited DoEndDoc(aAborted);
 | 
			
		||||
  dec(FBeginDocCount);
 | 
			
		||||
@ -922,15 +929,21 @@ begin
 | 
			
		||||
    {$IFDEF LogPrintoutFile}
 | 
			
		||||
    CopyFile(FOutputFileName, 'printjob'+ExtractFileExt(FOutputFileName));
 | 
			
		||||
    {$ENDIF}
 | 
			
		||||
    try
 | 
			
		||||
      {$IFNDEF DoNotPrint}
 | 
			
		||||
      if Filename<>'' then
 | 
			
		||||
        CopyFile(FOutputFileName, FileName)
 | 
			
		||||
    else
 | 
			
		||||
      PrintFile(FOutputFileName);
 | 
			
		||||
      else begin
 | 
			
		||||
        CupsResult:=PrintFile(FOutputFileName+'1');
 | 
			
		||||
        if CupsResult<=0 then
 | 
			
		||||
          raise Exception.Create('CUPS printing: '+GetLastError);
 | 
			
		||||
      end;
 | 
			
		||||
      {$ENDIF}
 | 
			
		||||
    finally
 | 
			
		||||
      DeleteFileUTF8(FOutputFilename);
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TCUPSPrinter.DoResetPrintersList;
 | 
			
		||||
begin
 | 
			
		||||
 | 
			
		||||
@ -168,6 +168,7 @@ type
 | 
			
		||||
    --------------------------------------------------}
 | 
			
		||||
    procedure SetJobState(aJobId : LongInt; aOp : ipp_op_t);
 | 
			
		||||
    function PrintFile(aFileName: String): longint;
 | 
			
		||||
    function GetLastError: string;
 | 
			
		||||
    procedure DebugOptions(AOPtions:Pcups_option_t=nil; n:Integer=0);
 | 
			
		||||
    function cupsGetOption(aKeyWord: string): String;
 | 
			
		||||
    function CopyOptions(out AOptions: Pcups_option_t): Integer;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user