Hi all,
I'm using RadPdfProcessing for ASP.NET MVC to create pdf template for financial documents. Sometimes content of some tables can be various length. In this case I'd like to move lower blocks/tables to a new page and generate pdf document with two pages. I'm using RadFixedDocument and FixedContentEditor to create tables/blocks on the document. Piece of ode below:
public
static
RadFixedDocument CreateDocument()
{
RadFixedDocument document =
new
RadFixedDocument();
RadFixedPage page =
new
RadFixedPage();
page.Size =
new
Size(600, 750);
FixedContentEditor editor =
new
FixedContentEditor(page);
document.Pages.Add(page);
editor.Position.Translate(defaultLeftIndent + 330, defaultTopIndent);
DrawTable(editor, maxWidth);
editor.Position.Translate(defaultLeftIndent, defaultTopIndent + 70);
DrawTitle(editor, maxWidth);
editor.Position.Translate(defaultLeftIndent, defaultTopIndent + 110);
DrawTableWithDetails(editor, maxWidth);
editor.Position.Translate(defaultLeftIndent, defaultTopIndent + 220);
DrawReceiverTable(editor, maxWidth);
private
static
void
DrawTable(FixedContentEditor editor,
double
maxWidth)
{
Table table =
new
Table();
table.LayoutType = TableLayoutType.AutoFit;
table.DefaultCellProperties.Padding =
new
Thickness(1);
#region FIRST ROW
TableRow firstRow = table.Rows.AddTableRow();
TableCell firstCell = firstRow.Cells.AddTableCell();
Block firstBlock = firstCell.Blocks.AddBlock();
firstBlock.TextProperties.FontSize = 10;
firstBlock.TextProperties.Font = FontsRepository.Helvetica;
firstBlock.InsertText(
"xxxxxxxxx"
);
TableCell secondCell = firstRow.Cells.AddTableCell();
Block secondBlock = secondCell.Blocks.AddBlock();
secondBlock.TextProperties.FontSize = 10;
secondBlock.TextProperties.Font = FontsRepository.Helvetica;
secondBlock.InsertText(
" xxxxxxxxx"
);
#endregion
editor.DrawTable(table,
new
Size(maxWidth,
double
.PositiveInfinity));
}
private
static
void
DrawTitle(FixedContentEditor editor,
double
maxWidth)
{
Block block =
new
Block();
block.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
block.TextProperties.Font = FontsRepository.HelveticaBold;
block.TextProperties.FontSize = 16;
block.InsertText(
"xxxxxxxxx"
);
block.InsertText(
"<xxxxxxxxx>"
);
editor.DrawBlock(block,
new
Size(maxWidth,
double
.PositiveInfinity));
}
private
static
void
DrawTableWithDetails(FixedContentEditor editor,
double
maxWidth)
{
Table table =
new
Table();
table.LayoutType = TableLayoutType.FixedWidth;
table.DefaultCellProperties.Padding =
new
Thickness(1);
Border border =
new
Border();
Border whiteBorder =
new
Border(0, BorderStyle.None,
new
RgbColor(255, 255, 255));
table.DefaultCellProperties.Borders =
new
TableCellBorders(border, border, border, border);
#region FIRST ROW
TableRow firstRow = table.Rows.AddTableRow();
TableCell firstCell = firstRow.Cells.AddTableCell();
Block firstBlock = firstCell.Blocks.AddBlock();
firstBlock.TextProperties.Font = FontsRepository.HelveticaBold;
firstBlock.InsertText(
"xxxxxxxxx"
);
TableCell secondCell = firstRow.Cells.AddTableCell();
Block secondBlock = secondCell.Blocks.AddBlock();
secondBlock.TextProperties.Font = FontsRepository.HelveticaBold;
secondBlock.InsertText(
"xxxxxxxxx"
);
#endregion
#region SECOND ROW
TableRow secondRow = table.Rows.AddTableRow();
firstCell = secondRow.Cells.AddTableCell();
firstCell.Borders =
new
TableCellBorders(border, border, border, whiteBorder);
firstBlock = firstCell.Blocks.AddBlock();
firstBlock.TextProperties.FontSize = 10;
firstBlock.InsertText(
"xxxxxxxxx"
);
secondCell = secondRow.Cells.AddTableCell();
secondCell.Borders =
new
TableCellBorders(border, border, border, whiteBorder);
secondBlock = secondCell.Blocks.AddBlock();
secondBlock.TextProperties.FontSize = 10;
secondBlock.InsertText(
"xxxxxxxxx"
);
#endregion
editor.DrawTable(table,
new
Size(maxWidth,
double
.PositiveInfinity));
}
private
static
void
DrawReceiverTable(FixedContentEditor editor,
double
maxWidth)
{
Table table =
new
Table();
table.LayoutType = TableLayoutType.FixedWidth;
table.DefaultCellProperties.Padding =
new
Thickness(1);
Border border =
new
Border();
Border whiteBorder =
new
Border(0, BorderStyle.None,
new
RgbColor(255, 255, 255));
table.DefaultCellProperties.Borders =
new
TableCellBorders(border, border, border, border);
#region TABLE CONTENT
TableRow firstRow = table.Rows.AddTableRow();
TableCell firstCell = firstRow.Cells.AddTableCell();
Block firstBlock = firstCell.Blocks.AddBlock();
firstBlock.TextProperties.Font = FontsRepository.HelveticaBold;
firstBlock.InsertText(
"xxxxxxxxx"
);
TableRow secondRow = table.Rows.AddTableRow();
firstCell = secondRow.Cells.AddTableCell();
firstCell.Borders =
new
TableCellBorders(border, border, border, whiteBorder);
firstBlock = firstCell.Blocks.AddBlock();
firstBlock.TextProperties.FontSize = 10;
firstBlock.InsertText(
"xxxxxxxxx"
);
#endregion
editor.DrawBlock(table,
new
Size(maxWidth,
double
.PositiveInfinity));
}
}
I've recently been given the task of turning some labels that we use to put on hardcopy documents into format that can be printed with a small label printer that takes 62mm label tape.
Basically, the user types all the data for the label into a form. I then store the details for them in a grid. When they are ready to print the label, they click a print button that is in my grid. The data for the label is put into a pdf and they print it from the pdf.
The label printer uses a continuous roll or tape so that the text fields can be as long as they want. I'm currently putting all the details into a Table object and then I draw the table with a width of 62mm.
How can I find what the height of the table would be when the width is 62mm so that I can set the height of the page?
public RadFixedDocument CreateDocument()
{
RadFixedDocument document = new RadFixedDocument();
RadFixedPage page = document.Pages.AddPage();
page.Size = new Size(Telerik.Windows.Documents.Media.Unit.MmToDip(62), Telerik.Windows.Documents.Media.Unit.MmToDip(100));
FixedContentEditor editor = new FixedContentEditor(page);
Table table = CreateDetailsTable();
editor.DrawTable(table, Telerik.Windows.Documents.Media.Unit.MmToDip(62));
return document;
}
Hi,
Is there a way to set background for IRowExporter like set color for ICellExporter,seems we only can loop all cells in a row and set one by one now ?
thank you !
currently ,we can set fore color for cell ,like
ICellExporter cellExporter = rowExporter.CreateCellExporter()
var color = System.Drawing.ColorTranslator.FromHtml("#0095ff");
cellExporter.SetFormat(new SpreadCellFormat() { ForeColor = new SpreadThemableColor(new SpreadColor(color.R, color.G, color.B))} );
but how to set background color for cell,i searched API but find nothing,anyone good idea?
thank you
Hello,
I am trying to create Word document from scratch. I prepared a asp.net webforms application and got a System DataTable
How do I insert a table from a datatable using Telerik RadWordsProcessing?
Thank you
First cell of table should not allow wrapping but always does. Does it have anything to do with the fact that I'm using a flow document instead of fixed? There seems to be very little documentation or samples of flow documents.
public
void
Mvce()
{
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider provider =
new
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
RadFlowDocument document =
new
RadFlowDocument();
RadFlowDocumentEditor editor =
new
RadFlowDocumentEditor(document);
Table t = editor.InsertTable();
TableCell cell0 =
new
TableCell(document);
cell0.CanWrapContent =
false
;
//AddBlock() not available??? Its in the documentation:
// https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/editing/tablecell#adding-cell-content
cell0.Blocks.AddParagraph().Inlines.AddRun(
"ClientName:"
);
TableCell cellLong =
new
TableCell(document);
cellLong.Blocks.AddParagraph().Inlines.AddRun(
"Nullam sit amet dui porta, imperdiet quam sit amet, consequat diam. In vel orci rutrum, vehicula purus ullamcorper, ornare lorem. Sed at arcu ultrices, fringilla augue in, condimentum quam. Sed pretium faucibus"
);
var row = t.Rows.AddTableRow();
row.Cells.Add(cell0);
row.Cells.Add(cellLong);
using
(Stream output = File.OpenWrite(
"sample.pdf"
))
{
provider.Export(document, output);
}
Process.Start(
"sample.pdf"
);
}
Hi,
In my MVC project, we used custom-server-side code to export grid data to Excel by utilizing Telerik.Document.SpreadsheedStreaming library. I explore Processing Document and didn’t find any interface related adding filter and frozen row to the sheet. Do I have the way to do the job? Any suggestion will be truly appreciated!
I am trying to print existing pdfs from a database. I am working mainly in asp.net expecting the print to happen on the server. This works for other types of files and I also use Telerik reporting which automatically prints reports on the server. The problem is what do I use to open an existing pdf and then send it to a printer without user interface.