Telerik Forums
Telerik Document Processing Forum
10 answers
684 views

€100 is printed as 100.

What do I do to get my € back?

Dimitar
Telerik team
 answered on 26 Nov 2020
7 answers
1.2K+ views

I am working with the Telerik UI for WinForms 2020 R1 release and I am experiencing a multitude of issues loading PDFs into the Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider via a FileStream (for splitting into individual pages) that I can properly load into the Telerik RadPdfViewer using the Load() method with the file name.

Some of the errors that I am experiencing are "R24 color space not supported", "R25 color space not supported", and "currentIndirectObject should not be null". I cannot provide copies of these PDFs, as they all contain Protected Health Information (PHI), which is protected information under HIPPA.

Dimitar
Telerik team
 answered on 26 Nov 2020
6 answers
888 views

Hi everyone, 

I am trying to convert the following quite simple HTMl to PDF

<!DOCTYPE html>
<html>
<head>
    <title>Configuration</title>
    <meta charset="utf-8" />
    <style type="text/css">
        body{
            font-family:Verdana,Arial;
            color:black
        }
        th{
            background-color: silver
        }
        table {
            width: 100%;
            border: solid 1px gray;
            margin-bottom: 32px
        }
        td {
            border-top: solid 1px gray
        }
    </style>
</head>
<body>
    <hr />
    <h2>Offer Configuration</h2>
    <div style="width:80%;margin-left:auto;margin-right:auto">
        <table align="center" cellpadding="0" cellspacing="0" style="width:600px">
            <tr>
                <th>Document</th>
                <th>Date</th>
                <th>Sales Person</th>
            </tr>
        </table>
        <br />
        <table align="right" cellpadding="0" cellspacing="0" style="width:30%;float:right">
            <tr>
                <th>Total</th>
            </tr>
            <tr>
                <td>${PL_TOTAL}</td>
            </tr>
        </table>
        <br />
    </div>
    <div id="divFooter">
         
    </div>
</body>
</html>

 

This is the code I am using

Dim htmlDocument = ProviderHtml.Import(My.Resources.Resource1.order)
Using output As New FileStream("c:\temp\out.pdf", FileMode.Create)
   ProviderPdf.Export(htmlDocument, output)
End Using
Process.Start("c:\temp\out.pdf")

 

Problem is, the output is very different from source the HTML:

- the HR arenot displayed

- the tables width are ignored

Note that pasting the same HTML here https://demos.telerik.com/aspnet-ajax/editor/examples/import-export/pdf-export/defaultcs.aspx generates an invalid PDF

Is there anything I am missing?

Thanks

Dimitar
Telerik team
 answered on 24 Nov 2020
4 answers
299 views

block.GraphicProperties.StrokeColor = color;

seems to do nothing

Roland
Top achievements
Rank 3
Iron
Iron
Veteran
 answered on 23 Nov 2020
3 answers
491 views
block.GraphicProperties.IsFilled = true;
 block.GraphicProperties.FillColor = color;

 

does not seem to do anything.

 

block.BackgroundColor = color;

 

only colors the line, not the entire rectangle of the block.

 

 

Roland
Top achievements
Rank 3
Iron
Iron
Veteran
 answered on 21 Nov 2020
1 answer
166 views

We are unable to make a simple class library in NET 5 by trying to compile the following class:

using Abp.Domain.Entities;
using Abp.Timing;
using Nuagecare.App.NcDocument.Dtos;
using Nuagecare.App.NcIncident.Dto;
using Nuagecare.Authorization.Users.Dto;
using Nuagecare.NcEntity.Dtos;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Media;
using Telerik.Windows.Documents.Flow.FormatProviders.Docx;
using Telerik.Windows.Documents.Flow.Model;
using Telerik.Windows.Documents.Flow.Model.Editing;
using Telerik.Windows.Documents.Flow.Model.Shapes;
using Telerik.Windows.Documents.Flow.Model.Styles;
using Telerik.Windows.Documents.Model;
using Telerik.Windows.Documents.Primitives;
using Telerik.Windows.Documents.Spreadsheet.Model;
 
namespace Nuagecare.DocumentProcessing
{
    public class DocumentProcessor : IDocumentProcessor
    {
        protected readonly ThemableFontFamily DefaultFontFamily = new ThemableFontFamily(new FontFamily("Calibri"));
        protected readonly ThemableColor DefaultForeground = new ThemableColor(Colors.Black);
        protected readonly double DefaultFontSize = 14.0;
 
        public Byte[] NcEntityMerge(Byte[] input, NcEntityDto ncEntity, string tenancyName, UserEditDto currentUser)
        {
            var FirstNames = ncEntity.GetData<AttributeDataDto>("FirstNames");
            var Surname = ncEntity.GetData<AttributeDataDto>("Surname");
            var Gender = ncEntity.GetData<AttributeDataDto>("Gender");
            var Height = ncEntity.GetData<AttributeDataDto>("Height");
            var Weight = ncEntity.GetData<AttributeDataDto>("Weight");
            var RoomNumber = ncEntity.GetData<AttributeDataDto>("RoomNumber");
            var NHSId = ncEntity.GetData<AttributeDataDto>("NHSId");
            var DateOfBirth = "";
            var Age = "";
 
            try
            {
                var sDateOfBirth1 = ncEntity.GetData<AttributeDataDto>("DateOfBirth"); //US (javascript) format
                DateTime dDateOfBirth = DateTime.ParseExact(sDateOfBirth1.Value, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture).ToLocalTime();
                DateOfBirth = dDateOfBirth.ToString("dd/MM/yyyy");
                Age = CalculateAge(dDateOfBirth).ToString();
            }
            catch (Exception ex)
            {
                DateOfBirth = "unknown";
                Age = "unknown";
            }
 
            DocxFormatProvider provider = new DocxFormatProvider();
            RadFlowDocument document = provider.Import(input);
 
            dynamic mergeRecord = new ExpandoObject();
 
            mergeRecord.DisplayName = ncEntity.DisplayName ?? "";
            mergeRecord.FullName = FirstNames.Value + " " + Surname.Value ?? "";
            mergeRecord.Gender = Gender.Value ?? "";
            mergeRecord.DateOfBirth = DateOfBirth;
            mergeRecord.Age = Age;
            mergeRecord.Height = Height.Value ?? "0";
            mergeRecord.Weight = Weight.Value ?? "0";
            mergeRecord.RoomNumber = RoomNumber.Value ?? "0";
            mergeRecord.NHSId = NHSId.Value ?? "";
            mergeRecord.TenancyName = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(tenancyName) ?? "";
            mergeRecord.CreationTime = Clock.Now.ToString("dddd, dd MMMM yyyy");
            mergeRecord.NuagecareRevisions = "1";
            mergeRecord.CreatedBy = currentUser.Name + " " + currentUser.Surname;
            mergeRecord.CreationText = "Created by " + currentUser.Name + " " + currentUser.Surname + " on " + Clock.Now.ToString("dddd, dd MMMM yyyy");
            mergeRecord.CreatedHistory = "Created by " + currentUser.Name + " " + currentUser.Surname + " on " + Clock.Now.ToString("dddd, dd MMMM yyyy");
            mergeRecord.LastUpdated = Clock.Now.ToString("dddd, dd MMMM yyyy");
 
            List<ExpandoObject> mailMergeDataSource = new List<ExpandoObject>();
            mailMergeDataSource.Add(mergeRecord);
 
            RadFlowDocument mailMergeResult = document.MailMerge(mailMergeDataSource);
 
            //use for testing - outputs to root of Web.Host
            //using (Stream output = new FileStream("CarePlan.docx", FileMode.OpenOrCreate))
            //{
            //    provider.Export(mailMergeResult, output);
            //}
            return provider.Export(mailMergeResult);
        }
 
        public Byte[] ReplaceCarePlanImage(Byte[] input, Byte[] image, IDictionary<string, string> imageNames)
        {
            //deprecated - unable find and replace image
            //possibly user two bookmarks and delete everything in between (i.e. the old image) and replace with the new image
            DocxFormatProvider provider = new DocxFormatProvider();
            RadFlowDocument document = provider.Import(input);
            RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
 
            var carePlanTitleParagraph = document.EnumerateChildrenOfType<Paragraph>().Where(p => p.StyleId.Contains("Title")).First();
 
            if (carePlanTitleParagraph != null)
            {
                Break br = new Break(document);
                editor.MoveToInlineEnd(carePlanTitleParagraph.Inlines.Last());
                editor.InsertParagraph();
 
                var header = document.Sections.First().Headers.Default;
                var headerImages = header.EnumerateChildrenOfType<ImageInline>();
                var footer = document.Sections.First().Headers.Default;
                var footerImages = footer.EnumerateChildrenOfType<ImageInline>();
                var images = document.EnumerateChildrenOfType<ImageInline>();
 
                foreach (var item in images)
                {
                    if (headerImages.Contains(item) || footerImages.Contains(item))
                    {
                        continue;
                    }
                    else
                    {
                        using (MemoryStream memStream = new MemoryStream(image))
                        {
                            var extension = Path.GetExtension(imageNames["FileName"]);
                            var props = System.Drawing.Image.FromStream(memStream);
                            int Width;
                            int Height;
                            if (props.Width > 350)
                            {
                                Width = 350;
                                Height = Convert.ToInt32((Convert.ToDecimal(props.Height) / Convert.ToDecimal(props.Width)) * 350);
                            }
                            else
                            {
                                Width = props.Width;
                                Height = props.Height;
                            }
                            //editor.InsertImageInline(memStream, extension.Replace(".", ""), new System.Windows.Size(Width, Height));
                            item.Image.ImageSource = new Telerik.Windows.Documents.Media.ImageSource(memStream, extension.Replace(".", ""));
                            item.Image.Name = Path.GetExtension(imageNames["FileName"]);
                        }
                    }
                }
 
 
 
            }
 
            return provider.Export(document);
        }
 
        public Byte[] NcAccidentBookMerge(
            Byte[] input,
            CreateOrEditNcDocumentInput ncDocument,
            UserEditDto currentUser,
            List<NcEntityDto> entities,
            List<UserEditDto> staff,
            string IncidentType,
            List<string> AccidentTags
            )
        {
            List<string> EntityNames = new List<string>();
            foreach (var ncEntity in entities)
            {
                var Title = ncEntity.GetData<AttributeDataDto>("Title").Value;
                var FirstNames = ncEntity.GetData<AttributeDataDto>("FirstNames").Value;
                var Surname = ncEntity.GetData<AttributeDataDto>("Surname").Value;
                EntityNames.Add(Title + " " + FirstNames + " " + Surname);
            }
            var ResidentNames = string.Join(", ", EntityNames);
 
            List<string> UserNames = new List<string>();
            foreach (var person in staff)
            {
                var FirstNames = person.Name;
                var Surname = person.Surname;
                UserNames.Add(FirstNames + " " + Surname);
            }
            var StaffNames = string.Join(", ", UserNames);
 
            List<string> DatesOfBirth = new List<string>();
            foreach (var ncEntity in entities)
            {
                var DoB = ncEntity.GetData<AttributeDataDto>("DateOfBirth").Value;
                DatesOfBirth.Add(DoB);
            }
            var DoBs = string.Join(", ", DatesOfBirth);
 
 
            List<string> AccidentTagList = new List<string>();
            foreach (var AccidentTag in AccidentTags)
            {
                AccidentTagList.Add(AccidentTag);
            }
            var AccidentTagNames = string.Join(", ", AccidentTagList);
 
 
            DocxFormatProvider provider = new DocxFormatProvider();
 
            RadFlowDocument document = provider.Import(input);
            dynamic mergeRecord = new ExpandoObject();
 
            mergeRecord.IncidentSummary = ncDocument.DisplayName ?? "";
            mergeRecord.ResidentNames = ResidentNames;
            mergeRecord.DatesOfBirth = DoBs;
            mergeRecord.StaffNames = StaffNames;
            mergeRecord.ReportString = ncDocument.ReportString ?? "";
            mergeRecord.IncidentType = IncidentType ?? "";
            mergeRecord.AccidentTags = AccidentTagNames;
            mergeRecord.OccurrenceDateAndTime = ncDocument.OccurrenceDatetime;
 
            if (UserNames.Count() > 0)
            {
                mergeRecord.FirstPerson = UserNames[0];
            }
 
            mergeRecord.ReportingUser = currentUser.Name + " " + currentUser.Surname;
 
            List<ExpandoObject> mailMergeDataSource = new List<ExpandoObject>();
            mailMergeDataSource.Add(mergeRecord);
 
            RadFlowDocument mailMergeResult = document.MailMerge(mailMergeDataSource);
 
            //use for testing - outputs to root of Web.Host
            //using (Stream output = new FileStream("CarePlan.docx", FileMode.OpenOrCreate))
            //{
            //    provider.Export(mailMergeResult, output);
            //}
            return provider.Export(mailMergeResult);
        }
 
        public Byte[] NcIncidentReportMerge(
            Byte[] input,
            CreateNcIncidentReportDocumentInput incident
            )
        {
            DocxFormatProvider provider = new DocxFormatProvider();
 
            RadFlowDocument document = provider.Import(input);
            dynamic mergeRecord = new ExpandoObject();
 
            mergeRecord.Id = incident.Id;
            mergeRecord.IncidentType = incident.IncidentType;
            mergeRecord.IncidentState = incident.IncidentState;
            mergeRecord.CreationTime = incident.CreationTime;
            mergeRecord.CreatorUser = incident.CreatorUser;
            mergeRecord.OccurrenceDateAndTime = incident.OccurrenceDatetime;
            mergeRecord.IncidentSummary = incident.IncidentSummary ?? "";
            mergeRecord.FirstPersonToIdentifyTheIncidentUser = incident.FirstPersonToIdentifyTheIncidentUser;
            mergeRecord.ReporterUser = incident.ReporterUser;
            mergeRecord.ManagerNotified = incident.ManagerNotified;
            mergeRecord.ReportedToManagerUser = incident.ReportedToManagerUser ?? "";
            mergeRecord.AntecedentNotes = incident.AntecedentNotes;
            mergeRecord.BehaviourNotes = incident.BehaviourNotes;
            mergeRecord.ConsequenceNotes = incident.ConsequenceNotes;
            mergeRecord.PropertyDamage = incident.PropertyDamage ?? "No property damage notes.";
            mergeRecord.PersonalInjuries = incident.PersonalInjuries ?? "No personal injury notes.";
            mergeRecord.MedicalNotes = incident.MedicalNotes ?? "No medical notes.";
            mergeRecord.ExternalAgencyNotes = incident.ExternalAgencyNotes ?? "No external agency notes.";
            mergeRecord.CarePlanNotes = incident.CarePlanNotes ?? "No care plan notes.";
            mergeRecord.RIDDORNotes = incident.RIDDORNotes ?? "No RIDDOR notes.";
            mergeRecord.NextOfKinNotes = incident.NextOfKinNotes ?? "No next of kin notes.";
            mergeRecord.AdditionalNotes = incident.AdditionalNotes ?? "No additional notes.";
 
            if (String.IsNullOrEmpty(string.Join(", ", incident.ResidentNames)))
            {
                mergeRecord.ResidentNames = "No residents involved.";
            }
            else
            {
                mergeRecord.ResidentNames = string.Join(", ", incident.ResidentNames);
            }
 
            if (String.IsNullOrEmpty(string.Join(", ", incident.StaffNames)))
            {
                mergeRecord.StaffNames = string.Join(", ", incident.StaffNames);
            }
            else
            {
                mergeRecord.StaffNames = string.Join(", ", incident.StaffNames);
            }
 
            if (String.IsNullOrEmpty(string.Join(", ", incident.ContactNames)))
            {
                mergeRecord.ContactNames = "No third parties involved.";
            }
            else
            {
                mergeRecord.ContactNames = string.Join(", ", incident.ContactNames);
            }
 
 
            List<ExpandoObject> mailMergeDataSource = new List<ExpandoObject>();
            mailMergeDataSource.Add(mergeRecord);
 
            RadFlowDocument mailMergeResult = document.MailMerge(mailMergeDataSource);
 
            //RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document); // document is an instance of the RadFlowDocument class
            //editor.ReplaceText("code", "source code", true, true);
 
            //use for testing - outputs to root of Web.Host
            //using (Stream output = new FileStream("ReportIncident.docx", FileMode.OpenOrCreate))
            //{
            //    provider.Export(mailMergeResult, output);
            //}
            return provider.Export(mailMergeResult);
        }
 
 
        public Byte[] AppendHistory(Byte[] input, List<NcDocumentHistoryDto> documentHistory)
        {
            DocxFormatProvider provider = new DocxFormatProvider();
            RadFlowDocument document = provider.Import(input);
            //SetupHistoryStyles(document);
            CreateSection(document, "Document history", documentHistory);
 
            //comment out when live
            //using (Stream output = new FileStream("LocalTest.docx", FileMode.OpenOrCreate))
            //{
            //    provider.Export(document, output);
            //}
 
            return provider.Export(document);
        }
 
        #region helpers
        /// <summary> 
        /// For calculating only age 
        /// </summary> 
        /// <param name="dateOfBirth">Date of birth</param> 
        /// <returns> age e.g. 26</returns> 
        private int CalculateAge(DateTime dateOfBirth)
        {
            int age = 0;
            age = DateTime.Now.Year - dateOfBirth.Year;
            if (DateTime.Now.DayOfYear < dateOfBirth.DayOfYear)
                age = age - 1;
            return age;
        }
 
        //private void SetupHistoryStyles(RadFlowDocument document)
        //{
        //    var heading1 = document.StyleRepository.AddBuiltInStyle(BuiltInStyleNames.GetHeadingStyleIdByIndex(1));
        //    var heading2 = document.StyleRepository.AddBuiltInStyle(BuiltInStyleNames.GetHeadingStyleIdByIndex(2));
        //}
 
        private void SetupCarePlanStyles(RadFlowDocument document)
        {
            var heading1 = document.StyleRepository.AddBuiltInStyle(BuiltInStyleNames.GetHeadingStyleIdByIndex(1));
            heading1.CharacterProperties.FontFamily.LocalValue = DefaultFontFamily;
            heading1.CharacterProperties.FontSize.LocalValue = 32.0;
            heading1.CharacterProperties.FontWeight.LocalValue = System.Windows.FontWeights.Bold;
            heading1.CharacterProperties.ForegroundColor.LocalValue = DefaultForeground;
            heading1.ParagraphProperties.PageBreakBefore.LocalValue = true;
        }
 
        private void CreateSection(RadFlowDocument document, string title, List<NcDocumentHistoryDto> documentHistory)
        {
            //delete section if exists
            Section sectionFound = null;
            var existingParagraph = FindHeaderAsParagraphContainingText(document, title);
            if (existingParagraph != null)
            {
                foreach (var sectionInstance in document.EnumerateChildrenOfType<Section>())
                {
                    if (sectionInstance == existingParagraph.BlockContainer)
                    {
                        sectionFound = sectionInstance;
                        break;
                    }
                }
                if (sectionFound != null)
                {
                    document.Sections.Remove(sectionFound);
                }
            }
 
            RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
            Section section = editor.InsertSection();
            section.SectionType = SectionType.Continuous;
            section.PageSize = PaperTypeConverter.ToSize(PaperTypes.A4);
 
            var paragraph = section.Blocks.AddParagraph();
            editor.MoveToParagraphStart(paragraph);
            paragraph.StyleId = BuiltInStyleNames.GetHeadingStyleIdByIndex(1);
            editor.InsertText(title);
 
            InsertTable(section, editor, documentHistory);
        }
 
        private void InsertTable(Section section, RadFlowDocumentEditor editor, List<NcDocumentHistoryDto> documentHistory)
        {
            var paragraph = section.Blocks.AddParagraph();
            editor.MoveToParagraphStart(paragraph);
 
            Table table = section.Blocks.AddTable();
 
            var row = table.Rows.AddTableRow();
 
            var cell = row.Cells.AddTableCell();
            cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Fixed, 120);
            SetCellText(editor, cell, "History", bold: true, background: new ThemableColor(Colors.LightSteelBlue), horizontalAlignment: Alignment.Left);
 
            //cell = row.Cells.AddTableCell();
            //cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Fixed, 120);
            //SetCellText(editor, cell, "User", bold: true, background: new ThemableColor(Colors.LightSteelBlue), horizontalAlignment: Alignment.Left);
 
            //cell = row.Cells.AddTableCell();
            //cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Auto);
            //SetCellText(editor, cell, "Report string", bold: true, background: new ThemableColor(Colors.LightSteelBlue), horizontalAlignment: Alignment.Left);
 
            //cell = row.Cells.AddTableCell();
            //cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Fixed, 100);
            //SetCellText(editor, cell, "Filename", bold: true, background: new ThemableColor(Colors.LightSkyBlue), horizontalAlignment: Alignment.Left);
 
 
            foreach (var history in documentHistory)
            {
                row = table.Rows.AddTableRow();
 
                //cell = row.Cells.AddTableCell();
                //SetCellText(editor, cell, history.CreationTime.ToLocalTime().ToString("dd/MM/yyyy HH:mm"), horizontalAlignment: Alignment.Left, verticalAlignment: VerticalAlignment.Top);
 
                //cell = row.Cells.AddTableCell();
                //SetCellText(editor, cell, history.CreatorUserName, horizontalAlignment: Alignment.Left, verticalAlignment: VerticalAlignment.Top);
 
                cell = row.Cells.AddTableCell();
                SetCellText(editor, cell, history.ReportString, horizontalAlignment: Alignment.Left, verticalAlignment: VerticalAlignment.Top);
 
                //cell = row.Cells.AddTableCell();
                //var test = Path.GetFileName(history.Uri);
                //SetCellText(editor, cell, Path.GetFileName(history.Uri), horizontalAlignment: Alignment.Left, verticalAlignment: VerticalAlignment.Top);
            }
        }
 
        private void SetCellText(RadFlowDocumentEditor editor, TableCell cell, string text, string fontFamily = null,
                               double? fontSize = null, bool? bold = null, bool? italic = null, TableCellBorders borders = null,
                               ThemableColor background = null, ThemableColor foreground = null, Alignment? horizontalAlignment = null,
                               VerticalAlignment? verticalAlignment = null)
        {
            cell.IgnoreCellMarkerInRowHeightCalculation = true;
            cell.Padding = new Padding(1);
 
            var paragraph = cell.Blocks.AddParagraph();
            paragraph.StyleId = BuiltInStyleNames.NormalStyleId;
            paragraph.Properties.SpacingBefore.LocalValue = 0;
            paragraph.Properties.SpacingAfter.LocalValue = 0;
 
            editor.MoveToParagraphStart(paragraph);
 
            if (borders != null)
                cell.Borders = borders;
 
            if (background != null)
                cell.Shading.BackgroundColor = background;
 
            editor.CharacterFormatting.FontFamily.LocalValue = string.IsNullOrEmpty(fontFamily)
                                                                   ? DefaultFontFamily
                                                                   : new ThemableFontFamily(fontFamily);
 
            editor.CharacterFormatting.FontSize.LocalValue = fontSize ?? DefaultFontSize;
 
            //editor.CharacterFormatting.FontWeight.LocalValue = (bold ?? false) ? FontWeights.Bold : FontWeights.Normal;
            //editor.CharacterFormatting.FontStyle.LocalValue = (italic ?? false) ? FontStyles.Italic : FontStyles.Normal;
 
            editor.CharacterFormatting.ForegroundColor.LocalValue = foreground ?? DefaultForeground;
 
            cell.VerticalAlignment = verticalAlignment != null ? verticalAlignment.Value : VerticalAlignment.Center;
 
            paragraph.TextAlignment = horizontalAlignment != null ? horizontalAlignment.Value : Alignment.Center;
 
            editor.InsertText(string.IsNullOrEmpty(text) ? " " : text);
        }
 
 
        private Paragraph FindHeaderAsParagraphContainingText(RadFlowDocument document, string searchedText)
        {
            foreach (var titleParagraph in document.EnumerateChildrenOfType<Paragraph>().Where(p => p.StyleId.Contains("Heading")))
            {
                StringBuilder paragraphContent = new StringBuilder();
                foreach (var run in titleParagraph.EnumerateChildrenOfType<Run>())
                {
                    if (run.Text == searchedText)
                    {
                        return titleParagraph;
                    }
                }
            }
            return null;
        }
 
 
        #endregion
    }
}

 

Can you tell us what Nuget packages we need to install to make this work?

Peshito
Telerik team
 answered on 16 Nov 2020
3 answers
287 views

I am trying to load a Word document and export to PDF, but the export file change the doc content when download it.

I am using the demo provide in the next url https://demos.telerik.com/aspnet-ajax/wordsprocessing/exporttopdf/defaultcs.aspx.

The changes in the content are:

- The bold format removed
- Some spaces are removed
-The footer is removed

 

I would like to know if i can use RadFlowDocument to load a document in format docx and export to PDF format without the format document will be modified .

 

I hope to receive help

Thanks for your time.

Vladislav
Telerik team
 answered on 09 Nov 2020
4 answers
986 views
Hi,

I am struggling to alter the linespacing on the telerik.windows.documents.fixed.model.Editing.Block. I use the following line of code;

textBlock1.LineSpacing = 10

However this doesn't seem to have any effect. Nothing crashes and there is no problems running the code. If I break at this line the value is never set. I can use the Visual Studio debugger to set the value and it works perfectly. Any ideas?

Secondly when using multiline text from a database the block doesn't seem to respect newlines. I have to use the following code which seems a bit excessive.
 
01.Private Sub InsertText(textBlock As Editing.Block, descriptionText As String)
02.           Dim ascii() As Byte = System.Text.Encoding.ASCII.GetBytes(descriptionText)
03.           For i As Integer = 0 To descriptionText.Length - 1
04.               If ascii(i) = 13 Then
05.                   textBlock.InsertLineBreak()
06.               Else
07.                   textBlock.InsertText(descriptionText(i))
08.               End If
09.           Next
10.       End Sub

Any help would be much appreciated.

Regards,

Shaun
Dimitar
Telerik team
 answered on 27 Oct 2020
1 answer
89 views

Hi all, I'm having trouble locating/seeing the NamedDestinations collection and the Bookmarks collection.

Online documentation indicates both are exposed by the RadFixedDocument object.

I'm using version 2019.2.503.40 of Winforms UI and coding in VB.Net if that matters.  All documentation indicates it was available in Q3 of 2018.

Am I missing something obvious or is it not available?  I've seen forum posts referencing WPF...

Thanks

Dimitar
Telerik team
 answered on 26 Oct 2020
5 answers
859 views
I am trying to create a PDF document and i want to setup a header and a footer, this should be the same for all the page. and then i want to insert data from stored procedure into this pdf file and format it. i have attached a template along with this. It will be very helpful if you can give me some suggestions.
Dimitar
Telerik team
 answered on 26 Oct 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?