Page 1 of 1

PrinterVector why is not printed on the printer

Posted: Wed Mar 10, 2021 6:33 am
by Schobaer
Hi,
why don't print on the printer? On Canvas it's fine.
Thanks for solution!

Code: Select all

If OpenWindow(0, 0, 0, 400, 400, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 400, 200)
  LoadFont(0, "Times New Roman", 20, #PB_Font_Bold)
  
    Debug DefaultPrinter()
  Debug PrinterVectorOutput()
  ;If StartVectorDrawing(CanvasVectorOutput(0))
  If StartVectorDrawing(PrinterVectorOutput())
    VectorFont(FontID(0), 11)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    MovePathCursor(50, 25)
    DrawVectorText("huhu")
    DrawVectorText("hihi")
    MovePathCursor(50, 100)
    DrawVectorParagraph("asdfas asdfasdf asdfa fdsfasdf asdfasdf asdfasdf asdfasdfasdf asdfasdfasdf asdfasdf asdfa asdfasdf asdfasdfasdf",100,100,#PB_VectorParagraph_Right)
  
    StopVectorDrawing()
  EndIf


  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
// Edit: Code-Tags added (Kiffi)

Re: PrinterVector why is not printed on the printer

Posted: Wed Mar 10, 2021 7:54 am
by infratec
You forgot StartPrinting() and StopPrinting()

Code: Select all

EnableExplicit

Define.i Event

If OpenWindow(0, 0, 0, 400, 400, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 400, 200)
  LoadFont(0, "Times New Roman", 20, #PB_Font_Bold)
  
  If DefaultPrinter()
    If StartPrinting("PB VectorTest")
      ;If StartVectorDrawing(CanvasVectorOutput(0))
      If StartVectorDrawing(PrinterVectorOutput())
        VectorFont(FontID(0), 11)
        VectorSourceColor(RGBA(255, 0, 0, 255))
        MovePathCursor(50, 25)
        DrawVectorText("huhu")
        DrawVectorText("hihi")
        MovePathCursor(50, 100)
        DrawVectorParagraph("asdfas asdfasdf asdfa fdsfasdf asdfasdf asdfasdf asdfasdfasdf asdfasdfasdf asdfasdf asdfa asdfasdf asdfasdfasdf",100,100,#PB_VectorParagraph_Right)
        
        StopVectorDrawing()
      EndIf
      StopPrinting()
    EndIf
  EndIf
  
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

Re: PrinterVector why is not printed on the printer

Posted: Wed Mar 10, 2021 8:05 am
by TI-994A
Schobaer wrote:...why don't print on the printer?
A call to the StartPrinting() function is required:

Code: Select all

wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered 
OpenWindow(0, 0, 0, 400, 200, "Vector Printing", wFlags)   

If DefaultPrinter() And 
   StartPrinting("Vector Printing") And 
   StartVectorDrawing(PrinterVectorOutput())  
  
  LoadFont(0, "Times New Roman", 20, #PB_Font_Bold)
  
  VectorFont(FontID(0), 11)
  VectorSourceColor(RGBA(255, 0, 0, 255))
  MovePathCursor(50, 25)
  DrawVectorText("PureBasic Vector Printing... ")
  DrawVectorText("a sample printout.")
  MovePathCursor(50, 100)
  DrawVectorParagraph("More random text to test printing constraints...", 
                      100, 100, #PB_VectorParagraph_Right)
  
  StopVectorDrawing()   
  StopPrinting()    
EndIf

While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend   

Re: PrinterVector why is not printed on the printer

Posted: Wed Mar 10, 2021 10:45 am
by Schobaer
Thank you, was just too stupid!

Re: PrinterVector why is not printed on the printer

Posted: Sat May 01, 2021 8:13 pm
by eck49
Not too stupid, I hope!

Because I was about to ask the same question....

Supplementary...
I think this may not be a PB issue, but what is going on here, and what can I do about it?

If I VectorOutput to PDF and then view the resulting file with a PDF viewer (Evince), it looks on screen just like the print on paper I get using VectorOutput to printer. But if I print the PDF file from the Viewer I get a tiny version of what I want in the middle of the paper. Scaled almost exactly 28%.

EDIT: Do about it? Answer is to Scale to fit printable area (option in Evince) which produces a print looking exactly like the print done directly from PB. Although it is not obvious to me why the PDF from PB does not have this size as its default.