Printer_Lib

Just starting out? Need help? Post your questions and find answers here.
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: Printer_Lib

Post by ClueLess »

The log file is only needed in case of problems anyway... Any location will be good as long we know where it is
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: Printer_Lib

Post by ABBKlaus »

The logfile is created in the current directory.

For the Logfile you have posted i have found that the command returns 0 = not successfull !

Code: Select all

StretchBlt_(-618589115,472,236,3331,1583,-1878980415,0,0,141,67,13369376)=0
Maybe its your PDF-Printer, mine here is working nicely :

Code: Select all

Printer-Lib Version V1.10
PureBasic Version 520
Printer : PDF-XChange Printer 2012
OpenPrinter_()=1
Print_SetTextAlign(0)
SetTextAlign_(5E216176,0)=0
Print_SetBkMode(1)
SetBkMode_(5E216176,1)=2
Print_SetLineColor(0)
Print_CreatePen(12200,0,0,0,0)
ExtCreatePen_(12200,2,18FEF8,0,0)=4E506432
Print_CreateBrush(0)
CreateSolidBrush_(0)=C510467B
Print_CreatePen(12200,0,0,0,0)
ExtCreatePen_(12200,2,18FF00,0,0)=EB5016A6
ipprint_Image(0,20,10,141,67,13369376)
IsImage(0)=32338848
UseImage(0)=-1140505175
GetDeviceCaps_()=#RC_BITBLT,#RC_BITMAP64,#RC_DI_BITMAP,#RC_DIBTODEV,#RC_STRETCHBLT,#RC_STRETCHDIB
ImageWidth=533
ImageHeight=253
ImageDepth=32
Using #RC_STRETCHBLT method
CreateCompatibleDC_(0)=453075751
SelectObject_(453075751,-1140505175)=25493519
StretchBlt_(1579245942,236,118,1665,791,453075751,0,0,533,253,13369376)=1
ipprint_Line(20,40,200,40)
LineTo_()=1
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: Printer_Lib

Post by ClueLess »

It is CutePDf which works fine with all my other printing
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, back to basics - Clueless, can you run my code and tell us the result?
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 »

Also, there seems to be a mis-match in image size in your code. From the log:
ipprint_Image(0,20,10,141,67,13369376) = 141mm x 67mm
ImageWidth=141 pix = 37.31mm
ImageHeight=67 pix = 17.73mm

So, it looks like you are asking the lib to stretch a 37mm image to 141mm?
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 »

... I have tested CutePDF with my code example and it works fine here.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: Printer_Lib

Post by ABBKlaus »

If GetDeviceCaps(DC,#TECHNOLOGY) function returns DT_METAFILE that would explain the failure.

If not we need that image fortesting :wink:
MSDN wrote:Remarks
StretchBlt stretches or compresses the source bitmap in memory and then copies the result to the destination rectangle. This bitmap can be either a compatible bitmap (DDB) or the output from CreateDIBSection. The color data for pattern or destination pixels is merged after the stretching or compression occurs.
When an enhanced metafile is being recorded, an error occurs (and the function returns FALSE) if the source device context identifies an enhanced-metafile device context.
If the specified raster operation requires a brush, the system uses the brush currently selected into the destination device context.
The destination coordinates are transformed by using the transformation currently specified for the destination device context; the source coordinates are transformed by using the transformation currently specified for the source device context.
If the source transformation has a rotation or shear, an error occurs.
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: Printer_Lib

Post by ClueLess »

Just ploaded and installed another PDF printer. Same result in the log:

Code: Select all

Printer-Lib Version V1.10
PureBasic Version 520
Printer : doPDF v7
OpenPrinter_()=1
Print_SetTextAlign(0)
SetTextAlign_(56211922,0)=0
Print_SetBkMode(1)
SetBkMode_(56211922,1)=2
Print_SetLineColor(0)
Print_CreatePen(12200,0,0,0,0)
ExtCreatePen_(12200,2,13FF00,0,0)=40500E28
Print_CreateBrush(0)
CreateSolidBrush_(0)=BC10062C
Print_CreatePen(12200,0,0,0,0)
ExtCreatePen_(12200,2,13FF08,0,0)=3C5013D3
ipprint_Image(0,20,10,141,67,13369376)
IsImage(0)=19461824
UseImage(0)=-989524775
GetDeviceCaps_()=#RC_BITBLT,#RC_BITMAP64,#RC_DI_BITMAP,#RC_DIBTODEV,#RC_STRETCHBLT,#RC_STRETCHDIB
ImageWidth=141
ImageHeight=67
ImageDepth=32
Using #RC_STRETCHBLT method
CreateCompatibleDC_(0)=1090588200
SelectObject_(1090588200,-989524775)=25493519
StretchBlt_(1445009698,236,118,1665,791,1090588200,0,0,141,67,13369376)=0
ipprint_Line(20,40,200,40)
LineTo_()=1
This doesn't seem a printer problema. Tell me what do you want me to do /test and I will do it
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: Printer_Lib

Post by ClueLess »

Just changed the image size:

Code: Select all

Enumeration
  #logo
EndEnumeration

IrsNbr.s = "000001/2013"
IRSheader.s = "Relatório de Assistência nº: " + IrsNbr.s

OPT$ = "ORIENTATION = " + Str(#DMORIENT_PORTRAIT) + ", "
OPT$ + "PAPERSIZE = " + Str(#DMPAPER_A4)

Print_SetDebug(#True)

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

If Print_OpenPrinter(Print_GetDefaultPrinter(), OPT$)
  Print_Image(#logo, 20, 10, 37, 17)
  Print_StartPrinting(IrsNbr.s)
  Print_Font("trebuchet ms", 12, #PB_Font_Bold)
  Print_SetTextColor(#Black)
  Print_Text(100, 10, IRSheader.s)
  Print_Font("trebuchet ms", 8)
  Print_Text(20, 30, IRSheader.s)
  Print_Line(20, 40, 180, 0)
  Print_StopPrinting()
Else
 MessageRequester("", "no printer available")
EndIf 
no printing
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: Printer_Lib

Post by ClueLess »

How can I attach a file to a posting so I can attach the picuture?
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 »

Upload to a webserver, then use "[img]Http..myImage[/img]" (without the speech marks)
However, first test is to run my stand-alone code on your PC and let us know the result. :wink:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: Printer_Lib

Post by ABBKlaus »

and please put that Print_Image() inside the StartPrinting() StopPrinting() block !!!

Code: Select all

Enumeration
  #logo
EndEnumeration

IrsNbr.s = "000001/2013"
IRSheader.s = "Relatório de Assistência nº: " + IrsNbr.s

OPT$ = "ORIENTATION = " + Str(#DMORIENT_PORTRAIT) + ", "
OPT$ + "PAPERSIZE = " + Str(#DMPAPER_A4)

Print_SetDebug(#True)

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

If Print_OpenPrinter(Print_GetDefaultPrinter(), OPT$)
  ;Print_Image(#logo, 20, 10, 37, 17) ; < - Wrong / will be ignored and not printed !!!
  If Print_StartPrinting(IrsNbr.s)
    Print_Image(#logo, 20, 10, 37, 17) ; < - Belongs here
    Print_Font("trebuchet ms", 12, #PB_Font_Bold)
    Print_SetTextColor(#Black)
    Print_Text(100, 10, IRSheader.s)
    Print_Font("trebuchet ms", 8)
    Print_Text(20, 30, IRSheader.s)
    Print_Line(20, 40, 180, 0)
    Print_StopPrinting()
  EndIf
Else
 MessageRequester("", "no printer available")
EndIf 


ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: Printer_Lib

Post by ClueLess »

Found the problema. So simple...
Enumeration
#logo
EndEnumeration

IrsNbr.s = "000002/2013"
IRSheader.s = "Relatório de Assistência nº: " + IrsNbr.s

OPT$ = "ORIENTATION = " + Str(#DMORIENT_PORTRAIT) + ", "
OPT$ + "PAPERSIZE = " + Str(#DMPAPER_A4)

Print_SetDebug(#True)

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

If Print_OpenPrinter(Print_GetDefaultPrinter(), OPT$)
Print_StartPrinting(IrsNbr.s) < -- This line was after the print image command
Print_Image(#logo, 20, 10, 37, 17)
Print_Font("trebuchet ms", 12, #PB_Font_Bold)
Print_SetTextColor(#Black)
Print_Text(100, 10, IRSheader.s)
Print_Font("trebuchet ms", 8)
Print_Text(20, 30, IRSheader.s)
Print_Line(20, 40, 180, 0)
Print_StopPrinting()
Else
MessageRequester("", "no printer available")
EndIf
Thank You guys... For now
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 »

We found that typo yesterday..........
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 »

did not see any mention to that... Anyway it is working...
One Question...
Is there any way to make the text wrap in a line?
Post Reply