Telerik Forums
Telerik Document Processing Forum
4 answers
385 views
is it possible (and if so how to) create pdf from doc file and to crate pdf from tif/tiff file with multiple pages?
Georgi
Telerik team
 answered on 30 Jan 2019
11 answers
996 views

Hi,

I have a fairly complex docx file, in which I want to replace some text using the ReplaceText method, and managed to do so, until today, when I tried to insert a newline into my "new text". To be more specific

Old text: "lorem ipsum VAR_TEXT".

Using: editor.ReplaceText("VAR_TEXT", "dolor"), it works, and the output is "lorem ipsum dolor", as expected.

 

Now I want to do this: editor.ReplaceText("VAR_TEXT", "dolor \n\r sit amet"), and achieve:

lorem ipsum dolor

sit amet

but what I always get is lorem ipsum dolor sit amet

I also tried with: Environment.NewLine, \n, \n\r, \r\n, <br>, <br />, <w:br /> ...all failed.

 

Can you please help me out? Thank you!

Tanya
Telerik team
 answered on 29 Jan 2019
5 answers
1.8K+ views

Hello we have been getting large PDF files in the 80 MBs range and need to compress these.  Some clients are scanning in too high resolution and in color.  I have tried several Telerik code examples for importing and exporting, but have had no successful attempts at reducing the file size. Most made the same PDF size, but some examples resulted in larger PDF sizes.  There was a grayscale example in the a thread, but that increased the file size by about 50% regardless of the PDF.  Is there an example on importing, running a compression scheme, and then exporting that results in smaller PDFs? 

Thank you.

 

Boby
Telerik team
 answered on 28 Jan 2019
1 answer
524 views

Can someone tell me how can i export a docx document into pdf with password?

 

I tried the following but i get a corrupted pdf file:

 

RadFixedDocument documentFromPDFtmp = new RadFixedDocument();
                        Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider providerFromPDFtmp = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
                        var fileFormatProvider = new DocxFormatProvider();
                        RadFlowDocument documentFromWord = fileFormatProvider.Import(sourceFile.InputStream); ;
                        IFormatProvider<RadFlowDocument> formatProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();                              
                        using (MemoryStream ms = new MemoryStream())
                        {                            
                            formatProvider.Export(documentFromWord, ms);                            
                            using (Stream stream = ms)
                            {
                                documentFromPDF = providerFromPDFtmp.Import(stream);
                            }
                            using (Stream output = new FileStream(path, FileMode.OpenOrCreate))
                            {
                                providerFromPDFtmp.ExportSettings.IsEncrypted = true;
                                providerFromPDFtmp.ExportSettings.UserPassword = Utils.GetConfigValue("PassPhrase");
                                providerFromPDFtmp.ExportSettings.ImageQuality = ImageQuality.Medium;
                                providerFromPDFtmp.Export(documentFromPDFtmp, output);
                            }
                        }

 

Looking forward for help with that

Thanks,

Hagai.

 

Georgi
Telerik team
 answered on 28 Jan 2019
5 answers
529 views

Please help me, I wanna generate word document contain  bullet and numberring using RadFlowDocumentEditor ? I tried but arrangement is so messi.

if I used section.block, it was success

               var paragraph1 = section.Blocks.AddParagraph();
                paragraph1.Inlines.AddRun("");
                paragraph1.ListId = list.Id;
                paragraph1.ListLevel = 0;

 

001.private void button1_Click(object sender, EventArgs e)
002.        {
003.            RadFlowDocument document = new RadFlowDocument();
004.            //Section section = document.Sections.AddSection();
005. 
006.            DocxFormatProvider provider = new DocxFormatProvider();
007.            RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
008. 
009.            string reportFilePathDir = Path.Combine(Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\")), "OutputTes", "listandtable.docx");
010.            // Start to Generate Monber Doc
011.            using (Stream output = new FileStream(reportFilePathDir, FileMode.OpenOrCreate))
012.            {
013.                //1. Table
014.                GenTableInDoc(document, editor);
015. 
016. 
017.                //2. list
018.                List list = document.Lists.Add(ListTemplateType.NumberedDefault);
019.                 
020.                var paragraphTop = editor.InsertParagraph();
021.                paragraphTop.Inlines.AddRun("Note that the numbering the paragraph.");
022. 
023.                var paragraphTop1 = editor.InsertParagraph();
024.                paragraphTop1.Inlines.AddRun("okeh <p color=\"red\">this is red color</p> <font color=\"red\">This is some text!</font>");
025. 
026. 
027.                var paragraph1 = editor.InsertParagraph();
028.                paragraph1.Inlines.AddRun("Note that the numbering the paragraph.");
029.                paragraph1.ListId = list.Id;
030.                paragraph1.ListLevel = 0;
031. 
032.                var paragraph2 = editor.InsertParagraph();
033.                paragraph2.Inlines.AddRun("Note that the numbering the paragraph.");
034.                paragraph2.ListId = list.Id;
035.                paragraph2.ListLevel = 1;
036. 
037.                var paragraph3 = editor.InsertParagraph();
038.                paragraph3.Inlines.AddRun("Note that the numbering the paragraph.");
039.                paragraph3.ListId = list.Id;
040.                paragraph3.ListLevel = 1;
041. 
042.                var paragraph4 = editor.InsertParagraph();
043.                paragraph4.Inlines.AddRun("Note that the numbering the paragraph.");
044.                paragraph4.ListId = list.Id;
045.                paragraph4.ListLevel = 2;
046. 
047.                var paragraphBottom = editor.InsertParagraph();
048.                paragraphBottom.Inlines.AddRun("Note that the numbering the paragraph.");
049. 
050. 
051.                //3. Table
052.                GenTableInDoc(document, editor);
053. 
054.                //*EXPORT TO WORD
055.                provider.Export(document, output);
056.            }
057. 
058.            MessageBox.Show(this, "ok");
059.        }
060. 
061. 
062.public static void GenTableInDoc(RadFlowDocument document, RadFlowDocumentEditor editor)
063.        {
064.            Style style = new Style("ok", StyleType.Table);
065.            style.CharacterProperties.ForegroundColor.LocalValue = new ThemableColor(System.Windows.Media.Colors.Black);
066.            style.CharacterProperties.FontWeight.LocalValue = FontWeights.Bold;
067.            style.CharacterProperties.FontSize.LocalValue = 9;
068. 
069.            document.StyleRepository.Add(style);
070. 
071.            var section = document.Sections.AddSection();
072. 
073.            Table table = editor.InsertTable();
074.            //Table table = section.Blocks.AddTable();
075.            table.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 100);
076. 
077.            document.StyleRepository.AddBuiltInStyle(BuiltInStyleNames.TableGridStyleId);
078.            table.StyleId = BuiltInStyleNames.TableGridStyleId;
079. 
080.            //header
081.            TableRow rowHeader = table.Rows.AddTableRow();
082.            rowHeader.RepeatOnEveryPage = true;
083. 
084.            //number cell header
085.            TableCell cellNumberHeader = rowHeader.Cells.AddTableCell();
086.            cellNumberHeader.Blocks.AddParagraph().Inlines.AddRun("Header").FontWeight = FontWeights.Bold; cellNumberHeader.Shading.BackgroundColor = new ThemableColor(System.Windows.Media.Colors.LightGray);
087.            cellNumberHeader.RowSpan = 2; cellNumberHeader.ColumnSpan = 1;
088. 
089.            cellNumberHeader = rowHeader.Cells.AddTableCell();
090.            cellNumberHeader.Blocks.AddParagraph().Inlines.AddRun("Header").FontWeight = FontWeights.Bold; cellNumberHeader.Shading.BackgroundColor = new ThemableColor(System.Windows.Media.Colors.LightGray);
091.            cellNumberHeader.RowSpan = 2; cellNumberHeader.ColumnSpan = 1;
092. 
093.            cellNumberHeader = rowHeader.Cells.AddTableCell();
094.            cellNumberHeader.Blocks.AddParagraph().Inlines.AddRun("Header").FontWeight = FontWeights.Bold; cellNumberHeader.Shading.BackgroundColor = new ThemableColor(System.Windows.Media.Colors.LightGray);
095.            cellNumberHeader.RowSpan = 1; cellNumberHeader.ColumnSpan = 3;
096. 
097.            cellNumberHeader = rowHeader.Cells.AddTableCell();
098.            cellNumberHeader.Blocks.AddParagraph().Inlines.AddRun("Header").FontWeight = FontWeights.Bold; cellNumberHeader.Shading.BackgroundColor = new ThemableColor(System.Windows.Media.Colors.LightGray);
099.            cellNumberHeader.RowSpan = 2; cellNumberHeader.ColumnSpan = 1;
100. 
101.            cellNumberHeader = rowHeader.Cells.AddTableCell();
102.            cellNumberHeader.Blocks.AddParagraph().Inlines.AddRun("Header").FontWeight = FontWeights.Bold; cellNumberHeader.Shading.BackgroundColor = new ThemableColor(System.Windows.Media.Colors.LightGray);
103.            cellNumberHeader.RowSpan = 2; cellNumberHeader.ColumnSpan = 1;
104. 
105.            TableRow rowHeader1 = table.Rows.AddTableRow();
106.            rowHeader1.RepeatOnEveryPage = true;
107. 
108.            TableCell c1 = rowHeader1.Cells.AddTableCell();
109.            c1.Blocks.AddParagraph().Inlines.AddRun("Header").FontWeight = FontWeights.Bold; c1.Shading.BackgroundColor = new ThemableColor(System.Windows.Media.Colors.LightGray);
110.            c1 = rowHeader1.Cells.AddTableCell();
111.            c1.Blocks.AddParagraph().Inlines.AddRun("Header").FontWeight = FontWeights.Bold; c1.Shading.BackgroundColor = new ThemableColor(System.Windows.Media.Colors.LightGray);
112.            c1 = rowHeader1.Cells.AddTableCell();
113.            c1.Blocks.AddParagraph().Inlines.AddRun("Header").FontWeight = FontWeights.Bold; c1.Shading.BackgroundColor = new ThemableColor(System.Windows.Media.Colors.LightGray);
114. 
115.            TableRow rowHeader2 = table.Rows.AddTableRow();
116.            TableCell c2 = rowHeader2.Cells.AddTableCell();
117.            c2.Blocks.AddParagraph().Inlines.AddRun("");
118.            c2 = rowHeader2.Cells.AddTableCell();
119.            c2.Blocks.AddParagraph().Inlines.AddRun("");
120.            c2 = rowHeader2.Cells.AddTableCell();
121.            c2.Blocks.AddParagraph().Inlines.AddRun("");
122.            c2 = rowHeader2.Cells.AddTableCell();
123.            c2.Blocks.AddParagraph().Inlines.AddRun("");
124.            c2 = rowHeader2.Cells.AddTableCell();
125.            c2.Blocks.AddParagraph().Inlines.AddRun("");
126.            c2 = rowHeader2.Cells.AddTableCell();
127.            c2.Blocks.AddParagraph().Inlines.AddRun("");
128.            c2 = rowHeader2.Cells.AddTableCell();
129.            c2.Blocks.AddParagraph().Inlines.AddRun("");
130.        }
Tanya
Telerik team
 answered on 22 Jan 2019
0 answers
75 views

Hi,,,

I'm using Telerik Winform Q1 2015.

I just generated Excel File using RadSpreadProcessing.

if I used Microsoft Office 2016 in PC, File Excel not Generated normaly (after file excel generated but suddenly that files had been removed automatically).

but the other way if I used Microsoft Office 2007, it's not a problemo.

 

Please, give me a solution... :) 

Regards

zake
Top achievements
Rank 1
 asked on 18 Jan 2019
7 answers
809 views

Hi,

I import an existing word-doc that contains several bookmarks:

// import word-doc to RadFlowDocument
RadFlowDocument templateDocument = provider.Import(fileMemoryStream);
// edit RadFlowDocument
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(templateDocument);

 

Then I modify the RadFlowDocument (inserting text, tables, ... at certain positions) by using the RadFlowDocumentEditor.

Finally, I need to remove/delete some parts of the document that are between two bookmarks. I have searched the documentation and forums but could not find a way how to do this.

Any help would be appreciated.

Regards, Manu

 

Tanya
Telerik team
 answered on 15 Jan 2019
1 answer
402 views

Hi All,

 

I need to write custom code for generating the PDF,  where i am getting the image in binary format some thing like below. from database. 

<img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATYAAACxCAYAAABOfp...........................

 

The Image needs to be inserted into BLOCK of RadFixedDocument. I do have the functions like the following , but my question is how to convert the above image format to any one of the parameters below.

block.InsertImage(imageSource);
block.InsertImage(stream);
block.InsertImage(imageSource, size);
block.InsertImage(stream, size);
block.InsertImage(imageSource, width, height);
block.InsertImage(stream, width, height);

 

Regards,

JP.

 

 

Martin
Telerik team
 answered on 08 Jan 2019
1 answer
158 views
Hi,

I have an engine that dynamically creates RadDocuments.

I have also a WPF application the show the document in a RadRichTextBox, users can add some comments, change some contents and export it.

All works really good.

Now we are working on web version of same application.

What the way?

I tested the HTML export of a document, so I can show it in a kendo Editor, the result is not perfect as the WPF version, this because the html export lost "pages" division, elements alignement...

Others ways?

I can also consider a way where user canno't edit the doc.

Ideas?
Tanya
Telerik team
 answered on 08 Jan 2019
1 answer
441 views
I tried to user your product and I have a problem.
I tried the following code to DigitalSign document and it says:
An unhandled exception of type 'System.NotSupportedException' occurred in mscorlib.dll

Additional information: Stream does not support reading.
Please help me what is problem?
Thank you
 X509Certificate2 certificate = new X509Certificate2("JohnDoe.pfx", "johndoe");
            // The name of the signature must be unique.
            string signatureName = "SampleSignature";

            // This is the Form XObject element that represents the contents of the signature field.
            Telerik.Windows.Documents.Fixed.Model.Objects.Form form = new Telerik.Windows.Documents.Fixed.Model.Objects.Form();
            form.FormSource = new FormSource();
            form.FormSource.Size = new System.Windows.Size(120, 120);

            // We will use the editor to fill the Form XObject.
            FixedContentEditor formEditor = new FixedContentEditor(form.FormSource);
            formEditor.DrawCircle(new System.Windows.Point(50, 50), 20);
            formEditor.DrawText(signatureName);

            // The Signature object is added to a signature field, so we can add a visualization to it.
            SignatureField signatureField = new SignatureField(signatureName);
            signatureField.Signature = new Signature(certificate);

            // The widget contains the Form XObject and defines the appearance of the signature field.
            SignatureWidget widget = signatureField.Widgets.AddWidget();
            widget.Rect = new Rect(new System.Windows.Point(200, 600), new System.Windows.Size(100, 100));
            widget.Border = new AnnotationBorder(10, AnnotationBorderStyle.Solid, null);
            widget.Content.NormalContentSource = form.FormSource;
            widget.RecalculateContent();

            // The Widget class inherits from Annotation. And, as any other annotation, must be added to the respective collection of the page.

            RadFixedDocument document = new RadFixedDocument();
            RadFixedPage page = document.Pages.AddPage();
            page.Annotations.Add(widget);
            document.AcroForm.FormFields.Add(signatureField);

            using (Stream stream = File.OpenWrite("signed.pdf"))
            {
                new PdfFormatProvider().Export(document, stream);
            }
Martin
Telerik team
 answered on 27 Dec 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?