3

I create the report dynamically, i e, I have no way to open a designer RDLC and fix it. I create a table and fill it through the dataset. Getting XML file and export it to PDF file. But even if I write

string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>PDF</OutputFormat>" +
" <PageWidth>11in</PageWidth>" +
" <PageHeight>8.5.0in</PageHeight>" +
" <MarginTop>0.05in</MarginTop>" +
" <MarginLeft>0.05in</MarginLeft>" +
" <MarginRight>0.05in</MarginRight>" +
" <MarginBottom>0.05in</MarginBottom>" +

" <KeepWithGroup>After</KeepWithGroup>" +
" <RepeatOnNewPage>true</RepeatOnNewPage>" + 
" <FixedData>true</FixedData>"+
 " <RepeatHeaderOnNewPage>true</RepeatHeaderOnNewPage>" +
"</DeviceInfo>";
try
{
 byte[] bytes = reportViewer1.LocalReport.Render(
 "PDF", deviceInfo, out mimeType, out encoding, out filenameExtension,
 out streamids, out warnings);

 using (FileStream fs = new FileStream(filename, FileMode.Create))
 {
 fs.Write(bytes, 0, bytes.Length);
 fs.Close();
 }
 return filename;
 }
 //....

I see the title only on 1 page Help solve the problem! Thanks!

rene
  • 41,474
  • 78
  • 114
  • 152
Irena
  • 111
  • 4
  • I'm still waiting for an answer ... Please help me! – Irena Jun 05 '12 at 04:21
  • Thanks, RoboLover! I am waiting for an answer... – Irena Jun 06 '12 at 08:53
  • Np Irena, try to keep your question active by editing and adding new things you found out by your researches, good luck.I hope you can find a solution. – Bastardo Jun 06 '12 at 10:20
  • I added a new node in the rdlc so – Irena Jun 06 '12 at 10:36
  • //Add new node XmlNode newNode = xDocument.CreateNode("element", "RepeatOnNewPage", "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition"); newNode.InnerText = "true"; xDocument.ChildNodes[1].ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[1].ChildNodes[0].ChildNodes[0].AppendChild(newNode); But now I get an error "An error occurred during local report processing" – Irena Jun 06 '12 at 10:41
  • Add this part to your question Irena. – Bastardo Jun 06 '12 at 11:01
  • hey Irena check this [dynamic table rdlc](http://gotreportviewer.com/DynamicTable.zip) – Bastardo Jun 08 '12 at 06:20
  • Issue has been resolved! Anyone who read my question - thank you! – Irena Jun 11 '12 at 12:29
  • 1
    Well, Irena consider answering your own question with the solution you had, for those who may encounter the same problem. – Bastardo Jun 11 '12 at 12:36
  • ok private Rdl.HeaderType CreateHeader() { Rdl.HeaderType header = new Rdl.HeaderType(); header.Items = new object[] { CreateHeaderTableRows(), true, }; header.ItemsElementName = new Rdl.ItemsChoiceType20[] { Rdl.ItemsChoiceType20.TableRows, Rdl.ItemsChoiceType20.RepeatOnNewPage, }; return header; } – Irena Jun 12 '12 at 05:01
  • (public string ExportReport(string filename) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string filenameExtension; string deviceInfo = "" + " PDF" + " 11in" + " 8.5.0in" + " 0.05in" + " 0.05in" + " 0.05in" + " 0.05in" + ""; – Irena Jun 12 '12 at 05:07
  • try { byte[] bytes = reportViewer1.LocalReport.Render( "PDF", deviceInfo, out mimeType, out encoding, out filenameExtension, //horizontal page out streamids, out warnings); using (FileStream fs = new FileStream(filename, FileMode.Create)) { fs.Write(bytes, 0, bytes.Length); fs.Close(); } return filename; } – Irena Jun 12 '12 at 05:08
  • Can you add those as anwer please, Irena? Not comments. – Bastardo Jun 12 '12 at 06:52

1 Answers1

2
    private Rdl.HeaderType CreateHeader()
    {
        Rdl.HeaderType header = new Rdl.HeaderType();
        header.Items = new object[]
            {
                CreateHeaderTableRows(),
                true,
            };
        header.ItemsElementName = new Rdl.ItemsChoiceType20[]
            {
                Rdl.ItemsChoiceType20.TableRows,
                Rdl.ItemsChoiceType20.RepeatOnNewPage,
            };
        return header;
    }
   //....
    public string ExportReport(string filename)
    {
        Warning[] warnings;
        string[] streamids;
        string mimeType;
        string encoding;
        string filenameExtension;
        string deviceInfo =
             "<DeviceInfo>" +
             " <OutputFormat>PDF</OutputFormat>" +
             " <PageWidth>11in</PageWidth>" +
             " <PageHeight>8.5.0in</PageHeight>" +
             " <MarginTop>0.05in</MarginTop>" +
             " <MarginLeft>0.05in</MarginLeft>" +
             " <MarginRight>0.05in</MarginRight>" +
             " <MarginBottom>0.05in</MarginBottom>" +
             "</DeviceInfo>"; 
        try
        {
            byte[] bytes = reportViewer1.LocalReport.Render(
                "PDF", deviceInfo, out mimeType, out encoding, out filenameExtension,                       out streamids, out warnings);
            using (FileStream fs = new FileStream(filename, FileMode.Create))
            {
                fs.Write(bytes, 0, bytes.Length);
                fs.Close();
            }
            return filename;
        }
        catch (Exception e)
        {
            Program.WriteLogEx.WriterLogErr(e.Message);
            return "";
        }
    }
Bastardo
  • 4,144
  • 9
  • 41
  • 60
Irena
  • 111
  • 4