PrintSetup.CurrentPrintSetting versus PrintSetup.InSession?

PrintSetup.CurrentPrintSetting versus PrintSetup.InSession?

nbrooksFL6XX
Participant Participant
2,522 Views
8 Replies
Message 1 of 9

PrintSetup.CurrentPrintSetting versus PrintSetup.InSession?

nbrooksFL6XX
Participant
Participant

I don't understand what it means for the PrintSetup to be InSession   versus   CurrentPrintSetting.   Can anyone explain what InSession means?

 

I'm trying to print a pdf of size 32x42 inches from my code.  If the default printer on my computer is set to anything other than my default PDF printer (under Devices and Printers  in the Control Panel), I get an error when I try to set the paper size in my code. 

The error say: "Illegal paper size"  and mentions the problem is with "Parameter name: ps".   If my default printer is set to Bluebeam (my PDF printer), then my code works fine and every pdf will print the first time.  But if the default is another printer, it fails the first time through.

 

Worth noting, when my print-to-pdf command fails on the first try, I can select my Print Pdf button from the Ribbon again and it will work from then on.  Something about failing that first attempt at running the command, seems to be setting internal things as they need to be set....when my default printer is not set to Bluebeam. 

 

I have seen help online that stated I needed to assign InSession to CurrentPrintSetting.  I am doing that. 

PrintManager.PrintSetup.CurrentPrintSetting = PrintManager.PrintSetup.InSession;

 

But I don't understand why. What does InSession mean? 

 

 

Any thoughts are appreciated. Thanks for your help!

0 Likes
Accepted solutions (1)
2,523 Views
8 Replies
Replies (8)
Message 2 of 9

RPTHOMAS108
Mentor
Mentor
Accepted solution

InSession is the same thing as it is in the UI: a common placeholder name for settings when the user doesn't want to save the settings under a name.

 

The CurrentPrintSetting property is what is referred to when you submit a print and can be either InSession or PrintSetting (both of which implement IPrintSetting). There is no requirement to set .CurrentprintSetting = PrintManager.PrintSetup.InSession

 

You have to be careful when InSession is current since it can't be renamed or deleted, when you delete a named setting that is current then InSession becomes current.

Message 3 of 9

nbrooksFL6XX
Participant
Participant

RPTHOMAS108 , Thank you so much for your quick response.  Your explanation helped a lot.   I never could find adequate documentation explaining InSession and CurrentPrintSetting in relation to InSession.

 

I believe my code is corrected and working now.  Thank you again!!!

0 Likes
Message 4 of 9

Extraneous
Advisor
Advisor

...but I seem to be stupid. Not understood.
If this "equal" is not required, then how to specify what to print through "in session"? Where to specify the PrintParameters?
I wrote such code, but it does not work:

 

 Document curDoc = sheet.Document;
PrintManager pManager = curDoc.PrintManager;
pManager.SelectNewPrintDriver("PDFCreator");
pManager.PrintRange = PrintRange.Current;
pManager.Apply();

//pManager.PrintSetup.CurrentPrintSetting = pManager.PrintSetup.InSession; //not required??

//InSessionPrintSetting isps = pManager.PrintSetup.InSession; //??
PrintParameters pps = pManager.PrintSetup.CurrentPrintSetting.PrintParameters; //isps.PrintParameters;
PaperSize pSize = SearchPaperSize(pManager, "A2");
pps.PaperSize = pSize;
pps.PaperPlacement = PaperPlacementType.Margins;
pps.MarginType = MarginType.NoMargin;
pps.ZoomType = ZoomType.Zoom;
pps.Zoom = 100;
pps.ColorDepth = ColorDepthType.GrayScale;
pManager.Apply();

//pManager.PrintSetup.CurrentPrintSetting = isps; //I have no idea what I'm writing

pManager.Apply();
pManager.SubmitPrint(sheet);  //it prints as if I didn’t set anything up

 

Alexander Zuev
In BIM we trust
Facebook | Linkedin | Telegram

0 Likes
Message 5 of 9

Extraneous
Advisor
Advisor

Lol, the same bug in the SDK Sample ViewPrinter, print settings are not saved: for example, if you select "setup - <in-session>" and "black lines", color is printed anyway. Nuff said... 

 

P.S. I found a similar discussion, but I have version 2017, is the bug still not fixed?

Alexander Zuev
In BIM we trust
Facebook | Linkedin | Telegram

0 Likes
Message 6 of 9

sonicer
Collaborator
Collaborator

I saw many time Is SDK Is bug. Sometimes Is nothing saved.

Message 7 of 9

Extraneous
Advisor
Advisor

Thanks! At least, it's good that this is a bug in a program, not in my brain Cat Very Happy

Alexander Zuev
In BIM we trust
Facebook | Linkedin | Telegram

0 Likes
Message 8 of 9

Archigrafix_Norge
Advocate
Advocate

Does it print black if it is not in-session? Or does it always print colour?


Luis Santos

archi systems as

0 Likes
Message 9 of 9

stephen_harrison
Advocate
Advocate

Just reading through this post with interest as I am working on a small print application and looking to retrieve the Print Setup Print Parameters which I can achieve for all but Insession.

I have been using 

PrintMgr.PrintSetup.CurrentPrintSetting = PrintMgr.PrintSetup.InSession;

but this is not returning the correct data.

In this post it states "There is no requirement to set .CurrentprintSetting = PrintManager.PrintSetup.InSession" if this is the case how do you set the PrintSetup to InSession?

0 Likes