ReportViewer печатает букву размером в одну страницу, но когда я печатаю, это на двух страницах - PullRequest
0 голосов
/ 04 июля 2018

Я использую vs2017, C #, asp.net 4.6.1 и Rdlc 14.2 на сайте web.forms

У меня есть одностраничный отчет, когда я отправляю его непосредственно в pdf, на одной странице

        ReportViewer1.DataBind();

        Microsoft.Reporting.WebForms.Warning[] warnings;
        string[] streamids;
        string mimeType;
        string encoding;
        string extension;

        string deviceInfo = "<DeviceInfo>" +
                                           "  <OutputFormat>PDF</OutputFormat>" +
                                           "  <PageWidth>8.5in</PageWidth>" +
                                           "  <PageHeight>11in</PageHeight>" +
                                           "  <MarginTop>0.5in</MarginTop>" +
                                           "  <MarginLeft>0.25in</MarginLeft>" +
                                           "  <MarginRight>0.25in</MarginRight>" +
                                           "  <MarginBottom>1in</MarginBottom>" +
                                           "</DeviceInfo>";
        byte[] writeBinaryBytes = new byte[0];
        writeBinaryBytes = ReportViewer1.LocalReport.Render
            ("Pdf", deviceInfo, out mimeType, out encoding, out extension,
            out streamids, out warnings);

        HttpContext.Current.Response.Buffer = true;
        HttpContext.Current.Response.AddHeader
    ("content-disposition", "attachment; filename=" + nombreReporte+".pdf");
        HttpContext.Current.Response.ContentType = "application/octet-stream";
        HttpContext.Current.Response.BinaryWrite(writeBinaryBytes);
        HttpContext.Current.Response.Flush();

Когда я просматриваю его в ReportViewer, он находится на одной странице, но если я экспортирую его в PDF или распечатываю, он находится на двух страницах ... Это мой код перед печатью

        System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
        pg.Margins.Top = 50;        //hundredths of an inch 0.5" * 100
        pg.Margins.Left = 25;       //hundredths of an inch 0.25" * 100
        pg.Margins.Right = 25;      //hundredths of an inch 0.25" * 100
        pg.Margins.Bottom = 100;    //hundredths of an inch 1" * 100
        System.Drawing.Printing.PaperSize size = new PaperSize
        {
            RawKind = (int)PaperKind.Letter
            //hundredths of an inch
            , Width = 850       //hundredths of an inch 8.5" * 100
            , Height = 1100     //hundredths of an inch 11" * 100
        };
    pg.PaperSize = size;
        pg.Landscape = false;
        //pg.PaperSource.RawKind = (int)PaperKind.A5;
        ReportViewer1.SetPageSettings(pg);
        ReportViewer1.LocalReport.Refresh();

Это элемент управления ReportViewer на странице aspx:

            <rsweb:ReportViewer ID="ReportViewer1" runat="server" 
                ShowToolBar="true" 
                ShowFindControls ="false"
                ShowCredentialPrompts="true"
                ShowDocumentMapButton="true"
                EnableEventValidation="fase" 
                AsyncRendering = "false"
                width="100%" />

Есть предложения?

Спасибо rubenc

1 Ответ

0 голосов
/ 05 июля 2018

Ну, оказалось, что проблема была в том, что у меня были установлены поля в отчете RDLC, я просто изменил их на 0, и теперь он работает.

...