Telerik Forums
Telerik Document Processing Forum
1 answer
13 views

I am trying to create a pdf page using the pdfprocessing library.

The page has a number of tables with mostly text and a few images. I think I am ok with handling these.

I am building up the page in a RadFixedPage added to a RadFixedDocument.

However, in one of the table cells I need to be able to insert a block of rtf formatted text.

This is user entered using a RadRichTextBox and saved to a string field in code-behind using RtfDataProvider

A typical block of rtf may be:

{\rtf1\ansi\ansicpg1252\uc1\deff0\deflang1033{\fonttbl{\f0 Segoe UI;}{\f1 Times New Roman;}{\f2 Verdana;}}{\colortbl\red0\green0\blue0 ;\red0\green176\blue80 ;\red255\green192\blue0 ;\red250\green250\blue250 ;\red0\green0\blue255 ;}{\*\defchp\ltrch\f0\fs18\i0\b0\strike0\cf0\ulc0\ulnone}{\*\defpap\sl276\slmult1\ql\sa180\ltrpar}{\stylesheet{\s0\sqformat\spriority0\ltrch\f0\fs18\i0\b0\strike0\cf0\ulc0\ulnone\sl276\slmult1\ql\ltrpar Normal;}{\*\ts2\tsrowd\spriority59\trbrdrt\brdrnone\trbrdrb\brdrnone\trbrdrl\brdrnone\trbrdrr\brdrnone\trbrdrh\brdrnone\trbrdrv\brdrnone\trgaph0\trpaddl75\trpaddr75\trpaddt0\trpaddb0\clpadft3\clpadt0\clpadfr3\clpadr0\clpadfl3\clpadl0\clpadfb3\clpadb0\tsvertalt\ltrch\f0\fs18\i0\b0\strike0\cf0\ulc0\ulnone\sl276\slmult1\ql\sa180\ltrpar Table Normal;}{\s3\spriority99\ltrch\f0\fs18\i0\b0\strike0\cf0\ulc0\ulnone\sl276\slmult1\ql\sb100\sa100\sbauto1\saauto1\ltrpar Normal (Web);}}\nouicompat\viewkind4\sectd\headery720\footery720\pard\sl276\slmult1\qc\ltrpar{\ltrch\f0\fs18\i\b\strike0\cf1\cb2\highlight2\ulc0\ulnone line }{\ltrch\f0\fs18\i0\b0\strike0\cf0\ulc0\ulnone 1}{\ltrch\f0\fs18\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl276\slmult1\ql\ltrpar{\ltrch\f1\fs18\i\b0\strike0\cf0\cb3\highlight3\ulc0\ulnone sDefaultStyleSettings}{\ltrch\f1\fs18\i0\b0\strike0\cf0\cb3\highlight3\ulc0\ulnone =}{\ltrch\f1\fs18\i0\b0\strike0\cf4\cb3\highlight3\ulc0\ulnone "True"}{\ltrch\f0\fs18\i0\b\strike0\cf0\ulc0\ulnone\par}\pard\sl276\slmult1\ql\ltrpar{\ltrch\f0\fs18\i0\b0\strike0\cf0\ulc0\ulnone linr 3s}{\ltrch\f0\fs18\i0\b\strike0\cf0\ulc0\ulnone lin 2}{\ltrch\f1\fs18\i0\b0\strike0\cf0\cb3\highlight3\ulc0\ulnone DocumentInherit}{\ltrch\f0\fs18\i0\b\strike0\cf0\ulc0\ulnone\par}}

 

For inserting normal text I have been using

            row = table.Rows.AddTableRow();
            cell = row.Cells.AddTableCell();
            cell.Blocks.AddBlock().InsertText(Language.Language.ProductName);

any suggestions how I can insert rtf rather than plain text?

Thanks

Andrew

Yoan
Telerik team
 answered on 26 Feb 2024
1 answer
11 views
I have a DOCX Template that has multiple merge fields defined. One of those fields is for an image. How can I get MailMerge to insert images into a merge field.
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 23 Feb 2024
0 answers
16 views
Hello! I'm currently attempting to transform an HTML body into a PDF using HtmlFormatProvider, RadFlowDocument, and PdfFormatProvider.

Everything functions good when generating a PDF with standard characters. However, when incorporating characters such as "ćšđž," these specific characters seem to be missing.

Could you kindly provide guidance on resolving this issue?
Sanja Tolo
Top achievements
Rank 1
Iron
Iron
 asked on 09 Feb 2024
0 answers
21 views

I created a test docx with the following text in a justified format:

"This is a brand-new document with justified text.  Putting extra text into the paragraph in order to highlight the specific justified format text.  This is simply test text in order to demonstrate the issue that I am having when I attempt to use the Telerik rad document find all."

I then upload the document into Session and save the file binary by converting the File.InputStream to Base64Stream.

I then create a find text of "This is simply test text".

The resulting IReadOnlyCollection<FindResult> of editor.FindAll(txtFind, false, true); contains one result with three runs.

"highlight the specific justified format text. This is simply"

"test"

"text in order to demonstrate the issue that I am having when I attempt to use the Telerik rad document find all.

 

I had assumed that setting match whole word would return a better result, but it does not.

I think I do not understand the concept of "runs".  There is no other formatting other than justification.  

I expected either the sentence that the text resides in to return OR the entire paragraph.  Not three incomplete sentences, one just including one word.

Patrick
Top achievements
Rank 1
 updated question on 06 Feb 2024
0 answers
25 views

Hello

I'm trying to create an Excel xlsx spreadsheet from data in a data table. I'm having trouble setting / defining cell borders. I would like to define a bottom black thin border for a range of cells.

I'm using this as a reference https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/working-with-cells/get-set-clear-properties#borders-property

I've started with this...

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets.Add();

ThemableColor black = new ThemableColor(Color.FromArgb(0, 0, 0, 0));
CellBorders blackBorders = new CellBorders(new CellBorder(CellBorderStyle.Thin, black));
worksheet.Cells[4, 0, 4, 9].SetBorders(blackBorders);

In Visual Studio, ThemableColor and Color are underlined in red. When I mouse over it says 'The name 'Color' does not exist in the current context'.

Am I missing a reference or using statement to be able to use ThemableColor?

Andrew
Top achievements
Rank 1
 asked on 30 Jan 2024
0 answers
20 views
I recently began my 30 day trial with Telerik and I downloaded the Progress® Telerik® UI for ASP.NET Core product.  I am attempting to now add the necessary nuget packages within the Telerik Document Processing product.  When attempting to add the Telerik.Windows.Documents.Core nuget package via the command line, I receive the below error.  I am using a mac with visual studio code for what it is worth.  Any insight on how to work around this error is appreciated.

error: There are no versions available for the package 'Telerik.Windows.Documents.Core'.

Adam
Top achievements
Rank 1
 asked on 03 Jan 2024
1 answer
42 views

My C# project targets net6.0-windows and enables windows forms:

<PropertyGroup>
 <TargetFramework>net6.0-windows</TargetFramework>
 <ImplicitUsings>enable</ImplicitUsings>
<UseWindowsForms>true</UseWindowsForms>
 <Nullable>enable</Nullable>
 </PropertyGroup>

In the code, I want to create PDF documents dynamically and show them by using the PdfViewer component.

Thus, I added the following references:

<PackageReference Include="Telerik.Documents.Core" Version="2023.3.1106" />
<PackageReference Include="Telerik.Documents.Fixed" Version="2023.3.1106" />
<PackageReference Include="Telerik.Documents.Flow" Version="2023.3.1106" />
<PackageReference Include="Telerik.Documents.Flow.FormatProviders.Pdf" Version="2023.3.1106" />
<PackageReference Include="Telerik.Zip" Version="2023.3.1106" />
<PackageReference Include="UI.for.WinForms.AllControls.Net60" Version="2023.3.1114" />

Here is a part of my code:


    internal class GenericPdfCombiner : IPdfCombiner
    {
        public RadFixedDocument Combine(List<string> fileNames)
        {
            using MemoryStream stream = new MemoryStream();
            using (PdfStreamWriter fileWriter = new PdfStreamWriter(stream, leaveStreamOpen: true))
            {
                for (var fi = 0; fi < fileNames.Count; fi++)
                {
                    var file = fileNames[fi];
                    using PdfFileSource fileSource = new PdfFileSource(new MemoryStream(File.ReadAllBytes(file)));
                    for (var p = 0; p < fileSource.Pages.Length; p++)
                    {
                        PdfPageSource sourcePage = fileSource.Pages[p];
                        using PdfPageStreamWriter resultPage = fileWriter.BeginPage(sourcePage.Size);
                        resultPage.WriteContent(sourcePage);
                    }
                }
            }
            PdfFormatProvider provider = new PdfFormatProvider();
            return provider.Import(stream);
        }
    }

but it shows the error Reference to type 'Size' claims it is defined in 'WindowsBase', but it could not be found on the lines like the following:

using PdfPageStreamWriter resultPage = fileWriter.BeginPage(sourcePage.Size);

How can I fix it?

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 03 Jan 2024
1 answer
25 views
why exporting to csv file not loads correctly and how to solve this 
Ramya
Top achievements
Rank 1
 updated question on 27 Dec 2023
1 answer
14 views

Hi,

I would like to create a new style with the All Caps Font Effect enabled in my Word document (refer to the attached image).

How can I do this programmatically?

I was expecting to be able to do it like this, but I cannot find any property to set the All Caps.

var document = new RadFlowDocument();

var style = new Style("ALL_CAPS", StyleType.Paragraph)
{
    Name = "ALL_CAPS",
    BasedOnStyleId = BuiltInStyleNames.NormalStyleId
};

style.CharacterProperties.AllCaps.LocalValue = true;

document.StyleRepository.Add(style);

Thank you

 

 

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 22 Dec 2023
1 answer
24 views

Hello,

I am trying to upload the stream object received from the 'ToXlsxStream' method of Telerik SpreadSheet processing library to Azure blob container. Unfortunately, it is saving as a blank excel file. I have data in the List object which is getting converted to xlsx stream. Not sure why the excel file is blank. Tried to save the stream to my local file explorer as well. Still, the issue persists. 

Below is the code:

 

  try
   {
Stream exportStream = exportFormat == SpreadDocumentFormat.Xlsx ? workOrderList.ToXlsxStream(columnsData, (string)options.title.ToString(), cellStyleAction: cellStyle) : workOrderList.ToCsvStream(columnsData);

Task.Factory.StartNew(() => AzureHelper.UploadReportOnCloud(exportStream,fileName, ConfigurationManager.AppSettings[Constant.REPORTATTACHMENTCONTAINER]));

}

            catch(Exception ex)
            {

            }

 

Please help me to resolve this issue.  

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 18 Dec 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?