SkiaImageFormatProvider: Add support for Text, TextMarkup, Line, and Stamp annotations.
Currently, these annotations are omitted on image export.
When Cyrillic culture is set an InvalidCastException is thrown.
Workaround: use English culture during the import process
System.Globalization.CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-EN");
PdfFormatProvider provider = new PdfFormatProvider();
RadFixedDocument document;
using (Stream stream = File.OpenRead("popup_dedetizacao_ok.pdf"))
{
document = provider.Import(stream);
}
System.Threading.Thread.CurrentThread.CurrentCulture = currentCulture;
For the RadPdfViewer control you can use a similar approach:
System.Globalization.CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-EN");
PdfFormatProvider provider = new PdfFormatProvider();
RadFixedDocument document;
using (Stream stream = File.OpenRead("popup_dedetizacao_ok.pdf"))
{
document = provider.Import(stream);
}
System.Threading.Thread.CurrentThread.CurrentCulture = currentCulture;
RadForm form = new RadForm();
RadPdfViewer radPdfViewer1 = new RadPdfViewer();
form.Controls.Add(radPdfViewer1);
radPdfViewer1.LoadElementTree();
radPdfViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
radPdfViewer1.Document = document;
form.ShowDialog();
Handle import of documents with wrong type of action key.
Once this is completed use the Exceptions Handling mechanism to handle this scenario. For instance:
private void ImportSettings_DocumentUnhandledException(object sender, DocumentUnhandledExceptionEventArgs e)
{
if (e.Exception is InvalidActionException)
{
Error message:
System.InvalidCastException: 'Unable to cast object of type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfHexString' to type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfLiteralString'.'This is the code used for merging:
private void MergeDifferentDocumentsPagesWithFixed()
{
string[] documentsToMerge =
{
"14301-STOCK_Proforma.pdf",
"14302-STOCK_Proforma.pdf",
"14303-STOCK_Proforma.pdf",
"14304-STOCK_Proforma.pdf",
"14305-STOCK_Proforma.pdf",
"14330-STOCK_Proforma.pdf"
};
RadFixedDocument doc = new RadFixedDocument();
PdfFormatProvider provider = new PdfFormatProvider();
foreach (string current_item in documentsToMerge)
{
string path = @"..\..\Samples\" + current_item;
RadFixedDocument docToMerge;
if (!File.Exists(path))
{
continue;
}
using (Stream stream = File.OpenRead(path))
{
docToMerge = provider.Import(stream);
}
doc.Merge(docToMerge);
}
string outputFilePath = @"..\..\mergedFixed.pdf";
File.Delete(outputFilePath);
using (Stream output = File.OpenWrite(outputFilePath))
{
provider.Export(doc, output);
}
Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true });
}
Workaround:
private void MergeDifferentDocumentsPages(string resultFileName)
{
string[] documentsToMerge =
{
"14301-STOCK_Proforma.pdf",
"14302-STOCK_Proforma.pdf",
"14303-STOCK_Proforma.pdf",
"14304-STOCK_Proforma.pdf",
"14305-STOCK_Proforma.pdf",
"14330-STOCK_Proforma.pdf"
};
File.Delete(resultFileName);
using (PdfStreamWriter fileWriter = new PdfStreamWriter(File.OpenWrite(resultFileName)))
{
foreach (string documentName in documentsToMerge)
{
string path = @"..\..\Samples\" + documentName;
using (PdfFileSource fileToMerge = new PdfFileSource(File.OpenRead(path)))
{
foreach (PdfPageSource pageToMerge in fileToMerge.Pages)
{
fileWriter.WritePage(pageToMerge);
}
}
}
}
Process.Start(new ProcessStartInfo() { FileName = resultFileName, UseShellExecute = true });
}