Telerik Forums
Telerik Document Processing Forum
1 answer
193 views

Hi,

Is it possible to export Arabic characters using Telerik Document Processing libraries ??

Tanya
Telerik team
 answered on 08 Nov 2016
5 answers
225 views

Hi;

I'm having problems, when I try to export with HtmlFormatProvider the OpenOffice/LibreOffice docx files.

If the file is created with MSWord there's no problems, all works fine, the problem is with LibreOffice/Openoffice generated-documents.

Please, I need help 'cause some of my customers uses LibreOffice to create the docx documents.

+++++++++++++++++++++++ CODE ++++++++++++++++++++++++++

                docxProvider = new DocxFormatProvider();
                htmlProvider = new HtmlFormatProvider();

                if(this._DocXByteArray == null)
                    this._DocXByteArray = System.IO.File.ReadAllBytes(this._DocXPath);

                document = docxProvider.Import(this._DocXByteArray);
                        
                htmlProvider.ExportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
                htmlProvider.ExportSettings.ImagesExportMode = ImagesExportMode.Embedded;
                htmlProvider.ExportSettings.StylesExportMode = StylesExportMode.Embedded;
                        
                string html = htmlProvider.Export(document); //heres crash with the down error trace

+++++++++++++++++++++++ CODE ++++++++++++++++++++++++++

I'm always getting this error

++++++++++++++++++++++++ ERROR TRACE ++++++++++++++++++++++++

  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.ParagraphElementBase.GetDefaultStyleId(IHtmlExportContext context, String& styleId)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.HtmlElementBase.CopyStyleFrom(IHtmlExportContext context, IElementWithStyle element)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.ParagraphElementBase.OnBeforeWrite(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.HtmlElementBase.Write(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.HtmlElementBase.WriteContent(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.HtmlElementBase.Write(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Export.HtmlExporter.ExportDocumentFragment(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Export.HtmlExporter.Export(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider.ExportOverride(RadFlowDocument document, Stream output)
  at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
  at Telerik.Windows.Documents.Common.FormatProviders.TextBasedFormatProviderBase`1.Export(T document)

++++++++++++++++++++++++ END ERROR TRACE ++++++++++++++++++++++++

 

Thx

Mihail
Telerik team
 answered on 03 Nov 2016
1 answer
59 views
Hi;
I'm having problems, when I try to export with HtmlFormatProvider the OpenOffice/LibreOffice docx files.
If the file is created with MSWord there's no problems, all works fine, the problem is with LibreOffice/Openoffice generated-documents.
Please, I need help 'cause some of my customers uses LibreOffice to create the docx documents.
+++++++++++++++++++++++ CODE ++++++++++++++++++++++++++
                docxProvider = new DocxFormatProvider();
                htmlProvider = new HtmlFormatProvider();

                if(this._DocXByteArray == null)
                    this._DocXByteArray = System.IO.File.ReadAllBytes(this._DocXPath);

                document = docxProvider.Import(this._DocXByteArray);
                        
                htmlProvider.ExportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
                htmlProvider.ExportSettings.ImagesExportMode = ImagesExportMode.Embedded;
                htmlProvider.ExportSettings.StylesExportMode = StylesExportMode.Embedded;
                        
                string html = htmlProvider.Export(document); //heres crash with the down error trace
+++++++++++++++++++++++ CODE ++++++++++++++++++++++++++
I'm always getting this error
++++++++++++++++++++++++ ERROR TRACE ++++++++++++++++++++++++
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.ParagraphElementBase.GetDefaultStyleId(IHtmlExportContext context, String& styleId)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.HtmlElementBase.CopyStyleFrom(IHtmlExportContext context, IElementWithStyle element)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.ParagraphElementBase.OnBeforeWrite(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.HtmlElementBase.Write(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.HtmlElementBase.WriteContent(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Model.Elements.HtmlElementBase.Write(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Export.HtmlExporter.ExportDocumentFragment(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.Export.HtmlExporter.Export(IHtmlWriter writer, IHtmlExportContext context)
  at Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider.ExportOverride(RadFlowDocument document, Stream output)
  at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
  at Telerik.Windows.Documents.Common.FormatProviders.TextBasedFormatProviderBase`1.Export(T document)
++++++++++++++++++++++++ END ERROR TRACE ++++++++++++++++++++++++

Thx
Mihail
Telerik team
 answered on 01 Nov 2016
1 answer
142 views
For example if I have a CellSelection coordinates how can I retrieve the values from all cells and move it like a cut and paste text in another part of my export excel file? 
Boby
Telerik team
 answered on 01 Nov 2016
8 answers
2.2K+ views
Hello,

I'm attempting to split a Pdf by removing pages.  After page removal, I export the RadFixedDocument back to a PDF through a stream.  I've tried various streams like MemoryStream and FileStream without luck.  All PDFs come about with blank pages.  Code is below.

public static IEnumerable<string> SplitPdf(PdfFileDefinition pdfFileDef)
       {
           List<string> pdfs = new List<string>();
           Stream stream = null;
           PdfFormatProvider formatProvider = new PdfFormatProvider();
 
           // Save temp file to disk
               var path = @"c:\temp";
               if(!Directory.Exists(path))
                   Directory.CreateDirectory(path);
            
           // Pdf streams must support read & seek operations    
           var fileUri = new Uri(pdfFileDef.FilePath);
            
           // Is pdf a file or resource
           if (fileUri.Scheme == "file")
           {
                 var tempFilePath = Path.Combine(path, "temp.pdf");
                 File.Copy(Path.Combine(path,fileUri.LocalPath), tempFilePath,true);
                 stream = File.Open(tempFilePath, FileMode.Open,FileAccess.Read);              
           }
           else if (fileUri.Scheme == "pack" && fileUri.Host.Contains("siteoforigin"))
           {                              
                stream = Application.GetRemoteStream(fileUri).Stream;   
           }
                        
           foreach(var pageBreak in pdfFileDef.PageBreaks)
           {                                                       
               RadFixedDocument document = new PdfFormatProvider(stream, FormatProviderSettings.ReadOnDemand).Import();
               RadFixedDocument splitDocument = new RadFixedDocument();  
               splitDocument = document;
                           
               for (int pageNumber = splitDocument.Pages.Count - 1; pageNumber >= 0; pageNumber--)
               {
                   if(!pageNumber.IsBetween<int>(pageBreak.StartPage, pageBreak.EndPage))
                   {
                       splitDocument.Pages.RemoveAt(pageNumber);
                   }
 
               }
                              
              // Generate temp pdf file for review
               var fileName = Path.Combine(path, Path.GetRandomFileName());
               fileName = Path.ChangeExtension(fileName, ".pdf");             
                               
               // Export filestream to Pdf
               using(var fs = new FileStream(fileName,FileMode.Create))
               {                               
                    formatProvider.Export(splitDocument, fs);    
                     
               }                                           
 
               pdfs.Add(fileName);
                                                              
           }
 
           return pdfs;
       }
Paulo Goncalves
Top achievements
Rank 2
 answered on 31 Oct 2016
1 answer
1.2K+ views

Is there a way to set column widths to auto fit? I see that RadSpreadProcessing has ColumnSelection.AutoFitWidth(). Is there any way to get that functionality with IColumnExporter? All I see is SetWidthInPixels() and SetWidthInCharacters(), but I can't get either of those values when creating the spreadsheet.

If not, are there any plans for this functionality?

Nikolay Demirev
Telerik team
 answered on 26 Oct 2016
4 answers
874 views

I am starting with an existing document, which is attached, and trying to figure out how to correctly set the position so I can start adding text at a certain point in the document.  The key is how do you find that point so the RadFlowDocumentEditor can begin adding and creating tables in the document.  I am not trying to do a mail merge.  All I want to do is get a certain position within the document to begin adding text.  Is there something special you need to do inside of the word document itself?  Here is the code I used to try and hopefully set the position, but it adds text to the top of the document and wipes out the existing text.  If you could provide me a code snippet or some guidance, I would appreciate it.

 

DocxFormatProvider provider = new DocxFormatProvider();
using (Stream input = File.OpenRead("Input.docx"))
{
RadFlowDocument document = provider.Import(input);
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
Run firstRun = document.EnumerateChildrenOfType<Run>().First();
editor.MoveToInlineEnd(firstRun);
editor.InsertText("Hello word!");

using (Stream output = File.OpenWrite("Output.docx"))
{
           provider.Export(document, output);
}
}

Mihail
Telerik team
 answered on 17 Oct 2016
1 answer
164 views

 

 

 

 

DocxFormatProvider provider = new DocxFormatProvider();
using (Stream input = File.OpenRead("InputFile.docx"))
{
    RadFlowDocument document = provider.Import(input);
    RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
    Run firstRun = document.EnumerateChildrenOfType<Run>().First();
editor.MoveToInlineEnd(firstRun);
editor.InsertText("Hello word!");
//DocxFormatProvider provider = new DocxFormatProvider();
using (Stream output = File.OpenWrite("F:/POCForSOW/ConsoleApplication1/ConsoleApplication1/Sample.docx"))
{
//RadFlowDocument document = CreateRadFlowDocument();
provider.Export(document, output);
}

Mihail
Telerik team
 answered on 14 Oct 2016
1 answer
185 views

Hello,

Importing and exporting this pdf results in an unreadable text.

The attached image "ImportedFile" shows how the imported pdf looks like. The other image, "ExportedFile", shows the result of the export.

 

Here's a code example to import and export:

private static void ImportAndExport()
{
    var fixedDocFormatProvider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
    RadFixedDocument fixedDocument;
 
    var importFile = @"C:\ImportedFile.pdf";
 
    using (var stream = File.OpenRead(importFile))
    {
        fixedDocument = fixedDocFormatProvider.Import(stream);
    }
 
    var formatProvider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
 
    var exportFile = @"C:\ExportedFile.pdf";
 
    using (var stream = new FileStream(exportFile, FileMode.Create))
    {
        formatProvider.Export(fixedDocument, stream);
    }
}

Any ideas why is this happening?

 

Thanks

Deyan
Telerik team
 answered on 30 Sep 2016
5 answers
627 views

Hi,

Is it possible to export Unicode characters from supplementary planes (above Plane 0), i.e. those that need more than 2 bytes of storage?  They seem to be silently ignored (normally a replacement character such as '?' is shown for unsupported code points).

A simple test shows that small value code points are OK but longer ones are ignored.  This should show 2 smiley faces:

var editor = new FixedContentEditor(container);
editor.DrawText("Smiley face OK: \u263A   Smiley ignored: \uD83D\uDE0A");

Any comments/suggestions would be welcome.

Thanks,
Chris

UI for WPF R2 2016 SP1

Boby
Telerik team
 answered on 27 Sep 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?