Telerik Forums
Telerik Document Processing Forum
1 answer
504 views

Hi,

I have a simple Excel file with just one sheet and one image in .xls and in .xlsx (attached in the zip file).

When reading the files using the XlsFormatProvider or XlsxFormatProvider, I get a workbook. When iterating the shapes on every sheet, I have a different result. I can retrieve the image using the XlsxFormatProvider in the xlsx file, but I'm not getting any shapes in the .xls file using the XlsFormatProvider.

Some code below:

var provider = new XlsxFormatProvider();
using (var fs = File.OpenRead("image.xlsx"))
{
    var workbook = provider.Import(fs);
    Assert.AreEqual(workbook.ActiveWorksheet.Shapes.Images.Count(), 1);
}

Should I be doing this differently? Or is this a known limitation?

I'm using version 2021.3.909.40.

Edit: just noticed that the same goes for charts.

Tanya
Telerik team
 answered on 08 Nov 2021
8 answers
343 views
Hi!

I adapted the example "CreateModifyExport" in xaml-sdk to create a workbook then export it via XlsxFormatProvider. This works fine except that when I open the exported file in Excel 2013 (64 bit) there are no gridlines visible. Maybe I missed something but there is no code where gridlines are enabled/disabled.
Second issue is that AutoFitWidth is not working correctly, the column width does not fit the text.

Regards
Neils 
Edward
Top achievements
Rank 1
Veteran
Iron
Iron
 answered on 05 Nov 2021
1 answer
2.2K+ views
Can I export Html to PDf using PDFStreamWriter or PDFFormatProvider?
Dimitar
Telerik team
 answered on 04 Nov 2021
1 answer
626 views

Hello, 

I am currently trying to write in the "Modele.docx" document that is just a template. For each OperationAffecteeViewModel, I want to write in this template, and then copy what i just wrote in "documentFinal.docx". But the application crashes at the line 

documentFinal.Sections.Add(copySection);

with the following error : The document element is associated with another document

here's the code :


 private async Task GenererOperations()
        {
            RadFlowDocument document = new RadFlowDocument(); ;
            RadFlowDocument documentFinal = new RadFlowDocument();
            var docxProvider = new DocxFormatProvider();



            foreach (OperationAffecteeViewModel operationAffectee in OperationsAffectees)
            {
                using (Stream input = File.OpenRead("Modele.docx"))
                {
                    document = docxProvider.Import(input);
                }
                RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
                GoToBookmark(document, editor, "OUVRAGE");
                editor.InsertText(operationAffectee.LibelleOuvrage);
                GoToBookmark(document, editor, "OPERATION");
                editor.InsertText(operationAffectee.LibelleTypeOperation);
                GoToBookmark(document, editor, "DATE_PRÉVUE");
                editor.InsertText(operationAffectee.DatePrevisionnelle.Date.ToString("dd/MM/yyyy"));

            }

            //chargement de la police pour éviter de perdre les caractères spéciaux lors de l'exportation
            var fontData = File.ReadAllBytes(@"wwwroot/fonts/Calibri_Regular.ttf");
            FontsRepository.RegisterFont(new Telerik.Documents.Core.Fonts.FontFamily("Calibri"), FontStyles.Normal, FontWeights.Normal, fontData);

            var providerPdf = new PdfFormatProvider();
            using (Stream outStream = File.OpenWrite("sample.pdf"))
            {
                providerPdf.Export(document, outStream);
            }

            await InvokeAsync(() => this.StateHasChanged());
        }

        
        private void GoToBookmark(RadFlowDocument document, RadFlowDocumentEditor editor, string bookmarkName)
        {
            var bookmark = document.EnumerateChildrenOfType<BookmarkRangeEnd>().FirstOrDefault(rangeStart => rangeStart.Bookmark.Name == bookmarkName);
            if (bookmark != null)
            {
                editor.MoveToInlineEnd(bookmark.Paragraph.Inlines[0]);
            }
        }


Thanks for helping me ! 

Leslie
Top achievements
Rank 1
Iron
 answered on 29 Oct 2021
0 answers
513 views

Hello,

I have a weird situation, that the line:

run.FontWieght = FontWieghts.Bold;

doesn't work.

in second hand, every other character attribute is working perfectly (like FontStyle, FontUnderline, Font size and so on).

can anyone guess what could be the issue? 

 

michael
Top achievements
Rank 1
 asked on 27 Oct 2021
1 answer
188 views

Hello,

Is there a way we can add the signature captured via a SignaturePad and add it to the RadFixedPage? Also certify that signature with a x509 self signed certificate?

 

Thanks,

Urmila

Dimitar
Telerik team
 answered on 27 Oct 2021
1 answer
453 views
Is there a way to create a horizontal line in a document using the RadWordsProcessing API? I am looking for something similar to the Microsoft Word horizontal line that can be inserted by typing "---". 
Dimitar
Telerik team
 answered on 25 Oct 2021
1 answer
326 views

Hello,

I am exporting the text and image as shown in the attached program. The resulting output shows the text floating around the image which is left aligned:

What I want to achieve now is the reverse of it so that the image gets right-aligned with text aligning to the left and floating around the image on the right.

How do I do that?

Thanks,

Adnan

Dimitar
Telerik team
 answered on 18 Oct 2021
0 answers
322 views

Hello,

i'm trying to convert some docx to PDF. The resulting document looks quite similar to the original, however i have 2 main issues:

  • Bullet lists are not present on the exported document
  • Bold text is never present in the exported document
  • The exported pdf file doesn't seem to be a valid PDF/A-3U one checking with some online validator

 

i've attached a very simple example.

Here is the code i'm using to generate the pdf:


public byte[] Convert()
{
    //to support fonts
    Telerik.Windows.Documents.Extensibility.FontsProviderBase fontsProvider = new FontsProvider();
    Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.FontsProvider = fontsProvider;

    //to support PNG's
    Telerik.Windows.Documents.Extensibility.JpegImageConverterBase jpegImageConverter = new Telerik.Documents.ImageUtils.JpegImageConverter();
    Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = jpegImageConverter;

    var importProvider = new DocxFormatProvider();
    byte[] templateData = GetTemplateData(); 
    var template = importProvider.Import(templateData);

    var pdfProvider = new PdfFormatProvider();
    PdfExportSettings settings = new();
    settings.ComplianceLevel = PdfComplianceLevel.PdfA3U;
    pdfProvider.ExportSettings = settings;
    var pdfBytes = pdfProvider.Export(template);
    return pdfBytes;
}

//... end class

public class FontsProvider : Telerik.Windows.Documents.Extensibility.FontsProviderBase
    {
        public override byte[] GetFontData(FontProperties fontProperties)
        {
            string fontFileName = fontProperties.FontFamilyName + ".ttf";
            string fontFolder = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);
            string targetPath = Path.Combine(fontFolder, fontFileName);

            DirectoryInfo directory = new DirectoryInfo(fontFolder);
            FileInfo[] fontFiles = directory.GetFiles("*.ttf");
            if (fontFiles.Any(s => s.Name.Equals(fontFileName, StringComparison.InvariantCultureIgnoreCase)))
            {
                using (FileStream fileStream = File.OpenRead(targetPath))
                {
                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        fileStream.CopyTo(memoryStream);
                        return memoryStream.ToArray();
                    }
                }
            }

            return null;
        }
    }

 

am i missing something?

Thanks in advance for your help!

Carmine
Top achievements
Rank 1
 asked on 12 Oct 2021
0 answers
336 views

I try to import a pdf file from a external source. This contains a Typ3 font but I cannot import it.

My telerik version is 2021.2 so it should work. 

PdfViewer: Add support for Type 3 fonts (telerik.com) is completet in R1 2021.

I try to Import the file like this:

                var provider = new PdfFormatProvider();
                var document = provider.Import(File.ReadAllBytes(dokument.Hyperlink));

And I get this Exception: Cannot create TrueType font type from FontFile3 with Type1C subtype!

 

   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontFile3Stream.CreateOpenTypeFontSource(FontType fontType)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontFile3Stream.ToFontSource(FontType fontType)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.TrueTypeFontObject.TryCreateSimpleFontFromFontFile(SimpleFont& font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.SimpleFontObject.TryCreateFontFromFontFile(FontBase& font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontObject.ToFont(PostScriptReader reader, IRadFixedDocumentImportContext context)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.RadFixedDocumentImportContext.GetFont(PostScriptReader reader, FontObject font)

 

 

How can I import them correctly?

Marco
Top achievements
Rank 1
Iron
Iron
Iron
 asked on 06 Oct 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?