简体   繁体   中英

Bad resolution when print panel from form

My project is to print a panel from form

but the resolution was so terrible

I checked a lot of posts

Knowing that the main problem is DPI difference between monitor and printer

I try to set my bitmap big and print it at right size i want

but it seems i cant set them well

the resolution still bad and the size change like uncontralable

if i set my bitmap size greater then 10k

it will disappear from print preview dialog

my code here

    Bitmap MemoryImage;
    public void GetPrintArea(Panel pnl)
    {

        MemoryImage = new Bitmap(9000,9000);
        Rectangle rect = new Rectangle(0,0,9000,9000);
        pnl.DrawToBitmap(MemoryImage, rect);

    }

    void doc_PrintPage(object sender, PrintPageEventArgs e)
    {
        GetPrintArea(flowLayoutPanel1);
        Rectangle pagearea = new Rectangle(0,0,5000, 5000);
        e.Graphics.DrawImage(MemoryImage,pagearea);
    }

    PrintDocument doc = new PrintDocument();
    private void button1_Click(object sender, EventArgs e)
    {
        PrintDocument doc = new PrintDocument();
        doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
        PrintPreviewDialog dlg = new PrintPreviewDialog();
        PaperSize psize = new PaperSize("A4 300DPI", 2480, 3508);
        doc.PrinterSettings.DefaultPageSettings.PaperSize = psize;
        dlg.Document = doc;
        dlg.ShowDialog();
    }

I want to get panel and print it on A4 with resolution like printing a word document

I spent almost a week try to solve this problem >"<

Plz save me ...

I spent almost a week try to solve this problem

You can't make it to work even if you try another week, because you are on the wrong track.

Knowing that the main problem is DPI difference between monitor and printer

You know the problem and know that there is no solution for that you still keep trying.

Solution: If you want to render some data on report, i don't think printing of panel is the solution. you should consider printing report in the form of a report . Like, consider making an RDLC/Crystal report and put your desired data on that report. In short, use Reports for reporting purpose .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM