Page 1 of 1

printing constants

Posted: Sun Feb 23, 2020 3:28 pm
by plantenkennis
Hello,

I am working on a routine where the user can design his own prints. While testing some things I saw the next strange behaviors:
  • When I set the oPrn:setPaperName("A4") and ask the GetPrintableWidth() and GetPrintableHeight() I get values like 576 and 813.
    When I set the oPrn:setPaperName("A3") and ask the GetPrintableWidth() and GetPrintableHeight() I get values like 559 and 783, which is smaller than on A4.
    When I look at System Preferences and than Printers/scanners I can change the prefered papersize from A4 to A3 When I then ask the GetPrintableWidth() and GetPrintableHeight() I get values like 806 and 1155, which seems more correct
Question: how can i check which prefered papersize is active on the users computer. Or how do I get the right values on every computer.

Futhermore, how can I print an image borderless. Now I have set:
oPrn:SetLeftMargin(0)
oPrn:SetRightMargin(0)
oPrn:SetTopMargin(0)
oPrn:SetbottomMargin(0)
But when I start an image at 0,0 and width and height on GetPrintableWidth() and GetPrintableHeight() the image is not at the edge of the paper. I can't change this in the printer menu, aspecialy as I save the print as pdf.

Re: printing constants

Posted: Mon Feb 24, 2020 10:37 am
by Antonio Linares
Dear René,

FiveMac uses a NSPrintInfo object to manage the printer:

https://developer.apple.com/documentati ... sprintinfo

FiveMac code:
https://github.com/FiveTechSoft/fivemac ... printers.m

Here you have all the methods that the class provides, maybe another method may help you better with what you need:

https://github.com/adobe-flash/crossbri ... rintInfo.m

Re: printing constants

Posted: Mon Feb 24, 2020 11:37 am
by mastintin
Change this function in printers.m :

Code: Select all


HB_FUNC( PRNSETPAPERNAME ) 
{
 NSString * string = hb_NSSTRING_par( 2 );
 NSPrintInfo * pi = ( NSPrintInfo *  ) hb_parnl( 1 );
  
 [ [pi dictionary] setObject: string forKey: NSPrintPaperName];
// FIXME: Should this change the orientation?
 [ [ pi dictionary] setObject: [ NSValue valueWithSize:
                                  [NSPrintInfo sizeForPaperName: string ]] forKey: NSPrintPaperSize];
    
    
// [ pi setPaperName : string ] ;
    
}

 
code test :

Code: Select all

   oprn:setPaperName("A5")
   
   ?  nHeight := oPrn:GetPrintableHeight()
   ?  nWidth  := oPrn:GetPrintableWidth()
   
   oprn:setPaperName("A3")
   
   ?  nHeight := oPrn:GetPrintableHeight()
   ?  nWidth  := oPrn:GetPrintableWidth()
   
   oprn:setPaperName("A4")
   
   ?  nHeight := oPrn:GetPrintableHeight()
   ?  nWidth  := oPrn:GetPrintableWidth()

 
my result :
a5->550x 401
a3->1190x842
a4->797x577

Re: printing constants

Posted: Tue Feb 25, 2020 6:05 am
by plantenkennis
Hello Antonio and Manuel,

thank you for your reply. Do I need a new lib for this, because I have replaced the function in printers.m but now get the next results:
A5 > 566 400
A3 > 566 400
A4 > 813 576

So it seems in my case the A3 size does not work properly?

And your printsizes are different than mine, so it is printer dependent. How to set printing borderless?