Page 1 of 1
StartPrinting with no StopPrinting?
Posted: Mon Mar 07, 2016 5:26 pm
by fromVB
This code works to return the printable area but exits without calling StopPrinting so as not to eject a blank page. The print job flashes briefly in the spooler window but gets removed as soon as the procedure returns:
Code: Select all
Procedure getPaperSize()
If PrintRequester()
If StartPrinting("Vector Printing")
If StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Millimeter))
Debug VectorOutputWidth()
Debug VectorOutputHeight()
StopVectorDrawing()
ProcedureReturn
EndIf
StopPrinting()
EndIf
EndIf
EndProcedure
getPaperSize()
Will this not calling of StopPrinting cause any kind of memory leak or device error down the road?
Re: StartPrinting with no StopPrinting?
Posted: Mon Mar 07, 2016 6:05 pm
by IdeasVacuum
You would expect it to be a problem (by the way, your procedure does call StopPrinting())
If the app is only for Windows, a wealth of information can be collected from the printer via the API.
Re: StartPrinting with no StopPrinting?
Posted: Tue Mar 08, 2016 2:55 am
by fromVB
IdeasVacuum wrote:You would expect it to be a problem (by the way, your procedure does call StopPrinting())
If the app is only for Windows, a wealth of information can be collected from the printer via the API.
Hi IdeasVacuum. StopPrinting is not called because the procedure exits before reaching it. And the routine still works if StopPrinting is remmed out.
API works but not so accurately with vector output. This is a normal A4 paper:
Code: Select all
GetDeviceCaps_(pdc, #HORZRES) = 4760
GetDeviceCaps_(pdc, #VERTRES) = 6814
PrinterPageWidth() = 4760
PrinterPageHeight() = 6814
VectorOutputWidth() = 4771
VectorOutputHeight() = 6803
I am only able to get the vector width and height of the printer after calling StartPrinting.
What is the problem you said you expect if StopPrinting is not called?
Re: StartPrinting with no StopPrinting?
Posted: Tue Mar 08, 2016 4:52 am
by IdeasVacuum
PB5.42LTS x86, Win7x86
Well, I expected problems to arise because PB usually expects a Start to be followed with a Stop, but I don't know if that is the case in this instance. Certainly if another StartPrinting() is called after getPaperSize(), no harm seems to have been done, but since the print area available is device dependent, you would not expect to have to Start Printing before being able to verify the size of the print area. This works on my PC:
Code: Select all
Procedure getPaperSize()
If PrintRequester()
If StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Millimeter))
Debug VectorOutputWidth()
Debug VectorOutputHeight()
StopVectorDrawing()
EndIf
EndIf
EndProcedure
getPaperSize()
Re: StartPrinting with no StopPrinting?
Posted: Tue Mar 08, 2016 3:23 pm
by fromVB
IdeasVacuum wrote:PB5.42LTS x86, Win7x86
Well, I expected problems to arise because PB usually expects a Start to be followed with a Stop, but I don't know if that is the case in this instance. Certainly if another StartPrinting() is called after getPaperSize(), no harm seems to have been done, but since the print area available is device dependent, you would not expect to have to Start Printing before being able to verify the size of the print area. This works on my PC:
Code: Select all
Procedure getPaperSize()
If PrintRequester()
If StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Millimeter))
Debug VectorOutputWidth()
Debug VectorOutputHeight()
StopVectorDrawing()
EndIf
EndIf
EndProcedure
getPaperSize()
Thanks IdeasVacuum. Never thought of trying that.
