Telerik Forums
Telerik Document Processing Forum
7 answers
822 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
413 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
161 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
449 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
1 answer
582 views

Hi,

I've created a word document that I use with WordsProcessing to mail merge. In the document I've had to use tables to be able to get left and right alignments of blocks of text (seems Word's TextBox isn't supported within WordsProcessing?). The tables solution works and allows me to produce a document as per the attached. However, when I try to convert to produced word document to PDF the document comes out with additional borders on the tables (where certain cell borders have been set to none within the word document). The best way to see this is to create a word document with a table of one row with three columns. For the first column make it so that the borders surround the cell (top, left, right bottom). Do the same for the last column. For the second (middle) column remove the top and bottom borders. The document should now show two boxes, one on the left and one on the right (see attached image as an example). Take this Word Document and then convert it to PDF on the demo (https://demos.telerik.com/aspnet-mvc/wordsprocessing/pdf-export). You'll see when comparing the word document and the converted PDF document what the issue is, in that the middle cell of the table renders with the top and bottom border (which is not present in the word document). Is this a limitation of the PDFProcessing? If so is there another way to construct a word document to achieve the same result both for mail merging in WordsProcessing and converting the subsequent document to PDF so that they render as intended?

Many thanks,

Neil

Peshito
Telerik team
 answered on 27 Dec 2018
3 answers
397 views

Hello, in an MVC application I need to convert a .docx that contains images into a pdf. My code below works if the docx does not contain an image. If the docx contains an image I get an object reference error when importing the document on this line: document = providerDocx.Import(stream);

 

            RadFlowDocument document = null;
            DocxFormatProvider providerDocx = new DocxFormatProvider();
            using (FileStream stream = File.Open(@"C:\\test\myWordDoc.docx", FileMode.Open))
            {
                document = providerDocx.Import(stream);

                var providerPdf = new PdfFormatProvider();

                Stream outStream = new MemoryStream();
                providerPdf.Export(document, outStream);

                //Test the conversion:
                var fileStream = File.Create(@"C:\\test\myWordDoc.pdf");
                outStream.Seek(0, SeekOrigin.Begin);
                outStream.CopyTo(fileStream);
                fileStream.Close();
            }

How can I convert an existing word document with images to a new pdf document?

Tanya
Telerik team
 answered on 13 Dec 2018
1 answer
1.0K+ views

     Hi,

I'm trying to use the RadFlowDocument in order to create a PDF document. I have successfully managed to use the examples provided in the documentation in order to import the body of my HTML into the document, however the examples for the header and footer do not make it clear how I would go about importing HTML in.

Below is the current state of my code. Unfortunately the header comes out as plain text, but the body is successfully processed. Any advise would be greatly received. 

 

public static byte[] GeneratePDF(DocumentTemplate doc)
        {            
            string body = "";
            body = doc.DocumentBody;

            HtmlFormatProvider provider = new HtmlFormatProvider();
            RadFlowDocument rfd = provider.Import(body);

            rfd.Sections.AddSection();

            Header defaultHeader = rfd.Sections.First().Headers.Add();
            Paragraph defaultHeaderParagraph = defaultHeader.Blocks.AddParagraph();
            defaultHeaderParagraph.Inlines.AddRun(doc.DocumentHeader);

            PdfFormatProvider provider2 = new PdfFormatProvider();
            
            using (MemoryStream output = new MemoryStream())
            {
                provider2.Export(rfd, output);
                return ReadToEnd(output);
            }
        }

Georgi
Telerik team
 answered on 12 Dec 2018
1 answer
1.1K+ views

I retrieve a PDF byte array from a web service.  How can I use PdfProcessing to display the byte array as a PDF document in a View?

 

Thanks.

Mike

Tanya
Telerik team
 answered on 05 Dec 2018
1 answer
198 views

I am attempting to give color of the particular text in the paragraph. But I am still failed. This is my code. Any help would be appreciated.

01.List list = document.Lists.Add(ListTemplateType.NumberedDefault);
02. 
03.                var section = document.Sections.AddSection();
04. 
05.                var paragraphTop = section.Blocks.AddParagraph();
06.                paragraphTop.Inlines.AddRun("Note that the numbering reference within the document content in the sample above contains a direct reference to the level to be applied because the <w:numPr> contains both the reference to the numbering definition (numId) and a reference to the level (ilvl). See Paragraph Properties for more on <w:numPr>. The other possible way to reference a level in content is through the referenced paragraph style. That is, in the <w:abstractNum> the appropriate subsidiary level (lvl) could contain a pStyle with a value of ListParagraph. In that case, the content contains only a reference to the numbering definition instance (numId), but it also references the paragraph style. The same style will be found in the numbering definition referenced and that level will be used for the paragraph.");
07. 
08.                var paragraphTop1 = section.Blocks.AddParagraph();
09.                paragraphTop1.Inlines.AddRun("okeh <p color=\"red\">this is red color</p> <font color=\"red\">This is some text!</font>");
10. 
11. 
12.                var paragraph1 = section.Blocks.AddParagraph();
13.                paragraph1.Inlines.AddRun("Note that the numbering reference within the document content in the sample above contains a direct reference to the level to be applied because the <w:numPr> contains both the reference to the numbering definition (numId) and a reference to the level (ilvl). See Paragraph Properties for more on <w:numPr>. The other possible way to reference a level in content is through the referenced paragraph style. That is, in the <w:abstractNum> the appropriate subsidiary level (lvl) could contain a pStyle with a value of ListParagraph. In that case, the content contains only a reference to the numbering definition instance (numId), but it also references the paragraph style. The same style will be found in the numbering definition referenced and that level will be used for the paragraph.");
14.                paragraph1.ListId = list.Id;
15.                paragraph1.ListLevel = 0;
16. 
17.                var paragraph2 = section.Blocks.AddParagraph();
18.                paragraph2.Inlines.AddRun("Line Two, Note that the numbering reference within the document content in the sample above contains a direct reference to the level to be applied because the <w:numPr> contains both the reference to the numbering definition (numId) and a reference to the level (ilvl). See Paragraph Properties for more on <w:numPr>. The other possible way to reference a level in content is through the referenced paragraph style. That is, in the <w:abstractNum> the appropriate subsidiary level (lvl) could contain a pStyle with a value of ListParagraph. In that case, the content contains only a reference to the numbering definition instance (numId), but it also references the paragraph style. The same style will be found in the numbering definition referenced and that level will be used for the paragraph.");
19.                paragraph2.ListId = list.Id;
20.                paragraph2.ListLevel = 1;
21. 
22.                var paragraph3 = section.Blocks.AddParagraph();
23.                paragraph3.Inlines.AddRun("Line three, Note that the numbering reference within the document content in the sample above contains a direct reference to the level to be applied because the <w:numPr> contains both the reference to the numbering definition (numId) and a reference to the level (ilvl). See Paragraph Properties for more on <w:numPr>. The other possible way to reference a level in content is through the referenced paragraph style. That is, in the <w:abstractNum> the appropriate subsidiary level (lvl) could contain a pStyle with a value of ListParagraph. In that case, the content contains only a reference to the numbering definition instance (numId), but it also references the paragraph style. The same style will be found in the numbering definition referenced and that level will be used for the paragraph.");
24.                paragraph3.ListId = list.Id;
25.                paragraph3.ListLevel = 1;
26. 
27.                var paragraph4 = section.Blocks.AddParagraph();
28.                paragraph4.Inlines.AddRun("Line four, Note that the numbering reference within the document content in the sample above contains a direct reference to the level to be applied because the <w:numPr> contains both the reference to the numbering definition (numId) and a reference to the level (ilvl). See Paragraph Properties for more on <w:numPr>. The other possible way to reference a level in content is through the referenced paragraph style. That is, in the <w:abstractNum> the appropriate subsidiary level (lvl) could contain a pStyle with a value of ListParagraph. In that case, the content contains only a reference to the numbering definition instance (numId), but it also references the paragraph style. The same style will be found in the numbering definition referenced and that level will be used for the paragraph.");
29.                paragraph4.ListId = list.Id;
30.                paragraph4.ListLevel = 2;
31. 
32.                var paragraphBottom = section.Blocks.AddParagraph();
33.                paragraphBottom.Inlines.AddRun("Note that the numbering reference within the document content in the sample above contains a direct reference to the level to be applied because the <w:numPr> contains both the reference to the numbering definition (numId) and a reference to the level (ilvl). See Paragraph Properties for more on <w:numPr>. The other possible way to reference a level in content is through the referenced paragraph style. That is, in the <w:abstractNum> the appropriate subsidiary level (lvl) could contain a pStyle with a value of ListParagraph. In that case, the content contains only a reference to the numbering definition instance (numId), but it also references the paragraph style. The same style will be found in the numbering definition referenced and that level will be used for the paragraph.");
Tanya
Telerik team
 answered on 29 Nov 2018
4 answers
1.2K+ views

I want to create a table in word document with header that having rowspan and columnspan.

please help me, because I had tried but the result is so messy. I have attach the table like I want. Tks

 

* note : I used Telerik Q2015

zake
Top achievements
Rank 1
 answered on 27 Nov 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?