printing constants

Post Reply
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

printing constants

Post 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.
Kind regards,

René Koot
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: printing constants

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
mastintin
Posts: 1502
Joined: Thu May 27, 2010 2:06 pm

Re: printing constants

Post 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
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Re: printing constants

Post 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?
Kind regards,

René Koot
Post Reply