Hi there,
I have an existing PDF and want to put an image at a certain x and y position and save the result into a new PDF. Is there someone who can provide a sample on how to achieve this?
Thanks in advance!
Hi,
I am adding three tables one after another. Each table has
different number of columns from one to three. I like every table have 100%
width. All cells should have equal width (100% for table where row has one cell,
50% for table with two cells)
Tables gets merged together, instead of three tables I am
getting one table with three rows. Cells gets wrong width. Row with one cell
doesn’t have 100% width.
If I add empty paragraph between tables then all three tables
get 100% width, but I am getting extra row between tables. Please take a look on the attached picture. First three tables get merged into one table with three rows. The rest of the tables have correct formatting but they do have extra row in-between.
Here is code:
private RadFlowDocument CreateDocument()
{
var document = new RadFlowDocument();
var tableStyle = new Style("TableStyle", StyleType.Table)
{
Name = "Table Style No Borders"
};
tableStyle.TableProperties.Borders.LocalValue = new TableBorders(new Border(BorderStyle.Single));
tableStyle.TableProperties.Alignment.LocalValue = Alignment.Left;
tableStyle.TableCellProperties.VerticalAlignment.LocalValue = VerticalAlignment.Top;
document.StyleRepository.Add(tableStyle);
var editor = new RadFlowDocumentEditor(document);
//TABLE 1 WITH 3 CELLS
var table1 = AddTable(tableStyle, editor);
var row1 = AddTableRow(table1, 3);
AddParagraphMoveEditor(editor, row1, 0);
editor.InsertText("LOGO: ").FontWeight = FontWeights.Bold;
AddParagraphMoveEditor(editor, row1, 1);
editor.InsertText("Quotation Detail");
AddParagraphMoveEditor(editor, row1, 2);
editor.InsertText(DateTime.Now.ToString("MMMM d, yyyy h:m"));
editor.MoveToTableEnd(table1);
//TABLE 2 WITH 2 CELLS
var table2 = AddTable(tableStyle, editor);
var row2 = AddTableRow(table2, 2);
AddParagraphMoveEditor(editor, row2, 0);
editor.InsertText("Customer: ").FontWeight = FontWeights.Bold;
AddParagraphMoveEditor(editor, row2, 1);
editor.InsertText("Quotation No: ").FontWeight = FontWeights.Bold;
editor.MoveToTableEnd(table2);
//TABLE 3 WITH 1 CELL
var table3 = AddTable(tableStyle, editor);
var row3 = AddTableRow(table3, 1);
AddParagraphMoveEditor(editor, row3, 0);
editor.InsertText("Location: ").FontWeight = FontWeights.Bold;
editor.InsertText("location goes here");
editor.MoveToTableEnd(table3);
editor.InsertText("");
//TABLE 4 WITH 3 CELLS
var table4 = AddTable(tableStyle, editor);
var row4 = AddTableRow(table4, 3);
AddParagraphMoveEditor(editor, row4, 0);
editor.InsertText("LOGO: ").FontWeight = FontWeights.Bold;
AddParagraphMoveEditor(editor, row4, 1);
editor.InsertText("Quotation Detail");
AddParagraphMoveEditor(editor, row4, 2);
editor.InsertText(DateTime.Now.ToString("MMMM d, yyyy h:m"));
editor.MoveToTableEnd(table4);
editor.InsertText("");
//TABLE 5 WITH 2 CELLS
var table5 = AddTable(tableStyle, editor);
var row5 = AddTableRow(table5, 2);
AddParagraphMoveEditor(editor, row5, 0);
editor.InsertText("Customer: ").FontWeight = FontWeights.Bold;
AddParagraphMoveEditor(editor, row5, 1);
editor.InsertText("Quotation No: ").FontWeight = FontWeights.Bold;
editor.MoveToTableEnd(table5);
editor.InsertText("");
//TABLE 6 WITH 1 CELL
var table6 = AddTable(tableStyle, editor);
var row6 = AddTableRow(table6, 1);
AddParagraphMoveEditor(editor, row6, 0);
editor.InsertText("Location: ").FontWeight = FontWeights.Bold;
editor.InsertText("location goes here");
editor.MoveToTableEnd(table3);
return document;
}
private static Table AddTable(Style tableStyleNoBorders, RadFlowDocumentEditor editor)
{
var table = editor.InsertTable();
table.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 100);
table.StyleId = tableStyleNoBorders.Id;
return table;
}
private TableRow AddTableRow(Table table, int cells)
{
var row = table.Rows.AddTableRow();
var cellWidth = 100 / cells;
for (int i = 0; i < cells; i++)
{
var cell = row.Cells.AddTableCell();
cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, cellWidth);
}
return row;
}
private void AddParagraphMoveEditor(RadFlowDocumentEditor editor, TableRow row, int cellNumber)
{
var cellParagraph = row.Cells[cellNumber].Blocks.AddParagraph();
editor.MoveToParagraphStart(cellParagraph);
}
Hello,
I need to add HTML content to my RadFlowDocument and then export it to PDF.
The problem is when the HTML text contains a table with borders. Then the borders are not visible in the exported PDF.
C# code - import HTML text:
01.
InsertDocumentOptions options =
new
InsertDocumentOptions
02.
{
03.
ConflictingStylesResolutionMode = ConflictingStylesResolutionMode.UseTargetStyle,
04.
InsertLastParagraphMarker =
false
05.
};
06.
var firstPageText = myPdfModel.FirstPageText.ToString();
07.
if
(firstPageText !=
null
)
08.
{
09.
editor.InsertDocument(htmlFormatProvider.Import(firstPageText), options);
10.
}
I use Kendo Editor to obtain HTML code. The generated HTML is:
01.
<
table
>
02.
<
tbody
>
03.
<
tr
style
=
"height:50%;"
>
04.
<
td
style
=
"width:50%;border-width:2px;border-style:solid;border-color:#cc3333;"
>a</
td
>
05.
<
td
style
=
"width:50%;border-width:2px;border-style:solid;border-color:#cc3333;"
>b</
td
>
06.
</
tr
>
07.
<
tr
style
=
"height:50%;"
>
08.
<
td
style
=
"width:50%;border-width:2px;border-style:solid;border-color:#cc3333;"
>c</
td
>
09.
<
td
style
=
"width:50%;border-width:2px;border-style:solid;border-color:#cc3333;"
>d</
td
>
10.
</
tr
>
11.
</
tbody
>
12.
</
table
>
In Kendo Editor the table looks fine (see screenshot) but in PDF there are no borders.
Is it a bug or do I have to set some options somewhere?
If it is a bug, suggest me some workaround please.
Best Regards,
Daniel
Hi,
We have a WPF solution with a blog, the blog messages are being saved into our database as RadDocuments.
Now we are building a MVC-solution which should also be able to show this blog.
The Problems are:
1. how do I convert the RadDocument to HTML?
2. how do I convert the RadDocument to RadFlowDocument so I can work with it in the Kendo.Editor?
Do you have examples on how to solve this? RadDocument is loaded as a string from DB.
Regards Kristian
Hello,
I'm doing some experiments with WordsProcessing and found an annoying problem.
In a docx document, I have a table in the header. The table height is 2.48cm.
In a test application, I've just opened the document and save it, using your library.
After that, I've opened the document in Word and the table height is not correct as it is only 1.46cm (that's the height of the text inside the table).
Looking at the in-memory data of the document, the height of the table row is set to "Auto".
Unfortunately, there is also a border on this table and it now looks ugly, not counting that the image in the header "crosses" the table border
I also have the same problem in the footer, that also contains a table. In this part, this is more annoying because the height of the footer is not respected and the whole document formatting is not correct.
Hello,
I have a docx template file that contains both MERGEFIELD and CheckBox.
Using version 2021.1.118 of Telerik.Windows.Documents.Flow I perform MailMerge on that document.
After mailmerge the Checkbox control in the output document looses its style when being manually triggered. Manually triggering checkbox in original template does not change original style.
It's expected, that after mailmerge the Checkbox behaves as before mailmerge.
The complete demo is here:
https://github.com/vslynko/telerik-mailmerge-bugreport
While evaluating Telerik.Documents.Spreadsheet.Trial (2021.1.118) I've encountered a bug with registering custom functions in .NET 5.
I'm using a console application, and trying to register a couple of functions right at the start of the Main() method. It works like a charm with target framework netcoreapp3.1.
But as soon as I bump the version to net5.0, registering a function throws an exception (I've copied the full stack below).
Perhaps you can guide me what happens? We're currently evaluating on upgrading our license for the latest features, but this thing could be crucial to us, since we need to use .NET 5 for a couple of reasons.
I'm calling them right at the start of the applicaption
public
static
void
Main(
string
[] args)
{
FunctionManager.RegisterFunction(
new
AAA());
FunctionManager.RegisterFunction(
new
BBB());
...
}
Here's the exception stack:
Unhandled exception. System.TypeInitializationException: The type initializer for 'Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.FunctionManager' threw an exception.
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.TypeInitializationException: The type initializer for 'Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.Db' threw an exception.
---> System.ArgumentOutOfRangeException: Index and count must refer to a location within the string. (Parameter 'count')
at System.String.Remove(Int32 startIndex, Int32 count)
at Telerik.Windows.Documents.Spreadsheet.Formatting.FormatHelper.FindAllOccurrences(String value, String part)
at Telerik.Windows.Documents.Spreadsheet.Formatting.FormatHelper.ReplaceSeparators(String formatString, Predicate`1 shouldReplaceWithGroupSeparator, Predicate`1 shouldReplaceWithDecimalSeparator, String newGroupSeparat
or, String newDecimalSeparator)
at Telerik.Windows.Documents.Spreadsheet.Formatting.FormatHelper.ReplaceCultureSpecificSeparatorsWithDefaults(String formatString, Nullable`1 formatStringCategory)
at Telerik.Windows.Documents.Spreadsheet.Model.CellValueFormat..ctor(String formatString, Boolean convertToInvariant, Nullable`1 formatStringCategory)
at Telerik.Windows.Documents.Spreadsheet.Model.CellValueFormat..ctor(String formatString)
at Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.Db..cctor()
--- End of inner exception stack trace ---
at Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.Db..ctor()
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type)
at Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.FunctionManager..cctor()
--- End of inner exception stack trace ---
at Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.FunctionManager.RegisterFunction(FunctionBase function)
at Iface.Oik.ScriptEngine.Program.Main(String[] args) in C:\Users\alexeid\Rider\Iface.Oik.ScriptEngine\src\Program.cs:line 20
How do I get (or "read") a table cell's text value?
For example:
var row = table.Rows[i];
int nbCols = row.Cells.Count();
if (!(nbCols < 1))
{
for (int j = 1; j < nbCols; j++)
{
Run run = new Run(row.Cells[j].Blocks[0].Document);
if (run.Text == "«Signature»")
{
RadFlowDocumentEditor colEditor = new RadFlowDocumentEditor(row.Cells[j].Blocks[0].Document);
// if it's the Signature cell then replace the content of the cell by the Image ...
// How do I do this ??
}
}
}
In the code above I am trying to iterate through the collection of columns to find the one that contains text «Signature» so that I can replace that text with an image. The beast I could do is use the run as shown above but it never finds the value (although the value is in the table).
Thanks