Hi Team,
I am using asp.net webforms.
I want to generate pdf from scratch.
pdf pages size should be A4.
and based on content length i need to generate multiple pages in the PDF.
I am using below code.
protected
void
btn2_Click(
object
sender, EventArgs e)
{
List<
string
> contents =
new
List<
string
>();
contents.Add(
"is a document processing library that enables your application to "
+
"import and export files to and from PDF format. The document model is "
+
"entirely independent from UI and allows you to generate sleek documents "
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"is a document processing library that enables your application to "
+
"import and export files to and from PDF format. The document model is "
+
"entirely independent from UI and allows you to generate sleek documents "
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"is a document processing library that enables your application to "
+
"import and export files to and from PDF format. The document model is "
+
"entirely"
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"is a document processing library that enables your application to "
+
"import and export files to and from PDF format. "
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"The document model is "
+
"entirely independent from UI and allows you to generate sleek documents "
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"is a application to "
+
"import and export files to and from PDF format. The document model is "
+
"entirely independent from UI and allows "
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"The document model is111 "
+
"entirely independent from UI and allows you to generate sleek documents "
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"The document model is222 "
+
"entirely independent from UI and allows you to generate sleek documents "
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"The document model is "
+
"entirely independent from UI and allows you to generate sleek documents "
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"The document model is "
+
"entirely independent from UI and allows you to generate sleek documents "
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"The document model is "
+
"entirely independent from UI and allows you to generate sleek documents "
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"The document model is "
+
"entirely independent from UI and allows you to generate sleek documents "
+
"with differently formatted text, images, shapes and more."
);
contents.Add(
"The document model is "
+
"entirely independent from UI and allows you to generate sleek documents "
+
"with differently formatted text, images, shapes and more."
);
var document =
new
RadFixedDocument();
var page = document.Pages.AddPage();
FixedContentEditor editor =
new
FixedContentEditor(page);
var x = 50;
var y = 50;
foreach
(var item
in
contents)
{
editor.Position.Translate(x, y);
//Start Position(x,y)
Block block =
new
Block();
block.GraphicProperties.FillColor = RgbColors.Black;
block.HorizontalAlignment = HorizontalAlignment.Left;
block.TextProperties.Font = FontsRepository.HelveticaBoldOblique;
block.TextProperties.FontSize = 20;
block.InsertText(
"RadPdfProcessing"
);
block.TextProperties.Font = FontsRepository.Helvetica;
block.TextProperties.FontSize = 20;
block.InsertText(item);
editor.DrawBlock(block,
new
System.Windows.Size(700,
double
.PositiveInfinity));
//x = x + 50;
// y = y + 150;
}
var pdfProvider =
new
PdfFormatProvider();
byte
[] renderedBytes =
null
;
using
(MemoryStream ms =
new
MemoryStream())
{
pdfProvider.Export(document, ms);
renderedBytes = ms.ToArray();
}
Response.Clear();
Response.AppendHeader(
"Content-Disposition:"
,
"attachment; filename=PdfDocument.pdf"
);
Response.ContentType =
"application/pdf"
;
Response.BinaryWrite(renderedBytes);
Response.End();
}
but the above code generating only single page.
how can i generate multiple pages based on content. and provide me any examples.