Telerik Forums
Telerik Document Processing Forum
1 answer
624 views

Hi,

I'm developing a template creation application so users can create their own templates and such for mail merge purposes and I am wondering if there is any way to replace placeholders (for example "[order:id]") with merge fields using RadFlowDocumentEditor (replace text feature to be exact).

I already realized ReplaceText does not support FieldInfo and I know I can replace the placeholder with values from the database as well but I think there is probably a way to get actual templates from that.

Thanks in advance.

Dimitar
Telerik team
 answered on 14 Dec 2021
1 answer
342 views

  RadFixedDocument doc = new PdfFormatProvider().Import(System.IO.File.OpenRead(localPdfFile));

I am trying to load a Adobe signed PDF document , but is throwing error as "The input data is not a complete block"

 

System.Security.Cryptography.CryptographicException
  HResult=0x80131430
  Message=The input data is not a complete block.
  Source=System.Core
  StackTrace:
   at System.Security.Cryptography.CapiSymmetricAlgorithm.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
   at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
   at System.Security.Cryptography.CryptoStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at System.IO.Stream.Dispose()
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Encryption.StandardEncrypt.CalculateAesResult(Byte[] cipherTextCombined, Byte[] key)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Encryption.StandardEncrypt.Encrypt(StandardEncryptionContext context)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Encryption.StandardEncrypt.EncryptString(Int32 objectNo, Int32 generationNo, Byte[] data)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Encryption.StandardEncrypt.DecryptString(Int32 objectNo, Int32 generationNo, Byte[] data)

 

 

Martin
Telerik team
 answered on 13 Dec 2021
0 answers
156 views

I have a PDF with a number of text fields that have a number format. I am updating them with calculated values: 

     If PDFdocument.AcroForm.FormFields.Contains(row.Item("XMLField").ToString()) Then
         field = PDFdocument.AcroForm.FormFields.Item(row.Item("XMLField").ToString())

         Select Case field.FieldType
               Case FormFieldType.TextBox
                         ModifyTextBox(CType(field, TextBoxField), OutText)
               Case FormFieldType.CheckBox
                         Try
                              ModifyCheckBox(CType(field, CheckBoxField), New String() {row.Item("OutText").ToString()})
                         Catch
                         End Try
         End Select
     End If

When this executes the number format is over written and I see 1222777.00 instead of 1,222,777.00.

Is there a way to either not lose the number format or reset the number format for the PDF Text field.? 

To clarify before the ModifyTextBox command the TextField is formatted as follows:

 After the ModifyTextBox command the format tab is changed to None:

 

Lee
Top achievements
Rank 1
Iron
 updated question on 09 Dec 2021
1 answer
794 views

When I run my application which converts RTF documents to HTML content, I get an HTML output without the footer and the header part. It seems that HtmlFormatProvider does not support exporting header and footers from RTF documents.

Is there any other way to do this conversion? or is this something that would be considered in the future?

using Telerik.Windows.Documents.Flow.FormatProviders.Html;
...

var
htmlProvider = new HtmlFormatProvider();
html = htmlProvider.Export(rtfDocument);

 

 

Tanya
Telerik team
 answered on 03 Dec 2021
1 answer
874 views

Good morning,

I have a process which successfully generates a number of PDFs in a folder, and then compresses that folder into an unencrypted zip file.

I have used the code from a previous question:

https://www.telerik.com/forums/zip-content-of-a-folder-into-an-encrypted-zip-file

So my code is as follows:

public static void CreateZipFileFromDirectory(string sourceDirectoryName, string destinationArchiveFileName)

        {

            char[] directorySeparatorChar = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };

 

            ZipArchiveMode archiveMode = System.IO.File.Exists(destinationArchiveFileName) ? ZipArchiveMode.Update : ZipArchiveMode.Create;

 

            if (!string.IsNullOrEmpty(sourceDirectoryName))

            {

                using FileStream archiveStream = System.IO.File.Open(destinationArchiveFileName, FileMode.OpenOrCreate);

                using ZipArchive archive = new ZipArchive(archiveStream, archiveMode, leaveOpen: false, entryNameEncoding: null);

                foreach (string fileName in Directory.GetFiles(sourceDirectoryName))

                {

                    using FileStream file = System.IO.File.OpenRead(fileName);

                    int length = fileName.Length - sourceDirectoryName.Length;

                    string entryName = fileName.Substring(sourceDirectoryName.Length, length);

                    entryName = entryName.TrimStart(directorySeparatorChar);

 

                    using ZipArchiveEntry entry = archive.CreateEntry(entryName);

                    using Stream entryStream = entry.Open();

                    file.CopyTo(entryStream);

                }

            }

        }

This creates the zip file and adds the first PDF successfully, but gives an error when trying to add the second PDF

"The process cannot access the file 'filename.zip' because it is being used by another process."

I have tried setting the leaveOpen parameter for the ZipArchive to true and to false but that gives me the same error.

Any ideas what I've missed?

Richard

 

Dimitar
Telerik team
 answered on 01 Dec 2021
2 answers
500 views

I am doing images extraction from PDF. Having trouble to create image (in any format) from EncodedImageData (https://docs.telerik.com/devtools/document-processing/api/telerik.windows.documents.fixed.model.resources.encodedimagedata) structre.

Can someone post a sample code. I tired with this sample (https://www.telerik.com/forums/manipulate-image-elements) but without success.

My image have FlateDecode filter, "DeviceRGB" ColorSpace and 8 BitsPerComponent (see attached).

Environment is .NET Core.

Martin
Telerik team
 answered on 30 Nov 2021
1 answer
1.5K+ views

I need to be able to take a pdf that is already created, and I need to search for sections of the pdf, insert and/or change existing text, and resave the pdf.

I saw the FixedContentEditor, but I only saw how to add, I didn't notice how to search for text or replace it?

Could you point me in the right direction?

Thank you!

Dimitar
Telerik team
 answered on 24 Nov 2021
1 answer
482 views

Hi,

I have a simple Excel file with just one sheet and one image in .xls and in .xlsx (attached in the zip file).

When reading the files using the XlsFormatProvider or XlsxFormatProvider, I get a workbook. When iterating the shapes on every sheet, I have a different result. I can retrieve the image using the XlsxFormatProvider in the xlsx file, but I'm not getting any shapes in the .xls file using the XlsFormatProvider.

Some code below:

var provider = new XlsxFormatProvider();
using (var fs = File.OpenRead("image.xlsx"))
{
    var workbook = provider.Import(fs);
    Assert.AreEqual(workbook.ActiveWorksheet.Shapes.Images.Count(), 1);
}

Should I be doing this differently? Or is this a known limitation?

I'm using version 2021.3.909.40.

Edit: just noticed that the same goes for charts.

Tanya
Telerik team
 answered on 08 Nov 2021
8 answers
322 views
Hi!

I adapted the example "CreateModifyExport" in xaml-sdk to create a workbook then export it via XlsxFormatProvider. This works fine except that when I open the exported file in Excel 2013 (64 bit) there are no gridlines visible. Maybe I missed something but there is no code where gridlines are enabled/disabled.
Second issue is that AutoFitWidth is not working correctly, the column width does not fit the text.

Regards
Neils 
Edward
Top achievements
Rank 1
Veteran
Iron
Iron
 answered on 05 Nov 2021
1 answer
2.1K+ views
Can I export Html to PDf using PDFStreamWriter or PDFFormatProvider?
Dimitar
Telerik team
 answered on 04 Nov 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
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?