Print preview

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Print preview

Post by roman » 29 Nov 2012, 14:46

Hi,

I just encountered another interesting situation:
(Using the CADEDITOR Demo / 8.1)

1) Trying to print a drawing the Custom Print Preview seems to change the drawing. The page dimensions seem to be changed?
2) I'm Trying to add a Footer to the print output with drawing it on the Printpage Event into the graphics part (Code below.) I can't get the real dimensions of the page when using the Custom Print Dialog, With the normal dialog it's working, but I can't print the whole Image...

My Test Code:

Code: Select all

private void miPrintPreview_Click(object sender, System.EventArgs e)
        {
            //this.DoExtentsForPrint();
            //this.prtForm.TypePage = CADImport.Printing.DrawingSize.Fit;
            //prtForm.VisibleRectangle = ImageRectangleF;		
            //printPrevDlg.Document = prtForm.Print(false);	
            //printPrevDlg.ShowDialog();
            //if(printPrevDlg.Document != null)
            //    printPrevDlg.Document.Dispose();
            printPrevDlg.Document = cadImage.Print(false, false, null);
            printPrevDlg.Document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDocument_PrintPage);
            try
            {
                printPrevDlg.ShowDialog();
            }
            catch (Exception e1)
            {
                MessageBox.Show(string.Format("{0}", e1.Message), "CADImport Net", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            if (printPrevDlg.Document != null)
                printPrevDlg.Document.Dispose();
        }

        private void miPrintCustom_Click(object sender, System.EventArgs e)
        {							
            DoExtentsForPrint();
            prtForm.PrintDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDocument_PrintPage); 
            prtForm.ShowDialog();
             
  		  
        }

        void PrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            e.Graphics.DrawRectangle(Pens.Red, e.MarginBounds);
            Rectangle rect = new Rectangle(e.MarginBounds.Left, e.MarginBounds.Bottom - 100, e.MarginBounds.Width, 100);
            e.Graphics.FillRectangle(Brushes.Gray, rect);
        }
wat's wrong with my code?

thank you
Roman

roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Re: Print preview

Post by roman » 04 Dec 2012, 12:42

???

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

Re: Print preview

Post by support » 06 Dec 2012, 18:46

Hello.
Custom Print Preview doesn't change a drawing but visualizes it with some scale value. The scale depends on "Drawing Settings -> Scale" factor set. However PrintDocument_PrintPage method doesn't take the scale into account. So your rectangle will be drawn as planned if Scale factor set to 1:1 only. The scale value doesn't accessible from API, so the code not applicable in common.
IMHO footer must be embedded to page which means that the page content will be drifted. If so, drawing to Graphics does nothing.

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

roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Re: Print preview

Post by roman » 10 Dec 2012, 11:54

Hi,

I should add a Footer to each drawing. How would you suggest adding a footer to drawing (landscape an protrait format)?

Thank you
Roman

roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Re: Print preview - Answer missing!

Post by roman » 16 Jan 2013, 14:28

Are there no possibilities? No answer to my post?????

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

Re: Print preview

Post by support » 16 Jan 2013, 19:20

Hello Roman.
CAD Import .NET doesn't provide "Footers" feature as a default tool. Footers can be realized as parts of a drawing using the current library version. We can also consider implementing access to the scale factor from API. This will allow correct drawing on PrintPageEventArgs.Graphics. Please specify more detailed that kind of data required within a footer for your task.

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

roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Re: Print preview

Post by roman » 16 Jan 2013, 19:35

Hello Alexander,

the only thin I'd need is a footer on the printing of the drawing (company name and logo).

I tried to add the footer using the graphics object from the printpage. Here i was able to add a picture, but there are differences with the "print preview" and the "custom print preview".
Using the "print preview" I was able to add a drawing, but I'm missing the extended features (scaling of the drawing e.g.).
When I tried to use the "custom print preview" the added drawing was not added correctly (side / with ratio was wrong) and even stranger the drawing seems to be rescaled when the graphics object was accessed. A simple rectangle was rescaled, but the ratio did also change(!?).

So what would you suggest me to do to add a footer to the printing, is there a code example how this can be done?

Thank you
Roman

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

Re: Print preview

Post by support » 31 Jan 2013, 18:09

Hello Roman.
The footer can be realized as a part of drawing as we mentioned. In this case a developer must calculate drawing extents to page sizes ratio then add correspond entities on a drawing taking the ratio into account. The added entities must be removed after printing or two different CADImage objects used.
This approach is objectionable in our opinion and the required code snippet is cumbersome. The method you have tried to realize is more acceptable.
We have discussed this situation and decided to add programmatic access to scale value of a PrintingForm object. We will try to provide you with the new library version at close time.

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

roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Re: Print preview

Post by roman » 04 Feb 2013, 18:08

Hello Alexander,

is it possible to tell me a more specific date so we can tell our customer when we can go on.

thank you
Roman

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

Re: Print preview

Post by support » 05 Feb 2013, 17:49

Hello Roman.
We have added programmatic access to scale factor that defined in "Drawing Settings -> Scale" groupbox of PrintingForm. Please check your e-mail box for instructions to receive the modified library version.
PrintingForm.Scale value must be taken into account within PrintDocument_PrintPage method. A footer must be embedded to page visually as we believe. This means the page content will be drifted. You can use page margins for example to avoid overlaying drawing content with graphics:

Code: Select all

  prtForm.PrintDocument.DefaultPageSettings.Margins = new Margins(left, right, top, bottom);
  prtForm.PrintDocument.OriginAtMargins = true;
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply