Telerik Forums
Telerik Document Processing Forum
1 answer
69 views

I do notice that the AutoFitHeight works fine when I'm dealing with only a single row without any merged cells.

I have a situation where I have a merged cell which is the combination of cells from the same row (i.e. B2-B5).  When trying to use AutoFitHeight, there is no change to the row height.

Is there anything I could do? 

Yoan
Telerik team
 answered on 18 Jul 2023
1 answer
46 views

We have a scenario where the client is wanting a combobox in a generated Word document to have the color of the combobox change depending on the option selected (these combo boxes are repeated many times in the document so the colour change is important to the client.

Screenshot shows  the Combobox in use. Below is the snippet of my code. Is there a way to do what I am after?

RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
// In my source (an html document that was converted to a Word Document higher in the code) "#ddlApplies" is where I need to place a ComboBox
// It is in a table cell.
ReadOnlyCollection<FindResult> findResults = editor.FindAll("#ddlApplies", matchCase: false, matchWholeWord: false);
foreach (var item in findResults)
{
	string foundVal = item.Runs[0].Text.Replace("#", "");
	// The full run name consists of "#ddl|Identifier". In Furture dev we will use the Identifier (which is put in as the alias) to identify which control this is so we can read in the document and update other datasets
	//var ddlContentControl = editor.InsertStructuredDocumentTag(SdtType.ComboBox);
	ComboBoxProperties properties = new ComboBoxProperties();
	// Complies --- Green
	// Does not Comply --- Red
	// Minor Variation --- Orange
	// N/A -- Grey
	properties.Items.Add(new ListItem() { DisplayText = "Complies", Value = "Complies" });
	properties.Items.Add(new ListItem() { DisplayText = "Does not Comply", Value = "Does not Comply" });
	properties.Items.Add(new ListItem() { DisplayText = "Minor Variation", Value = "Minor Variation" });
	properties.Items.Add(new ListItem() { DisplayText = "N/A", Value = "N/A" });
	// Setting the alias with the identifier.
	properties.Alias = foundVal.Split("|")[1];
	properties.Lock = Lock.SdtLocked;
	properties.Placeholder = new Placeholder() {
		PlaceholderText = "Select",
		ShowPlaceholder = true
	};
	properties.OutlineAppearance = OutlineAppearance.BoundingBoxes;
	//setting the properties
	properties.RunProperties.CopyPropertiesFrom(item.Runs[0].Properties);
	/***
	Here is where I think I need to set things. But not sure how. Client wants each option to have a different colour. They would prefer the whole cell to change, but happy if I can just get the ComboBox to change.
	
	***/
	
	//inserting the Tag and setting the default value
	editor.MoveToInlineStart(item.Runs[0]);	
	editor.InsertStructuredDocumentTag(properties, item.Runs[0], item.Runs[0]);
	item.Runs[0].Text = "Select";	

}

Vladislav
Telerik team
 answered on 17 Jul 2023
1 answer
54 views

How can I install the document library alone without installing a component UI library?

I just want to process PDF files

Yoan
Telerik team
 answered on 13 Jul 2023
1 answer
77 views
I want to learn more about Word processing and how to create tables in the Word document.
Unfortunately I only ever see c# code.
Can someone show me an example for VB.NET ?
A simple table with cell contents..
Yoan
Telerik team
 answered on 13 Jul 2023
1 answer
228 views


Hi all, 

I got some problems when I try to read my Excel file as below:

1. It skipped the null cells, it only read data at the cells having value. For example in my case, after reading cell 2 at row 2, it jumped to cell 14. 

2. It showed the error message "The given key '3' was not present in the dictionary." at cell 15

You can see my code, the Excel file I used, and the result in below

My code

@page "/testpage"
@using Telerik.Documents.SpreadsheetStreaming;
<div>
    @((MarkupString)(str.ToString()))
</div>


@code {
    private StringBuilder str = new StringBuilder();
    protected override void OnInitialized()
    {
        str = ReadData();
    }
    private StringBuilder ReadData()
    {

        try
        {
            string filename = ".\\Template.xlsx";
            using (FileStream fs = new FileStream(filename, FileMode.Open))
            {
                using (IWorkbookImporter workBookImporter = SpreadImporter.CreateWorkbookImporter(SpreadDocumentFormat.Xlsx, fs))
                {
                    foreach (IWorksheetImporter worksheetImporter in workBookImporter.WorksheetImporters)
                    {
                        foreach (IRowImporter rowImporter in worksheetImporter.Rows)
                        {
                            foreach (ICellImporter cell in rowImporter.Cells)
                            {
                                if(cell.Value!= null)
                                {
                                    str.Append(cell.Value.ToString());

                                }
                                else
                                {
                                    str.Append("NULL");
                                }
                                str.Append(",");
                            }
                            str.Append("<br/>");
                        }

                    }
                }
            }
            return str;
        }
        catch(Exception ex)
        {
            str.Append("<br/>");
            str.Append(ex.Message);
            return str;
        }

    }
}
 My Excel file as a picture below, I also attached my Excel in the question (Template.rar)

  The result when I run 

  Everyone who know how to fix it, please help me.

Thank you

Yoan
Telerik team
 answered on 04 Jul 2023
1 answer
98 views

Hi all,

 

I would like to replace a temporary page content (a placeholder text) with an image in a Pdf. In order to do this, I use the telerik solution here.

My problem is that it doesn't work always : it often bugs because the placeholder text seems to be splitted in multiple text fragment.

Here is an example :

In my document : the placeholder text

The text fragments found in pdf :

And sometimes it works well:

Is there any solution to help me with this please?

 

Thank you,
Regards,
Adrian

Martin
Telerik team
 answered on 28 Jun 2023
0 answers
86 views

I have a method like so that takes HTML and returns a PDF: 

private static Stream ConvertToPdf(string htmlFileContent)
{
	var htmlProvider = new HtmlFormatProvider();

	var htmlDocument = htmlProvider.Import(htmlFileContent);

	var pdfProvider = new PdfFormatProvider();

	var pdfMemoryStream = new MemoryStream();

	pdfProvider.Export(htmlDocument, pdfMemoryStream);

	pdfMemoryStream.Position = 0;

	return pdfMemoryStream;
}

This method works perfectly on my local Windows dev box, but when I run it in a Fargate container in AWS ECS, I get the following exception if the HTML contains an image:

System.NotSupportedException: Not supported image format.
   at Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource.DoOnUnknownData(Byte[] unknownData, ImageQuality imageQuality, Action`1 doOnEncodedData)
   at Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource.InitializeImageInfoFromUnknownData(Byte[] unknownData, ImageQuality imageQuality)
   at Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource.EnsureImageInfo()
   at Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource.get_Width()
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Objects.ImageXObject.CopyPropertiesFrom(IPdfExportContext context, ImageSource imageSource)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExportContext.GetResource(ImageSource resource)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfContentExportContext.GetResource(ImageSource imageSource)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ContentElementWriters.ImageWriter.WriteOverride(PdfWriter writer, IPdfContentExportContext context, Image element)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ContentElementWriters.MarkableContentElementWriter`1.Write(PdfWriter writer, IPdfContentExportContext context, Object element)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ContentElementWriters.ClippingWriter.WriteOverride(PdfWriter writer, IPdfContentExportContext context, Clipping clipping)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ContentElementWriters.ContentElementWriter`1.Write(PdfWriter writer, IPdfContentExportContext context, Object element)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ContentElementWriters.ContentRootWriter.WriteOverride(PdfWriter writer, IPdfContentExportContext context, IContentRootElement element)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ContentElementWriters.ContentElementWriter`1.Write(PdfWriter writer, IPdfContentExportContext context, Object element)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ContentElementWriters.ContentElementWriterBase.WriteElement(PdfWriter writer, IPdfContentExportContext context, Object element)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.ContentStream.BuildContentData(IPdfExportContext context, IResourceHolder resourceHolder, IContentRootElement contentRootElement)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.Page.CopyPropertiesFrom(IPdfExportContext context, RadFixedPage fixedPage)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.CopyRadFixedPageProperties(RadFixedPage source, Page destination, IRadFixedDocumentExportContext context)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.CopyPagePropertiesFrom(IRadFixedDocumentExportContext context)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.CopyPropertiesFrom(IRadFixedDocumentExportContext context)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExporter.Export(IRadFixedDocumentExportContext context, Stream output)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(RadFixedDocument document, Stream output)
   at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(RadFlowDocument document, Stream output)
   at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
All of those Telerik.Windows.Documents.* namespaces make me skeptical. I am referencing the .NET Standard NuGet packages from the Telerik feed, so they should work on Linux, right?
Dev
Top achievements
Rank 1
 asked on 15 Jun 2023
1 answer
45 views
 I want to create new file , is possible import header and footer from exist docx file ?
Aleks
Telerik team
 answered on 15 Jun 2023
1 answer
123 views

When creating a PDF is there a way to nest a table within another table without having to be specific of the tables Y position?  I actually have 3 tables that can look like this:

Table1 - Row1

Table2 - Row1

Table3 - Row1
Table3 - Row2

Table1 - Row2

The number of rows per table is determined by the data, so I don't necessarily know where I am on the page.  Do I have to increase some kind of counter for each line, cause that would be miserable?  I wish there were more extensive examples for creation of Pdf's.  I have seen the Developer Focused examples none of them even come close to what I am trying to accomplish.  

Yoan
Telerik team
 answered on 15 Jun 2023
1 answer
59 views

Hi.

I'd like to be able to put certain strings in a Word document, and then programmatically have everything between those strings removed.  The following works, when STARTREPLACE and ENDREPLACE are on the same line.

RadFlowDocument document = provider.Import(inputFileStream);

RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);

editor.ReplaceText(new Regex("(?<=STARTREPLACE)(.*)(?=ENDREPLACE)", RegexOptions.Singleline), string.Empty);

However when STARTREPLACE and ENDREPLACE are not on the same line, nothing happens.

Anyone have any idea how I can make this work over multiple lines - or if there's another approach which would be better?

Thanks in advance!

Dean

Yoan
Telerik team
 answered on 13 Jun 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?