Telerik Forums
Telerik Document Processing Forum
1 answer
159 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
178 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
616 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
3 answers
372 views

Hello!

We try to import HTML Source Code, and export it to OpenXml.

The problem is, that the highlighting - color of the Runs (RunProperties) does not match with the HTML-highlighting-colors.

The HTML string is for example:

<p style="margin-top: 0px;margin-bottom: 0px;line-height: 1.15;"><span style="font-family: 'Verdana';font-size: 16px;background-color: #F79646;">Test</span><span style="font-family: 'Verdana';font-size: 16px;"></span></p>

The WordProcessing - Code:

HtmlFormatProvider cHtmlFormatProvider = new HtmlFormatProvider();
RadDocument cDocument = cHtmlFormatProvider.Import(sHtmlString);
 
DocxFormatProvider cDocxFormatProvider = new DocxFormatProvider();
using (var fileStream = new MemoryStream())
{
    cProvider.Export(cDocument, fileStream);
    using (WordprocessingDocument wp = WordprocessingDocument.Open(fileStream, true))
    {
         //Paragraphs and runs etc...
    }
}

 

But if i check the RunProperties of the Run (of the Paragraph), i see that the highlighting color is 'yellow' but it should be #F79646 (Orange).

There is no other possibility for us, we have to export it to HTML.

The Html Source Code was produced by RadRichTextBox.

Please help us.

Thank you.

 

Tanya
Telerik team
 answered on 22 Sep 2016
3 answers
739 views

Hi, Im trying to convert docx/xlsx documents to jpg images. The only way I know of how to do this is via the WPF telerik. By converting a Docx/XLSX to PDF then PDF to jpg image. If there is any other way please let me know. This is what I'm currently doing:

XLSX

Dim stream As FileStream = File.OpenRead(inputPath)
Dim document As RadFixedDocument
 
Dim fileFormatProvider As Spreadsheet.FormatProviders.IWorkbookFormatProvider = New Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider()
Dim workbook As Spreadsheet.Model.Workbook
Using stream
   workbook = fileFormatProvider.Import(stream)
End Using
 
Dim formatProvider As New Spreadsheet.FormatProviders.Pdf.PdfFormatProvider()
document = formatProvider.ExportToFixedDocument(workbook)
 
Dim page As RadFixedPage = document.Pages(0)
Dim factory2 As New ThumbnailFactory
Dim size2 = New Size(1200, 1800)
 
'This line throws an error
Dim imageSrc As ImageSource = factory2.CreateThumbnail(page, size2)

 

DOCX

Dim stream As FileStream = File.OpenRead(inputPath)
Dim document As RadFixedDocument
 
Dim docxformatprovider As New Flow.FormatProviders.Docx.DocxFormatProvider()
Dim docxdocument As Flow.Model.RadFlowDocument = docxformatprovider.Import(stream)
Dim formatProvider As New Flow.FormatProviders.Pdf.PdfFormatProvider()
document = formatProvider.ExportToFixedDocument(docxdocument)
 
'To image conversion
Dim page As RadFixedPage = document.Pages(0)
Dim factory2 As New ThumbnailFactory
Dim size2 = New Size(1200, 1800)
 
'This line throws an error
Dim imageSrc As ImageSource = factory2.CreateThumbnail(page, size2)

 

The code is a little bit different, the xlsx code contains Using Stream but makeing no difference. 

The last line throws an error: An unhandled exception of type 'System.NullReferenceException' occurred in Telerik.Windows.Controls.FixedDocumentViewers.dll

But if I save the Flowdocument as a PDF, then open it again it wont be a problem to create an imageSrc with the fixedpage, this is of course not a desirable situation:

'Here I already converted the document to a RadFlowDocument
 
Dim provider As New Fixed.FormatProviders.Pdf.PdfFormatProvider()
Using output As Stream = File.OpenWrite(inputPath & ".pdf")
    provider.Export(document, output)
End Using
 
Dim stream2 As FileStream = File.OpenRead(inputPath & ".pdf")
Dim pdf As New Fixed.FormatProviders.Pdf.PdfFormatProvider(stream2, Fixed.FormatProviders.FormatProviderSettings.ReadOnDemand)
document = pdf.Import()
 
Dim page As RadFixedPage = document.Pages(0)
Dim factory2 As New ThumbnailFactory
Dim size2 = New Size(1200, 1800)
 
'No problem, image can be created.
Dim imageSrc As ImageSource = factory2.CreateThumbnail(page, size2)

This only works for the DOCX file. The XLSX can't be saved from the workbook file. 

I hope you can help me.

These are the guides I used:
http://docs.telerik.com/devtools/document-processing/libraries/radwordsprocessing/formats-and-conversion/pdf/pdfformatprovider.html
http://docs.telerik.com/devtools/document-processing/libraries/radwordsprocessing/formats-and-conversion/docx/docxformatprovider.html
http://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/formats-and-conversion/xlsx/xlsxformatprovider.html
http://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/formats-and-conversion/pdf/pdfformatprovider.html
http://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/formats-and-conversion/pdf/pdfformatprovider.html
http://www.telerik.com/forums/convert-pdf-to-jpg

Tanya
Telerik team
 answered on 20 Sep 2016
2 answers
115 views

Hi,

Is it possible to generate PDFs containing transparent gradients?

Setting the alpha component on a solid object (RgbColor) works as expected; it's not fully opaque and any colours behind the show though.  Setting the alpha component on GradientStops appears to have no effect; the colors are shown at full opacity

This can be demonstrated with the API documentation example http://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/concepts/colors-and-color-spaces#patterncolor and simply changing the LinearGradient stops to include an alpha value that is less than 255:

linearGradient.GradientStops.Add(new GradientStop(new RgbColor(10, 0, 207, 0), 0));
linearGradient.GradientStops.Add(new GradientStop(new RgbColor(10, 0, 102, 204), 1));

When rendered this shows a gradient with full opacity (attached) when it would be expected to be near transparent.

Thanks,
Chris

UI for WPF R2 2016 SP1

Chris
Top achievements
Rank 1
 answered on 16 Sep 2016
1 answer
262 views

Hi,

My name is Lokesh G, I got struck while using this Replace Method in RadFlowDocumentEditor. It's showing some error at ReplaceText().

Can you help me to over come this... 

Error Message: Onhover on ReplaceText seeing the below message

RadFlowDocumentEditor doesn't contain a definition for ReplaceText and no extension method 'ReplaceText' accepting  a first argument of type RadFlowDocumentEditor could not be found

How I used and Declared it:
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);


editor.ReplaceText(FindWhatTextBox.Text, ReplaceWithTextBox.Text, MatchCaseCheckBox.Checked, MatchWholeWordCheckBox.Checked);

Tanya
Telerik team
 answered on 14 Sep 2016
3 answers
897 views
You've officially made things confusing by having the different libraries for the spreadsheet.  I need a good (current) example on how to do an easy import and export of a Spreadsheet that I am using/showing in a Spreadsheet Control.  Also, I'll be saving the spreadsheet to a SQL table so do you have an example where I don't have to write out to a FileStream first?  I'd like to go directly from a Stream to a byte array without writing to the file system.
Nikolay Demirev
Telerik team
 answered on 13 Sep 2016
6 answers
479 views

I'm sure this is possible but I cant quite get the provider usage figured out. I have a string  of HTML I want to output as a PDF . This does not work, what am i doing wrong?

    protected void test(string htmlString)

    {
        HtmlFormatProvider htmlDoc = new HtmlFormatProvider();
        htmlDoc.Import(htmlString);
        byte[] renderedBytes = null;

        IFormatProvider<RadFlowDocument> formatProvider = new PdfFormatProvider();
        using (MemoryStream ms = new MemoryStream())
        {
            formatProvider.Export(htmlDoc, ms); // this is invalid
            renderedBytes = ms.ToArray();
        }
        Response.Clear();
        Response.AppendHeader("Content-Disposition", "attachment; filename=ExportedFile" + ".pdf");
        Response.ContentType = "application/pdf";
        Response.BinaryWrite(renderedBytes);
        Response.End();

Nikolay Demirev
Telerik team
 answered on 13 Sep 2016
8 answers
405 views
Is it possible to run the XlsxFormatProvider in an Async to report the progress on a RadProgressBar?
Carlitos
Top achievements
Rank 1
 answered on 06 Sep 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?