Real beginner question here but need some pointers on sizing in a PDF document.
Can anyone explain sizing in PdfProcessing?
First question - How is the page size defined for RadFixedDocument, does is default to A4 or is there some kind of measurement setting applied by default? Does this same metric apply to the rest of the document (e.g. is it all mm/pixels or some other measurement)
RadFixedDocument document =
new
RadFixedDocument();
Second question
How is image size in pixels relative to the sizing on the page itself. In the sample below, imageSource.Width is pixels taken from the actual image, how does that translate to a relative size on the page?
Hi,
I'd like to suggest you split your assemblies so they are more efficient for server side use. Currently if you want to do some PDF processing on the server from the namespace `Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Streaming` you end up loading presentation framework dlls on the server which is unnecessary. If you look at the manifest for Telerik.Windows.Documents.Core.dll you will see
.assembly extern PresentationFramework
{
.publickeytoken = (31 BF 38 56 AD 36 4E 35 ) // 1.8V.6N5
.ver 4:0:0:0
}
.assembly extern System.Xaml
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly extern System.Drawing
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 4:0:0:0
}
.assembly Telerik.Windows.Documents.Core
{
This ends up loading unnecessary dlls, including System.Windows.Forms in IIS (if you are hosting the server in IIS).
I have a requirement to write the value "#N/A" but as an error not the text.
I tried to use SetCell with value "#N/A" but it seems that excel will not recognize this cell as an error because when the file is opened with an excel in another language the value remains "#N/A" (In German for instance the value should be converted to "#NV")
Hey,
I have a need to search for text fragments in a PDF page and convert these to navigable Hyperlinks.
Using: string documentContent = provider.Export(document); to export the full PDF document text fragments finds the text fragments properly, but is unusable as it doesn't preserve the content element that contains the text as I am required to insert a link at the same positional data.
I have also tried this code snippet with no luck as it seems to only return individual character data. The provider.Export(...) method does return the text fragments that are being searched properly, but how to enumerate the text elements in a page similar to what Export() is doing is where I need help with.
What is wrong with the method below for processing out the text fragments? Apparently the provider.Export() method that is baked in has another way of reading and forming the full text fragments that I need to copy or mimic as to preserve the positional information for the text fragment.
private void SearchTextFragment(RadFixedDocument document, string searchText)
{
foreach (var page in document.Pages)
{
foreach (var contentElement in page.Content)
{
if (contentElement is TextFragment)
{
string text = (contentElement as TextFragment).Text;
if (text.IgnoreCaseEqual(searchText))
{
}
}
}
}
}
Hello,
I'm trying to create a PDF file from a Xamarin app.
Everything went well until I add text with accent (it's quite embarasing for me, because all my texts are in French).
I know that the 14 Standard fonts are withou accent.
So i try to add a FontsProvider to add a MyriadPro.ttf file (which is also Embedded a ressource in my Android and Ios projets), as explained here : https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/cross-platform , with the using of the Environment.SpecialFolder.Fonts folder
I put the provider class and initiate it in my create method.
But when i don't know how to add the .tff file to the Environment.SpecialFolder.Fonts
When a call my fontfamily with this line (from the Xamarin sample app) : this.SetTextProperties(block, RgbColors.Black, 25, new FontFamily("MyriadPro"))
The custom Fontprovider is called as expected, but a have a exception, because the folder : /data/user/0/com.xxx.xxxx/files/.fonts is not found
My question is : how to add my ttf to the SpecialFolder.fonts , in my Android and Ios project ?
Thanks for you help,
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