How can I read and set the paper style (aka papername) in Firemonkey MacOS

  

Working in Delphi Firemonkey for Mac OS64.

Trying to read and then set the variable Apple calls the “paperName”, which is the paper type (letter, legal, envelope, etc.) I know that it is accessed through NSPrinter.PaperName? but I do not understand how to code FMX to access it.

I’m using cookbooked code to get the paper rectangle:

FPrintInfo := TNSPrintInfo.Wrap(TNSPrintInfo.OCClass.sharedPrintInfo);
FPrintInfo.retain;
PMGetAdjustedPaperRect(FPrintInfo.PMPageFormat, @PaperRect);
FPrintInfo.release;

but I’m not experienced at all with Mac code so my attempts to plug-and-play off of this code to get papername have not been successful.

Thanks for your help.

Dave,

Thanks. Sorry, I didn’t really give you enough info. The code I provided does work, to get the paper rectangle.

What I am trying to get, in addition, is the paper name, and I can’t figure out what function will get me that.

I’m trying to use PMGetPageFormatPaper(FPrintInfo.PMPageFormat, @PaperTypeS); but I think I may not be declaring PaperTypeS correctly.

What I’m trying is:

function getPaperShape: string;
var
FPrintInfo: NSPrintInfo;
PaperRect: PMRect;
paperwidth,paperheight:double;
paperTypeS:string;
begin
FPrintInfo := TNSPrintInfo.Wrap(TNSPrintInfo.OCClass.sharedPrintInfo);
FPrintInfo.retain;
PMGetAdjustedPaperRect(FPrintInfo.PMPageFormat, @PaperRect);
PMGetPageFormatPaper(FPrintInfo.PMPageFormat, @PaperTypeS);
FPrintInfo.release;
paperwidth:= PaperRect.right-PaperRect.left;
paperheight:= PaperRect.bottom-PaperRect.top;
end;

That clearly is not correct, since I get nothing returned in paperTypeS. I’ve tried declaring paperTypeS as NSPrinter.PaperName, or just as PaperName, or as PMPaperName, but clearly I’m just guessing here and none of those are recognized by FMX as valid types.

Does that make more sense?

Again, thanks.

Scott

Comments are closed.