Printer_Lib

Just starting out? Need help? Post your questions and find answers here.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Printer_Lib

Post by IdeasVacuum »

Print_Image() should be after Print_StartPrinting()
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: Printer_Lib

Post by ClueLess »

I'm sorry IdeasVacuum

Did not read your entire line yestarday. Could have been solved yestarday...
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Printer_Lib

Post by IdeasVacuum »

Print_DrawText() will give wordwrap.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: Printer_Lib

Post by ClueLess »

Ok got it. But how would I get the printing width To define the box?
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: Printer_Lib

Post by ClueLess »

I tried with this line code:

Code: Select all

    Print_DrawText(25, 62, 175, 100, InterventionTxt)
25 is my X, 62 is my Y, and the text box is 175 wide by 100 high.

InterventionTxt is my text that should span 2 or 3 lines.

Any help Please?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Printer_Lib

Post by IdeasVacuum »

But how would I get the printing width To define the box?
Do you mean the distance between the paper margins?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Printer_Lib

Post by IdeasVacuum »

Test this:

Code: Select all

Enumeration
  #Logo
EndEnumeration

Define *RX = AllocateMemory(SizeOf(long))
Define *RY = AllocateMemory(SizeOf(long))
Define *RW = AllocateMemory(SizeOf(long))
Define *RH = AllocateMemory(SizeOf(long))

sInterventionTxt.s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam molestie commodo magna, id rutrum enim suscipit ac. Nunc tempor faucibus magna, vel volutpat tellus luctus et. Nam quis diam non nunc sagittis cursus non nec ante. Suspendisse egestas magna ac diam pulvinar eu iaculis eros mattis. Sed scelerisque molestie felis, in facilisis tellus varius quis. Nam dictum dignissim auctor. Nam dolor dui, commodo ut iaculis ut, faucibus pellentesque turpis. Etiam sagittis lacinia eros, et sollicitudin quam dictum ut. Fusce sagittis porttitor nunc, a tempor eros iaculis sit amet. Aliquam erat volutpat. Duis nisi magna, hendrerit at consectetur nec, placerat sit amet lectus. Etiam a orci et nibh porttitor suscipit. Quisque quis congue ligula. In sed augue dolor. Maecenas malesuada quam tempus nulla sagittis nec tincidunt velit eleifend. Proin auctor, felis ut rutrum facilisis, odio odio pretium ipsum, vitae hendrerit nisi sem eu leo. Nunc tincidunt elit vitae erat commodo euismod. Aliquam id enim ante. Sed mattis felis non urna molestie mollis. Maecenas faucibus interdum dui non dapibus. Integer ut sapien dui, sed pretium libero. Vestibulum condimentum, diam nec ullamcorper bibendum, metus purus commodo turpis, vel posuere erat metus id justo. Quisque lectus mauris, sodales at semper ut, feugiat sed mauris. Maecenas aliquet eros et lectus gravida ac tristique mauris adipiscing. Fusce quis justo ac leo pharetra feugiat. Pellentesque suscipit, urna vel semper tempor, nunc dui volutpat enim, nec facilisis est est non orci. Praesent vestibulum ultrices lectus ut molestie. Integer non dolor dui. Vestibulum varius dolor nec arcu ultricies auctor porta orci sollicitudin. Sed lacus lectus, semper eget sodales a, lacinia ac justo."

CreateImage(#Logo,533,253,24)

If StartDrawing(ImageOutput(#Logo))

                Box(0,0,533,253,RGB(056,180,074))
        StopDrawing()
EndIf

     sFile.s = Str(Date())
   sIrsNbr.s = "000001/2013"
sIRSheader.s = "Relatório de Assistência nº: " + sIrsNbr
      sOPT.s = "ORIENTATION = " + Str(#DMORIENT_PORTRAIT) + ", "
      sOPT + "PAPERSIZE = " + Str(#DMPAPER_A4)

;UsePNGImageDecoder()
;LoadImage(#logo, "AFVCR - logo IRS.png")

Print_SetDebug(#True)

If Print_OpenPrinter(Print_GetDefaultPrinter(), sOPT)

      Print_SetUnits(#PRINT_MM)
      Debug Print_GetDeviceCaps(#HORZSIZE)        ;Paper Width in mm
      Debug Print_GetDeviceCaps(#VERTSIZE)        ;Paper Height in mm
      Debug Print_GetDeviceCaps(#PHYSICALWIDTH)   ;Paper Width in printer units (mm 10ths)
      Debug Print_GetDeviceCaps(#PHYSICALHEIGHT)  ;Paper Height in printer units (mm 10ths)
      Debug Print_GetDeviceCaps(#PHYSICALOFFSETX) ;Paper Left Margin in printer units (mm 10ths)
      Debug Print_GetDeviceCaps(#PHYSICALOFFSETY) ;Paper Top Margin in printer units (mm 10ths)

      Print_StartPrinting(sFile)
      Print_Image(#Logo, 20, 10, 141, 67)
      Print_Font("trebuchet ms", 12, #PB_Font_Bold)
      Print_SetTextColor(#Black)
      ;Calc Rectangle to fit text
      Print_DrawText(25, 62, 175, 0, sInterventionTxt, #DT_WORDBREAK|#DT_CALCRECT, *RX, *RY, *RW, *RH)
      ;Print the text in the calculated rectangle
      Print_DrawText(25, 62, 175, PeekF(*RH), sInterventionTxt, #DT_WORDBREAK)

      Print_SetLineColor(#Red)              ;<-- 
      Print_Box(25, 62, 175,PeekF(*RH)) ;<-- Added lines to see that text is good fit in box

      Print_Text(100, 10, sIRSheader)
      Print_Font("trebuchet ms", 8)
      Print_Text(20, 30, sIRSheader)
      Print_Line(20, 40, 180, 0)
      Print_StopPrinting()
Else
      MessageRequester("", "no printer available")
EndIf 
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: Printer_Lib

Post by ClueLess »

Thank You. I manage to make it work with the help of the exemple 8. I wish it was simplier, or it had a better help.

Thank You for your help and patience
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Printer_Lib

Post by IdeasVacuum »

Well, printing is PB's biggest weakness in my opinion. Printer_Lib is pretty good once you get your head around it, but it is of course Windows only. I wish the lib's functionality could become part of PB, that would be Utopia 8)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: Printer_Lib

Post by ClueLess »

lets wait for rel 10. It may have the printing solved. ;-)
Post Reply