Hi Thomas,
thanks for the suggestion...
It is Actually a Three Page Report... Where the content is predefined as to what content comes in which page...
There is no problem for the first page... but 2nd may spill over to 3rd and/or 3rd may spill over to 4th...
Suppose if I have to use GetDocumentObjectsFromPage(), then content must already be written to page...
For Ex: my code is somewhat like this....
Code:
void GenPDF()
{
Document document = new Document();
WriteContentPage1(document);
document.LastSection.AddPageBreak();
WriteContentPage2(document);
document.LastSection.AddPageBreak();
WriteContentPage3(document);
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);
renderer.Document = document;
renderer.RenderDocument();
FileStream fStream = new FileStream(Path, FileMode.Create);
renderer.PdfDocument.Save(fStream);
}
void WriteContentPage1(Document document)
{
Section section = document.LastSection;
/*Code to Retrieve Data from DB based on some logic...*/
DataTableReader dtr = dTable.CreateDataReader();
while(dtr.read())
{
section.AddParagraph(dtr[0].ToString());
//Format Code....
}
}
void WriteContentPage2(Document document)
{
Section section = document.LastSection;
/*Code to Retrieve Data from DB based on some logic...*/
DataTableReader dtr = dTable.CreateDataReader();
while(dtr.read())
{
section.AddParagraph(dtr[0].ToString());
//Format Code....
}
}
void WriteContentPage3(Document document)
{
Section section = document.LastSection;
/*Code to Retrieve Data from DB based on some logic...*/
DataTableReader dtr = dTable.CreateDataReader();
while(dtr.read())
{
section.AddParagraph(dtr[0].ToString());
//Format Code....
}
}
If i have to use GetDocumentObjectsFromPage() and change the Content size then i may have to use some thing like this
Code:
void GenPDF()
{
Document document = new Document();
WriteContentPage1(document);
document.LastSection.AddPageBreak();
WriteContentPage2(document,false);
[b]DocumentRenderer docRenderer = new DocumentRenderer(document);
docRenderer.PrepareDocument();
DocumentObject[] docObj = docRenderer.GetDocumentObjectsFromPage(2);
if(docObj.Length>0)
{
WriteContentPage2(document,true);
}[/b]
document.LastSection.AddPageBreak();
WriteContentPage3(document, false);
[b]DocumentRenderer docRenderer = new DocumentRenderer(document);
docRenderer.PrepareDocument();
DocumentObject[] docObj = docRenderer.GetDocumentObjectsFromPage(2);
if(docObj.Length>0)
{
WriteContentPage3(document,true);
}[/b]
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);
renderer.Document = document;
renderer.RenderDocument();
FileStream fStream = new FileStream(Path, FileMode.Create);
renderer.PdfDocument.Save(fStream);
}
void WriteContentPage2(Document document,bool bChange)
{
if(bChange)
{
Section section = document.LastSection;
/*Code to Remove Last specific content*/
/*Code to Get Resized Data from DB based on some logic...*/
DataTableReader dtr = dTable.CreateDataReader();
while(dtr.read())
{
section.AddParagraph(dtr[0].ToString());
//Re-Format Code to adjust the content in page....
}
}
else
{
Section section = document.LastSection;
DataTableReader dtr = dTable.CreateDataReader();
while(dtr.read())
{
section.AddParagraph(dtr[0].ToString());
//Format Code....
}
}
}
//WriteContentPage3() // same as page2
To change the Content Size,i have to get new resized content from DB and Rewrite the content by deleting the previous content...
Is there any way to delete and insert the specific page or content...
thanks in advance....
Seshagiri