Margin don't appear to work

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
SoupMan
Posts: 7
Joined: 05 Jan 2010, 18:30

Margin don't appear to work

Post by SoupMan » 27 May 2011, 00:29

Hi,

Looked at one of the other margin topics on this forum and it helped me understand some things but has not resolved my issue.

Here's the code I use:

Code: Select all

            CADImport.Printing.PrintingForm PF = new CADImport.Printing.PrintingForm();
            System.Drawing.Printing.PaperSize PaperSize = new System.Drawing.Printing.PaperSize();
            PaperSize.RawKind = (int)System.Drawing.Printing.PaperKind.Letter;

            PF.Image = this.cadEditorControl1.Image;
            PF.PrintDocument.DefaultPageSettings.PaperSize = PaperSize;
            PF.PrintDocument.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(120, 0, 0, 0);
            PF.PrintDocument.PrinterSettings.PrinterName = "PrimoPDF";
            PF.TypePage = CADImport.Printing.DrawingSize.Fit;
            PF.Print(true);
No matter what I do with the margins, everything remains the same. I can make the margin 500 and it will still shows the same margins.
If I make PF.Image.IsWithoutMargin = true, then I can't get a margin at all.

What am I missing?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Margin don't appear to work

Post by support » 27 May 2011, 13:24

Hello.
The following string is missed within your code:

Code: Select all

PF.PrintDocument.OriginAtMargins = true;
However setting a margin to a page size that filled completely by drawing when PrintingForm.TypePage = DrawingSize.Fit will result in missing image segment with current library version. Also we recommend to add the following string to avoid possible distortion of printout of some drawings:

Code: Select all

PF.VisibleRectangle = this.ImageRectangleF;
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

SoupMan
Posts: 7
Joined: 05 Jan 2010, 18:30

Re: Margin don't appear to work

Post by SoupMan » 27 May 2011, 20:53

Alexandre,

So you are saying that currently I will experience clipping of the drawing if I use Drawing.Fit with Margins. Instead of me giving snippets of what I'm doing let me tell you my objective:

I want to have a set margin (lets say half an inch all around) and I want the drawing to fit within the remaining space and keep it's aspect ratio (no stretching). Can this be achieved with the current library? If not, will it become available at a later time?

Regarding the last line of code in your last post, what is this.ImageRectangleF? Is it the ImageRectangle of the PrintForm or the one from the CAD Controls?

You guys know your stuff. Thanks for that!

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Margin don't appear to work

Post by support » 30 May 2011, 11:21

Hello.
Your initial snippet related to margins set to PrintingForm object. Using margins with TypePage = DrawingSize.Fit result in clipping if margin set to size that filled completely. We will fix this issue in the future library versions. However you can use margins for CADImage object:

Code: Select all

       cadImage.IsWithoutMargins = false;
       cadImage.BorderType = CADBorderType.Ratio;
       cadImage.BorderSize = 0.125;
Setting CADBorderType.Global defines margins in drawing units.

ImageRectangleF is the structure that represents current size and position of the drawing image. This structure was implemented in demo projects as well as to CADViewer/CADEditor controls.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply