Telerik Forums
Telerik Document Processing Forum
1 answer
98 views

Hi there,

I am trying to generate a list on the position of a named bookmark in an template.

The list is generated and looks fine, but is a positioned at the very end of the document.

The code looks very similar to my code for generating a  table on the position of a bookmark, but for a list it does not work.

Does anyone kwows what is going wrong? Is a section always generated at the very end of the document?

Thank for your help!

 

My code:

var bookmark = bookmarks.FirstOrDefault(b => b.Bookmark.Name == "PaymentMilestones");

if (bookmark is not null)
{
editor.MoveToInlineEnd(bookmark.Bookmark.BookmarkRangeStart);

var section = editor.InsertSection();

List list = document.Lists.Add(ListTemplateType.BulletDefault);

if (purchaseOrderPaymentMilestones is not null && purchaseOrderPaymentMilestones.Any())
{
foreach (var purchaseOrderPaymentMilestone in purchaseOrderPaymentMilestones)
{
var paragraph = section.Blocks.AddParagraph();
paragraph.Inlines.AddRun($"{purchaseOrderPaymentMilestone.Percentage.ToString("N0")}% {purchaseOrderPaymentMilestone.PaymentMilestone.FullDescription}");
paragraph.ListId = list.Id;
paragraph.ListLevel = 0;
}
}
}
Yoan
Telerik team
 answered on 22 Jul 2024
1 answer
83 views

Hi I am looking for code to add a table to a template with a bookmark:

The first step in my code is to go to the named bookmark, then I generate the table, but the table is not attached to location of the bookmark, but shows at the very end of the document.

var bookmark = bookmarks.FirstOrDefault(b => b.Bookmark.Name == "PricingTable");
if (bookmark is not null)
{
editor.MoveToInlineEnd(bookmark.Bookmark.BookmarkRangeStart);

Table table = document.Sections.AddSection().Blocks.AddTable();
document.StyleRepository.AddBuiltInStyle(BuiltInStyleNames.TableGridStyleId);
table.StyleId = BuiltInStyleNames.TableGridStyleId;
foreach (var pricingTableRow in pricingTable)
{
TableRow row = table.Rows.AddTableRow();
foreach (var property in pricingTableRow.GetType().GetProperties())
{
TableCell cell = row.Cells.AddTableCell();
cell.Blocks.AddParagraph().Inlines.AddRun(property.GetValue(pricingTableRow) is null ? string.Empty : property?.GetValue(pricingTableRow)?.ToString());
}
}
}

}

 

 

Yoan
Telerik team
 answered on 18 Jul 2024
1 answer
76 views

Hi,

We've been using the DocFormatProvider and DocxFormatProvider to convert from DOC to DOCX. Most documents convert okay. However, we've noticed some really old documents (late 90's) contain an image (or object) type called PBrush. I'm guessing it's from the old PaintBrush program. Is there any option to keep these when converting?

Thanks

Daniel

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 18 Jul 2024
1 answer
121 views

Here's a trivial example that demonstrates this and the file as well, confused because it works on your "InteractiveForms.pdf" file. The file can be found on the Canadian government site, see link below.

PdfFormatProvider provider = new PdfFormatProvider();
RadFixedDocument document = provider.Import(File.OpenRead("t661-fill-20e.pdf"));

Note that the RadFixedDocument.AcroForm.FormFields will be count of 0 even though there are tons of editable fields ...

The PDF file can be found on the Canadian government website:  See Fillable PDF (t661-fill-20e.pdf) at ...

Site to grab the PDF

Hoping for a miracle ... ;)
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 31 May 2024
2 answers
105 views

Hi,

Table cells with individually set vertical borders lose them when DocxFormatProvider is used for export. Import and export the attached file to see the problem. Does anyone know how to fix this? Pdf export seems to work correctly.

Thanks,
stim

Yoan
Telerik team
 answered on 27 May 2024
1 answer
77 views
I have Telerik UI for WPF and used RadPdfViewerControl. I noticed the below message on UI when rendering PDF file. Is this not included as part of Telerik UI for WPF ? Do I need to purchase a separate license for this ? If so, how much is the commercial license  ?


Dess | Tech Support Engineer, Principal
Telerik team
 answered on 27 May 2024
1 answer
118 views

Hello,

I would like to know if it's possible to retrieve the footnotes of a word document (docx) using RadFlowDocument.

I'm trying to look for examples but I'm not able to find any.

I'm building a solution that needs to parse .docx files and retrieve the footnotes.

I know that with OpenXML format it's possible to read it: FootnotesPart footnotesPart = wordDoc.MainDocumentPart.FootnotesPart;

Any help would be great.

Thanks.

Yoan
Telerik team
 answered on 23 May 2024
2 answers
338 views

Hello,

I am trying to set up Github actions to build my application and I followed the article at https://www.telerik.com/blogs/announcing-nuget-keys to configure the access to the telerik feed.

The action definition looks like this:


# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET

on:
  workflow_dispatch:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

jobs:
  build:

    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v4
    - name: Setup .NET
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: 8.0.x
    - name: Restore NuGet Packages
      run: dotnet restore ./MySolution.sln --configfile ./nuget.config -v detailed 
      env:
        MY_API_KEY: ${{ secrets.TELERIK_NUGET_KEY }}
    - name: Build
      run: dotnet build ./MySolution.sln --no-restore
    - name: Test
      run: dotnet test MyTests/MyTests.csproj --no-build --verbosity normal

But there are the error on restoring the packages:

error NU1101: Unable to find package Telerik.Documents.Core. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, MyTelerikFeed, nuget.org
error NU1101: Unable to find package Telerik.Documents.Fixed. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, MyTelerikFeed, nuget.org
error NU1101: Unable to find package Telerik.Documents.Flow. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, MyTelerikFeed, nuget.org
error NU1101: Unable to find package Telerik.Documents.Flow.FormatProviders.Pdf. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, MyTelerikFeed, nuget.org
error NU1101: Unable to find package Telerik.Zip. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, MyTelerikFeed, nuget.org
error NU1101: Unable to find package UI.for.WinForms.AllControls.Net60. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, MyTelerikFeed, nuget.org

 

Any ideas on how to fix it?

Sergey
Top achievements
Rank 1
Iron
 answered on 21 May 2024
1 answer
103 views

When i import an XLSX file and save it, Excell table are gone.
I use this table name in some formules.

I want insert some dynamic header information and some rows to the table.

I cant find any documentation which other things will be lost when i export the file.

    private void OpenFile()
    {
        string fileName = @"Template.xlsx";
        _xlsxProvider = new XlsxFormatProvider();

        using (Stream stream = File.OpenRead(fileName))
        {
            try
            {
                _workbook = _xlsxProvider.Import(stream);
                _worksheet = _workbook.ActiveWorksheet;
                _workbook.History.IsEnabled = false;
            }
            catch (Exception)
            {
                Console.WriteLine("Could not open file.");
            }
        }
    }
 public Stream GetOutputStream()
 {
     Stream stream = new MemoryStream();
     _xlsxProvider.Export(_workbook, stream);
     stream.Position = 0;
     return stream;
 } 

var stream  = _excelService.GetOutputStream();
 //write stream to fole
 using (var fileStream = File.Create("Output.xlsx"))
 {
     await stream.CopyToAsync(fileStream);
 }

Is it possible to keep the table when exporting.
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 25 Apr 2024
1 answer
112 views

Hello, I have a PDF form where I am manipulating the fields.  When I try to use the example code I get the error - The method or operation is not implemented.  The current trial version works with this code, but I am using an old version.  Is this possible with the version I am using?

The form part seems to work ok, I just get the error on the final line.   Is there another way to save the file with the R1.2021 version?  Thank you!

File.WriteAllBytes(outputPath, pdfProvider.Export(document));

Full code from example:

 string inputPath = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "PDFs\\ce_certificate.pdf";
 string fileName = "certificate_" + drCE["series_id"] + "_" + drCE["member_id"] + ".pdf";
 string outputPath = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "PDFs\\CECertificates\\" + fileName;

 Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider pdfProvider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
 RadFixedDocument document = pdfProvider.Import(File.ReadAllBytes(inputPath));

 foreach (RadFixedPage page in document.Pages)
 {
     foreach (Annotation annotation in page.Annotations)
     {
         if (annotation.Type == AnnotationType.Widget)
         {
             Widget widget = (Widget)annotation;
             var field = widget.Field as TextBoxField;
             if (field != null)
             {
                 switch (field.Name)
                 {
                     case "member_name":
                         field.Value = drCE["full_name"].ToString();
                         break;
                     case "course_name":
                         field.Value = drCE["title"].ToString();
                         break;
                     case "ce_credits":
                         field.Value = drCE["total_credits"].ToString();
                         break;
                     case "completed_date":
                         field.Value = DateTime.Parse(drCE["complete_date"].ToString()).ToShortDateString();
                         break;
                 }
             }
         }
     }
 }


 //not implemented in our version
 //document.AcroForm.FlattenFormFields();

 //not implemented in our version
 File.WriteAllBytes(outputPath, pdfProvider.Export(document));

Yoan
Telerik team
 answered on 15 Apr 2024
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?