printing constants

printing constants

Postby plantenkennis » Sun Feb 23, 2020 3:28 pm

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
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: printing constants

Postby Antonio Linares » Mon Feb 24, 2020 10:37 am

Dear René,

FiveMac uses a NSPrintInfo object to manage the printer:

https://developer.apple.com/documentation/appkit/nsprintinfo

FiveMac code:
https://github.com/FiveTechSoft/fivemac/blob/23636eb7ad3e9aea7122cd4014fcec076e7e9392/source/winapi/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/crossbridge/blob/master/gnustep/core/gui/Source/NSPrintInfo.m
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: printing constants

Postby mastintin » Mon Feb 24, 2020 11:37 am

Change this function in printers.m :
Code: Select all  Expand view


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  Expand view

   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
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: printing constants

Postby plantenkennis » Tue Feb 25, 2020 6:05 am

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


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 9 guests