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);
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
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.
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!
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.
Hello,
I am currently trying to write in the "Modele.docx" document that is just a template. For each OperationAffecteeViewModel, I want to write in this template, and then copy what i just wrote in "documentFinal.docx". But the application crashes at the line
documentFinal.Sections.Add(copySection);
with the following error : The document element is associated with another document
here's the code :
private async Task GenererOperations()
{
RadFlowDocument document = new RadFlowDocument(); ;
RadFlowDocument documentFinal = new RadFlowDocument();
var docxProvider = new DocxFormatProvider();
foreach (OperationAffecteeViewModel operationAffectee in OperationsAffectees)
{
using (Stream input = File.OpenRead("Modele.docx"))
{
document = docxProvider.Import(input);
}
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
GoToBookmark(document, editor, "OUVRAGE");
editor.InsertText(operationAffectee.LibelleOuvrage);
GoToBookmark(document, editor, "OPERATION");
editor.InsertText(operationAffectee.LibelleTypeOperation);
GoToBookmark(document, editor, "DATE_PRÉVUE");
editor.InsertText(operationAffectee.DatePrevisionnelle.Date.ToString("dd/MM/yyyy"));
}
//chargement de la police pour éviter de perdre les caractères spéciaux lors de l'exportation
var fontData = File.ReadAllBytes(@"wwwroot/fonts/Calibri_Regular.ttf");
FontsRepository.RegisterFont(new Telerik.Documents.Core.Fonts.FontFamily("Calibri"), FontStyles.Normal, FontWeights.Normal, fontData);
var providerPdf = new PdfFormatProvider();
using (Stream outStream = File.OpenWrite("sample.pdf"))
{
providerPdf.Export(document, outStream);
}
await InvokeAsync(() => this.StateHasChanged());
}
private void GoToBookmark(RadFlowDocument document, RadFlowDocumentEditor editor, string bookmarkName)
{
var bookmark = document.EnumerateChildrenOfType<BookmarkRangeEnd>().FirstOrDefault(rangeStart => rangeStart.Bookmark.Name == bookmarkName);
if (bookmark != null)
{
editor.MoveToInlineEnd(bookmark.Paragraph.Inlines[0]);
}
}
Thanks for helping me !
Hello,
I have a weird situation, that the line:
run.FontWieght = FontWieghts.Bold;
doesn't work.
in second hand, every other character attribute is working perfectly (like FontStyle, FontUnderline, Font size and so on).
can anyone guess what could be the issue?
Hello,
Is there a way we can add the signature captured via a SignaturePad and add it to the RadFixedPage? Also certify that signature with a x509 self signed certificate?
Thanks,
Urmila