Telerik Forums
Telerik Document Processing Forum
1 answer
63 views

Hi,

 

I have an existing xlsx file that contains graphics (drawing)

I simply open the workbook, 


var workbook = CreateWorkbook();

byte[] bytes;

using (var output = new MemoryStream())
{
    new XlsxFormatProvider().Export(workbook, output);
    bytes = output.ToArray();
}

File.WriteAllBytes("c:\\Logs\\test.xlsx", bytes);


private Workbook CreateWorkbook()
{
    Workbook workbook;
    IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();
    FileStream? stream = null;
    try
    {
        stream = File.Open("AnalyseImpayeTemplate.xlsx", FileMode.Open);
        workbook = formatProvider.Import(stream);
    }
    catch (IOException ex)
    {
        throw new IOException("The file cannot be opened. It might be locked by another application.", ex);
    }
    finally
    {
        stream?.Dispose();
    }

    return workbook;
}

When I open the result file, with release 2024.3.806, I got an error. It delete drawing parts :

Partie supprimée: /xl/drawings/drawing1.xml partie.  (Forme de dessin)

With release 2024.2.426, it works fine.

Any ideas why?

Yoan
Telerik team
 answered on 08 Oct 2024
1 answer
61 views

Hi

I have a problem with row height when processing docx files and exporting to pdf.
Export does not respect the height of a table row if the height of a given row is lower than the content of cells in that row. However, if the height of the row is greater than the content, then it is ok.
During processing, a given row has its height set as Exact and a specific value in pixels, but after export, the height of a given row in the table adjusts to the content.

Maybe there is a workaround for this problem?

Yoan
Telerik team
 answered on 09 Sep 2024
2 answers
106 views

 

I have the following code that shows the bold formatting from HTML to PDF appears inconsistent.

The last table has all the cells wrapped in <b> tags, but they are not rendered bold in the PDF. There seems to be some correlation to the length of the text (short text sometimes will be bold). I have also tried <strong> tags and CSS that applies bold. It does not matter which font is chosen.

Inconclusive observation: It appears that if the bold text line wraps inside a cell, it doesn’t apply bold. Text that does not wrap in the cell appears to apply bold.

Any help appreciated.

 


using RegServices.Portal.Web.Services.Pdf;
using Telerik.Documents.ImageUtils;
using Telerik.Windows.Documents.Flow.FormatProviders.Html;
using Telerik.Windows.Documents.Flow.Model;
using Xunit.Abstractions;

namespace Portal.Web.Tests.Pdf;

public class PdfBoldRenderTests : OutputTestBase
{
    private readonly IHtmlToWordConverter _htmlToWordConverter = new HtmlToWordConverter();
    string path = "c:\\\\temp\\\\pdf\\\\";
    public PdfBoldRenderTests(ITestOutputHelper output) : base(output)
    {
    }

    [Fact]
    public void CanRenderBold()
    {
        var html = $$"""
                   <!DOCTYPE html>
                   <html lang="en">
                      <head>
                         <title>Test</title>
                         <style>
                            body { 
                            font-family: Arial;
                            }
                            .bold {
                            font-weight: bold;
                            }
                            .font-bold {
                            font-weight: 800;
                            }
                            .font-black {
                            font-weight: 800;
                            }
                         </style>
                      </head>
                      <body>
                         <table>
                            <tr>
                               <td>
                                  The quick brow fox. Regular text <br>
                                  <b>The quick brow fox.  Bold text</b><br>
                                  <span class="bold">The quick brow fox.  Bold text via css</span><br>
                               </td>
                               <td>
                                  <table>
                                     <tr>
                                        <td>
                                           The quick brow fox. Regular text <br>
                                           <b>The quick brow fox.  Bold text</b><br>
                                           <span class="bold">The quick brow fox.  Bold text via css</span><br>
                                        </td>
                                     </tr>
                                  </table>
                               </td>
                            </tr>
                            <tr>
                               <td colspan="2">
                                  <table>
                                     <tbody>
                                        <tr>
                                           <td class="w-2-24">
                                              <b>Financial year</b>
                                           </td>
                                           <td>
                                              <b>General Services Charge (range)</b><em>(weekly)</em>
                                              <span class="font-black">General Services Charge (range)</span>
                                           </td>
                                           <td class="w-2-24">
                                              <b>Overall % change from previous year </b>
                                           </td>
                                           <td>
                                              <b>
                                              Maintenance Reserve Fund contribution (range)
                                              </b>
                                              <em>(weekly)</em>
                                           </td>
                                           <td class="w-2-24">
                                              <b>Overall % change from previous year</b>
                                              <em>(+ or -)</em>
                                           </td>
                                        </tr>
                                  </table>
                               </td>
                            </tr>
                         </table>
                         <b>The quick brow fox.  Bold text</b><br>
                         <table>
                            <tbody>
                               <tr>
                                  <td class="w-2-24">
                                     <b>Financial year</b>
                                  </td>
                                  <td>
                                     <b>Bold Text</b><em>(weekly)</em>
                                     <span class="font-black">General Services Charge (range)</span>
                                  </td>
                                  <td class="w-2-24">
                                     <b>Bold Text</b>
                                  </td>
                                  <td>
                                     <b>
                                     Bold Text
                                     </b>
                                     <em>(weekly)</em>
                                  </td>
                                  <td class="w-2-24">
                                     <b>Bold Text</b>
                                     <em>(+ or -)</em>
                                  </td>
                               </tr>
                            </tbody>
                         </table>
                         
                         <b>The quick brow fox.  Bold text</b><br>
                         <table>
                            <tr>
                               <td>
                                  <b>I am a bold text</b>
                               </td>
                               <td>
                                  <b>I am a bold text
                                  </b><em>(weekly)</em>
                               </td>
                               <td>
                                  <b>I am a bold text</b>
                               </td>
                               <td>
                                  <b>
                                  I am a bold text test test
                                  </b>
                                  <em>(weekly)</em>
                               </td>
                               <td>
                                  <b>I am a bold text test</b>
                               </td>
                            </tr>
                         </table>
                      </body>
                   </html>
                   """;

        var htmlDocument = _htmlToWordConverter.ConvertHtmlToWord(html);
        var docxProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();

        Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.FontsProvider =
            new FontsProvider();

        using var memoryStream = new MemoryStream();
        docxProvider.Export(htmlDocument, memoryStream);
        var documentBytes = memoryStream.ToArray();

        File.WriteAllBytes($"{path}Test.docx", documentBytes);

        var (pdfBytes, pdfDoc) = PdfConverter.ConvertDocxToPdf(documentBytes);
        File.WriteAllBytes($"{path}Test.pdf", pdfBytes);

        var provider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
        using Stream pdfStream = File.OpenWrite($"{path}Test2.pdf");
        provider.Export(pdfDoc, pdfStream);
    }
    
    public interface IHtmlToWordConverter
    {
        RadFlowDocument ConvertHtmlToWord(string html);
    }

    public class HtmlToWordConverter : IHtmlToWordConverter
    {
        public RadFlowDocument ConvertHtmlToWord(string html)
        {
            var htmlFormatProvider = new HtmlFormatProvider();
            return htmlFormatProvider.Import(html);
        }
    }

    public static class PdfConverter
    {
        static PdfConverter()
        {
            var defaultImagePropertiesResolver = new ImagePropertiesResolver();
            Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.ImagePropertiesResolver =
                defaultImagePropertiesResolver;
        }

        public static (byte[] bytes, RadFlowDocument doc) ConvertDocxToPdf(byte[] docxBytes)
        {
            var docxProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
            var pdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();

            var document = docxProvider.Import(docxBytes);

            using var memoryStream = new MemoryStream();
            pdfProvider.Export(document, memoryStream);
            pdfProvider.ExportToFixedDocument(document);
            return (memoryStream.ToArray(), document);
        }
    }
}


Setven
Top achievements
Rank 1
Iron
Iron
 answered on 31 Aug 2024
0 answers
133 views

I tried doing the following:

using Stream stream = File.OpenRead(fileName);
RadFixedDocument pdfDocument = new PdfFormatProvider().Import(stream);
RadFixedDocument pdfNew = new();
pdfNew.Pages.Add(pdfDocument.Pages.First());

I get the following error:

System.ArgumentException: 'The document element is associated with another parent. (Parameter 'item')'

 

Is there a way to clone a page, so it can be added to another document?

Henrik
Top achievements
Rank 1
 asked on 20 Aug 2024
2 answers
200 views

I am having trouble getting some HTML converted to PDF to render Unicode checkboxes.

\u2612 ☒ and \u2610  

They appear ok in the word conversion, but are missing in PDF

Here is the same code


using Telerik.Documents.ImageUtils;
using Telerik.Windows.Documents.Flow.FormatProviders.Html;
using Telerik.Windows.Documents.Flow.Model;

namespace Web.Tests.Pdf;

public class PdfRenderTests
{
    private readonly IHtmlToWordConverter _htmlToWordConverter = new HtmlToWordConverter();
    string path = "c:\\\\temp\\\\pdf\\\\";

    [Fact]
    public void CanRenderCheckbox()
    {
        var html = "<span class=\"checkbox\">\u2612 Yes \u2610 No</span>";
        var htmlDocument = _htmlToWordConverter.ConvertHtmlToWord(html);
        var docxProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
        using var memoryStream = new MemoryStream();
        docxProvider.Export(htmlDocument, memoryStream);
        var documentBytes = memoryStream.ToArray();

        File.WriteAllBytes($"{path}Test.docx", documentBytes);

        var pdfBytes = PdfConverter.ConvertDocxToPdf(documentBytes);
        File.WriteAllBytes($"{{path}}Test.pdf", pdfBytes);
    }
}

public interface IHtmlToWordConverter
{
    RadFlowDocument ConvertHtmlToWord(string html);
}

public class HtmlToWordConverter : IHtmlToWordConverter
{
    public RadFlowDocument ConvertHtmlToWord(string html)
    {
        var htmlFormatProvider = new HtmlFormatProvider();
        return htmlFormatProvider.Import(html);
    }
}

public static class PdfConverter
{
    static PdfConverter()
    {
        var defaultImagePropertiesResolver = new ImagePropertiesResolver();
        Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.ImagePropertiesResolver =
            defaultImagePropertiesResolver;
    }

    public static byte[] ConvertDocxToPdf(byte[] docxBytes)
    {
        var docxProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
        var pdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();

        var document = docxProvider.Import(docxBytes);

        using var memoryStream = new MemoryStream();
        pdfProvider.Export(document, memoryStream);
        return memoryStream.ToArray();
    }
}

 

PDF Output:

 

Word Output


Yoan
Telerik team
 answered on 20 Aug 2024
1 answer
131 views

Greetings,

I am using Telerik 2024.3.802 PdfProcessing library.

We have used the Telerik library to convert a HTML document to Word DOCX format.

This process completes successfully.

Then using Telerik PdfProcessing, executing a Word to PDF process. 

The method throws an exception shown below.

The code is fairly trivial:

 

public static byte[] ConverDocxToPdf(byte[] docxBytes)
{
var docxProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
var pdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();

var document = docxProvider.Import(docxBytes);

using var memoryStream = new MemoryStream();
pdfProvider.Export(document, memoryStream);
return memoryStream.ToArray();
}

 

If we open the Telerik produced docx file, in word, and resave it (no changes)

Then  the Word to PDF process works. So it may imply there is an error in the HTML to word conversion which is creating a invalid docx file.

Is there anyway to "validate" a docx file with the Telerik tooling?

 

EDIT: When using this OpenXML validator: https://learn.microsoft.com/en-us/office/open-xml/word/how-to-validate-a-word-processing-document?tabs=cs-0%2Ccs  against the Telerik created word docx file, I get a list of 51 errors.  So Telerik Html to Docx perhaps is not creating a valid docx for various nodes.

 

Here are the list of errors

 

Error 1
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:footerReference'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.SectionProperties
Error 2
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 3
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 4
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 5
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 6
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 7
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 8
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 9
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 10
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 11
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 12
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 13
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 14
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 15
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 16
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 17
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 18
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 19
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 20
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 21
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 22
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 23
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 24
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 25
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 26
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 27
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 28
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 29
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 30
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 31
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 32
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 33
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 34
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 35
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 36
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 37
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 38
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tr'. List of possible elements expected: <http://schemas.openxmlformats.org/wordprocessingml/2006/main:tblGrid>.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.Table
Error 39
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties
Error 40
Description: The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:tcBorders'.
ErrorType: Schema
Node: DocumentFormat.OpenXml.Wordprocessing.TableCellProperties

 

 

(Microsoft.AspNetCore.Components.Web.ErrorBoundary) Unhandled exception rendering component: "The document element is associated with another parent. (Parameter 'item')"
System.ArgumentException: The document element is associated with another parent. (Parameter 'item')
at Telerik.Windows.Documents.Fixed.Model.Collections.DocumentElementCollection`2.VerifyDocumentElementOnInsert(T item)
at Telerik.Windows.Documents.Core.Data.DocumentElementCollectionBase`2.Add(T item)
at Telerik.Windows.Documents.Fixed.Model.Editing.FixedContentEditor.Append(PositionContentElement element)
at Telerik.Windows.Documents.Fixed.Model.Editing.FixedContentEditor.Draw(PositionContentElement element)
at Telerik.Windows.Documents.Fixed.Model.Editing.Layout.ContentElementLayoutElementBase`1.Draw(DrawLayoutElementContext context)
at Telerik.Windows.Documents.Fixed.Model.Editing.Block.Draw(IEnumerable`1 lineElements, DrawLayoutElementContext context)
at Telerik.Windows.Documents.Fixed.Model.Editing.Block.DrawInternal(FixedContentEditor editor, Rect boundingRect)
at Telerik.Windows.Documents.Fixed.Model.Editing.Block.Draw(FixedContentEditor editor, Rect boundingRect)
at Telerik.Windows.Documents.Fixed.Model.Editing.Tables.TableCell.Draw(FixedContentEditor editor)
at Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table.DrawCellContent(FixedContentEditor editor, TableCell cell)
at Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table.DrawTableCells(FixedContentEditor editor, Int32 rowIndex, TableCellCollection cells)
at Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table.DrawTableRows(FixedContentEditor editor)
at Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table.DrawInternal(FixedContentEditor editor, Rect boundingRect)
at Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table.Draw(FixedContentEditor editor, Rect boundingRect)
at Telerik.Windows.Documents.Fixed.Model.Editing.Tables.TableCell.Draw(FixedContentEditor editor)
at Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table.DrawCellContent(FixedContentEditor editor, TableCell cell)
at Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table.DrawTableCells(FixedContentEditor editor, Int32 rowIndex, TableCellCollection cells)
at Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table.DrawTableRows(FixedContentEditor editor)
at Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table.DrawInternal(FixedContentEditor editor, Rect boundingRect)
Yoan
Telerik team
 answered on 20 Aug 2024
1 answer
96 views

I see Sreadsheet processing has row removal feature but it seems you need to know the range of rows you want to remove. 

How would you recommend acheiving something like a trim functionality? Excel spreadsheets in my experience are notorious for having potenatially pages and pages of empty rows after all the actual content.  In fact I am working with one like that now.How can I get rid of those empty rows?

 

Thank you!

Yoan
Telerik team
 answered on 19 Aug 2024
0 answers
87 views
I am using a PdfFormatProvider to export the stream of a DocX.

I am displayinga preview of this docx as PDF within my application. The problem is, the PDF is not showing the correct spacing, line numbers and other items listed in the docX file.

When I save DocX as PDF it will display everything needed.
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
 asked on 05 Aug 2024
1 answer
111 views

Hi folks,

we have a requirement for a PDF that we must draw a table with different columns counts and sizes. Our approach is to generate a defined number of cells in a row (18) and merge them appropriately as we need them. Find a test below.

void AddSecondTable(RadFixedPage page)
{
var blackBorder = new Border(1, new RgbColor(0, 0, 0));
var editor = new FixedContentEditor(page);
editor.Position.Translate(Unit.CmToDip(2), Unit.CmToDip(2));
var table = new Table
{
LayoutType = TableLayoutType.AutoFit,
DefaultCellProperties =
{
Padding = new Thickness(5, 5, 5, 5),
Borders = new TableCellBorders(blackBorder, blackBorder, blackBorder, blackBorder)
}
};

for (var rowIndex = 0; rowIndex < 10; rowIndex++)
{
var row = table.Rows.AddTableRow();
for (var cellIndex = 0; cellIndex < 18; cellIndex++)
{
var cell = row.Cells.AddTableCell();
cell.PreferredWidth = Unit.CmToDip(1);
var b = cell.Blocks.AddBlock();
b.InsertText(new FontFamily("Helvetica"), FontStyles.Normal, FontWeights.Normal, $"Cell: {cellIndex}");
}

var firstCell = row.Cells[0];
firstCell.ColumnSpan = 4;
}

editor.DrawTable(table, Unit.CmToDip(18));
}

 

We expect that the first cell be placed over the first four columns, but nothing happens at all. What do we miss here?

Further, we would expect that the next cell starts with cellIndex 4, as the first four (0-3) are “merged”.

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 05 Aug 2024
1 answer
90 views

I am generating a RadFlowDocument, and at the end protecting the entire document with a custom password like below..

                editor.Protect("TestPassword");
This works when I open the word document as expected, but when I go in MS Word to UNLOCK the document with my password, I am constantly told the password is incorrect.. Any advise on what I am doing wrong? 
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 24 Jul 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?