Telerik Forums
Telerik Document Processing Forum
1 answer
988 views

Hi,

I'm currently using FixedContentEditor to create my pdf. I'm using blocks to write the long text like "terms and conditions" at the end of the pdf but it doesnot wrap the text. Is there a way I can insert long text ?

 

FixedContentEditor contentEditor4 = new FixedContentEditor(document.Pages[0], simplePosition4);
Block block4 = new Block();
block4.InsertText("This summary details the voting directions (if any) for business items on the appointment documents in your favour. If you vote these proxy votes you must vote in accordance with these directions. By completing the attached voting paper, when directed to vote in a particular manner, you are deemed to have voted in accordance with those directions.");
contentEditor4.DrawBlock(block4);

Dimitar
Telerik team
 answered on 10 Dec 2019
4 answers
1.1K+ views

Hi,

I have an existing word document and I need to remove paragraph/sentence/line.

stream input = File.OpenRead(filepath);
RadFlowDocument document  = provider.Import(input);

RadFlowDocumentEditor  editor = new RadFlowDocumentEditor(document);     
editor.ReplaceText("<Expr2>", ltr.Expr2));   
editor.ReplaceText("<Expr3>", ltr.Expr3));

If ltr.Expr2 is blank, then it should remove blank lines from document where <Expr2> exists, otherwise replace text with ltr.Expr2 value. 

Any help would be greatly appreciated.

Tanya
Telerik team
 answered on 10 Dec 2019
10 answers
797 views

Hi,

I have a problem where I need a header repeat on every page but its not working. Please help.

 

RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
Stream stream = File.Open(pathlogo, FileMode.Open);

using (stream)
{
    Telerik.Windows.Documents.Media.ImageSource image = newTelerik.Windows.Documents.Media.ImageSource(stream, "png");
    editor.InsertImageInline(stream, "png", new System.Windows.Size(168, 48));
}

var codeFont = new ThemableFontFamily(new System.Windows.Media.FontFamily("Arial"));
editor.CharacterFormatting.FontFamily.LocalValue = codeFont;
editor.CharacterFormatting.FontWeight.LocalValue = FontWeights.Bold;
editor.CharacterFormatting.FontSize.LocalValue = 12.0;
editor.InsertText("Statement");
document.StyleRepository.AddBuiltInStyle(BuiltInStyleNames.TableGridStyleId);
editor.TableFormatting.StyleId = BuiltInStyleNames.TableGridStyleId;

var section = editor.InsertSection();
var table = section.Blocks.AddTable();
section.Rotate(PageOrientation.Landscape);
var headerrow = table.Rows.AddTableRow();
headerrow.RepeatOnEveryPage = true;
var hcell1 = headerrow.Cells.AddTableCell();

hcell1.Blocks.AddParagraph().Inlines.AddRun("Name").FontWeight = FontWeights.Bold;
var hcell2 = headerrow.Cells.AddTableCell();
hcell2.Blocks.AddParagraph().Inlines.AddRun("Profession").FontWeight = FontWeights.Bold;
var hcell3 = headerrow.Cells.AddTableCell();
hcell3.Blocks.AddParagraph().Inlines.AddRun("Age").FontWeight = FontWeights.Bold;

foreach (var item in initltr)
{
    var row = table.Rows.AddTableRow();
    var cell1 = row.Cells.AddTableCell();
    var cell2 = row.Cells.AddTableCell();
    var cell3 = row.Cells.AddTableCell();
    cell1.Blocks.AddParagraph().Inlines.AddRun(item.Name).FontSize = 9;
    cell2.Blocks.AddParagraph().Inlines.AddRun(item.Profession).FontSize = 9;
    cell3.Blocks.AddParagraph().Inlines.AddRun(item.Age).FontSize = 9;
}

return document;

Dimitar
Telerik team
 answered on 26 Nov 2019
1 answer
121 views
I'm adding PieCharts to my excel and I couldn't find a way to add Data labels. Is there way to add Data labels to the Pie? And also can we add point explosion to the Pie?
Dimitar
Telerik team
 answered on 26 Nov 2019
5 answers
1.4K+ views

Hi,

I need help to setup page orientation to landscape due to size of the contents in cells. 

Here is my code.

public RadFlowDocument CreateDocument(ref RadFlowDocument document, List<LetterGenerateData> initltr, string pathlogo)
{
    RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
    Stream stream = File.Open(pathlogo, FileMode.Open);

    using (stream)
    {
        Telerik.Windows.Documents.Media.ImageSource image = new Telerik.Windows.Documents.Media.ImageSource(stream, "png");
        editor.InsertImageInline(stream, "png", new System.Windows.Size(168, 48));
    }

    var codeFont = new ThemableFontFamily(new System.Windows.Media.FontFamily("Arial"));
    editor.CharacterFormatting.FontFamily.LocalValue = codeFont;
    editor.CharacterFormatting.FontWeight.LocalValue = FontWeights.Bold;
    editor.CharacterFormatting.FontSize.LocalValue = 12.0;
    editor.InsertText("Statement");
    document.StyleRepository.AddBuiltInStyle(BuiltInStyleNames.TableGridStyleId);
    editor.TableFormatting.StyleId = BuiltInStyleNames.TableGridStyleId;

    var table = editor.InsertTable();
    var headerrow = table.Rows.AddTableRow();
    headerrow.RepeatOnEveryPage = true;
    var hcell1 = headerrow.Cells.AddTableCell();

    hcell1.Blocks.AddParagraph().Inlines.AddRun("Name").FontWeight = FontWeights.Bold;
    var hcell2 = headerrow.Cells.AddTableCell();
    hcell2.Blocks.AddParagraph().Inlines.AddRun("Profession").FontWeight = FontWeights.Bold;
    var hcell3 = headerrow.Cells.AddTableCell();
    hcell3.Blocks.AddParagraph().Inlines.AddRun("Age").FontWeight = FontWeights.Bold;
   
    foreach (var item in initltr)
    {
        var row = table.Rows.AddTableRow();
        var cell1 = row.Cells.AddTableCell();
        var cell2 = row.Cells.AddTableCell();
        var cell3 = row.Cells.AddTableCell();
        cell1.Blocks.AddParagraph().Inlines.AddRun(item.Name).FontSize = 9;
        cell2.Blocks.AddParagraph().Inlines.AddRun(item.Profession).FontSize = 9;
        cell3.Blocks.AddParagraph().Inlines.AddRun(item.Age).FontSize = 9;
    }

    return document;
}

Much appreciated.

 

Dimitar
Telerik team
 answered on 26 Nov 2019
2 answers
434 views

Hi

I am generating a PDF from a html file using HtmlFormatProvider, RadFlowDocument and PdfFormatProvider.

The generated PDF contains some large tables that is not rendered correctly.

This can be solved if I can set the html page witdth somehow.  Is it possible?

 

Peter
Top achievements
Rank 1
 answered on 22 Nov 2019
1 answer
854 views

I have a Template pdf (With company logo as letter head). I want to use this pdf as the first page when I'm creating my pdf. 

Here's my sample code. It creates the letter head in the first page and the rest of the content in a new page.

 

PdfFormatProvider provider = new PdfFormatProvider();
RadFixedDocument document = provider.Import(File.ReadAllBytes(InputFileName));

            using (RadFixedDocumentEditor editor = new RadFixedDocumentEditor(document))
            {

                editor.ParagraphProperties.SpacingBefore = 10;
                editor.ParagraphProperties.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
                editor.InsertParagraph();
                editor.CharacterProperties.FontSize = 40;
                editor.CharacterProperties.Font = boldItalicFont;
                editor.InsertRun("Summary of Proxy Votes");

 

Dimitar
Telerik team
 answered on 22 Nov 2019
1 answer
787 views

I'm having this issue with some digital signed pdfs. 

Here is the code that gets the exception:

var signatureFields = document.AcroForm.FormFields.Where(field => field.FieldType == FormFieldType.Signature).ToList();
            if (signatureFields.IsNotNullOrEmpty())
            {
                foreach (var signatureField in signatureFields)
                {
                    var field = (SignatureField)signatureField;

                    if (field != null && field.Signature != null)
                    {
                        var test = field.Signature.Validate(); - this is the line where I get the exceptions!

 

The method Validate() called without the properties parameter throws exception in 2 cases:

1st - using pdf signed with specialized software

Message: "No signature validation handler was found for the subfilter: ETSI.CAdES.detached

and the StackTrace: at Telerik.Windows.Documents.Fixed.Model.DigitalSignatures.Signature.Validate(SignatureValidationProperties validationProperties)\r\n   at Telerik.Windows.Documents.Fixed.Model.DigitalSignatures.Signature.Validate()\r\n   at... (there goes the path in my project)

2nd - using pdf signed with the same digital signature by Adobe Acrobat Reader

Message "ASN1 bad tag value met.\r\n"

and the StackTrace: at System.Security.Cryptography.Pkcs.SignedCms.OpenToDecode(Byte[] encodedMessage, ContentInfo contentInfo, Boolean detached)\r\n   at System.Security.Cryptography.Pkcs.SignedCms.Decode(Byte[] encodedMessage)\r\n   at Telerik.Windows.Documents.Fixed.Model.DigitalSignatures.Pkcs7Detached.ValidateOverride(SignatureDataProperties dataProperties, SignatureValidationProperties validationProperties)\r\n   at Telerik.Windows.Documents.Fixed.Model.DigitalSignatures.SignatureValidationHandlerBase.Validate(SignatureDataProperties dataProperties, SignatureValidationProperties validationProperties)\r\n   at Telerik.Windows.Documents.Fixed.Model.DigitalSignatures.Signature.Validate(SignatureValidationProperties validationProperties)\r\n   at Telerik.Windows.Documents.Fixed.Model.DigitalSignatures.Signature.Validate()\r\n   at... (there goes the path in my project)

I'll be glad if you can tell me where the problem is and what can I do to fix it. 

I want to be clear, there are just some correctly signed pdfs that cannot pass this validation. Most of them can but I'm afraid that I am missing something, as one of the non-passing digital signatures is new.

 

Georgi
Telerik team
 answered on 20 Nov 2019
21 answers
2.2K+ views
Hello

I would like to create PDF file, as container for images, (the source of the images is scanner).
I order to make small file size, I'm converting the images from BMP to JPEG and then do the export to PDF file,
but the output file size is huge.
I'm following this example.


1. How can i control the PDF file size?
2. Is the PDF export saves JPEG  image as is or decode and then save it?


My Code:

​
01.void f(List<Bitmap> Images)
02.{
03.  DateTime now = DateTime.Now;
04.  string name = "scan-" + now.ToString("yyyyMMdd") + "-" + now.ToString("HHmmss") + "_3" + ".pdf";
05.             
06.  using (FileStream FileStream = new FileStream(@"c:\Users\avicode\Desktop\tmp\" + name,FileMode.Create))
07.  using (MemoryStream ms = new MemoryStream())
08.             
09.  if (Images.Count >= 1)
10.  {
11.    RadDocument document = new RadDocument();
12.    for (int i = 0; i < Images.Count; i++)
13.    {
14.      System.Drawing.Image oBmpImage = (System.Drawing.Image)Images[Images.Count - 1];
15.      oBmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
16.      Telerik.Windows.Documents.Model.Section section = new Telerik.Windows.Documents.Model.Section();
17.      Telerik.Windows.Documents.Model.Paragraph paragraph = new Telerik.Windows.Documents.Model.Paragraph();
18. 
19.      ImageInline image = new ImageInline(ms);
20.      paragraph.Inlines.Add(image);
21.      section.Blocks.Add(paragraph);
22.      document.Sections.Add(section);
23. 
24.    }
25.    PdfFormatProvider oPdf = new PdfFormatProvider();
26.    oPdf.Export(document,FileStream);
27.    }
28.}
Nikolay Demirev
Telerik team
 answered on 18 Nov 2019
3 answers
997 views
I need to know how to email a digitally signed PDF document from a user input webform.
Tanya
Telerik team
 answered on 25 Oct 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?