PictureBox - List

3 posts, 0 answers
  1. Roger
    Roger avatar
    4 posts
    Member since:
    Aug 2010

    Posted 24 Feb 2012 Link to this post

    Hello,

    I use a PictureBox to display a dynamic loaded Imagelist (Hardcopyscans) of a Document Manegement System.
    Now i need to scale the report automaticaly so it fits the width of the 1st picture in the List.

    But i allways got two pages instead of one, because the reportsize seems to be to small for the image.
    Or, if i scale up the report size, the image wil be shown to small or does some uggly, scaling - that results in unreadable text.

    Also, if i receive a "landscape formated image" the size of the report shuld manage this situation, not cuting off the document in two separate pages.

    Right now i use something like this in the NeedDataSource Handler:

    if (dicFormat["PageSettigs"] == "Landscape") 
        this.Report.PageSettings.Landscape = true;
    else 
        this.Report.PageSettings.Landscape = false;

    SizeU u1 =
    new SizeU(new Unit(lstImage[0].Width, UnitType.Pixel),
    new Unit(lstImage[0].Height, UnitType.Pixel));
    this.Report.PageSettings.PaperSize = u1;

    The content of the image shuld be printed best in 1:1 size.
    Whats the best way to manage this?

  2. Hadib Ahmabi
    Hadib Ahmabi avatar
    181 posts
    Member since:
    Nov 2011

    Posted 24 Feb 2012 Link to this post

    "But i allways got two pages instead of one, because the reportsize seems to be to small for the image." - Have you taken the margins into account? You should subtract the margins in order to get the usable area. 

    About the landscape mode, it seems like you are doing it the right way.

  3. DevCraft Release
  4. Roger
    Roger avatar
    4 posts
    Member since:
    Aug 2010

    Posted 27 Feb 2012 Link to this post

    Thanks for the reply,

    I finally managed it.
    As you thought, the problem was the border of the page.
    I had set them to 0 but, there is an additional border of the page that can't be controlled as it seems.

    The explicit setting of the PictureBox’s size, the subtraction of a constant offset and the scale-configuration of the PictureBox set to "Stretch" solved the problem for me.



    Here the Code:
    double dOffset = 2;
    Unit uWidth = new Unit(29.7 - dOffset, UnitType.Cm); //A4
    Unit uHeight = new Unit(21.0 - dOffset, UnitType.Cm); //A4
     
    SizeU u1 = new SizeU(uWidth, uHeight);
    this.Report.PageSettings.PaperSize = u1;
     
    pictureBox1.Width = uWidth;
    pictureBox1.Height = uHeight;

Back to Top