The problem I'm trying to solve is that users do not know that the original document may not be what they are seeing in the viewer when there are layers.
A property that indicates
that a document has layers would allow the system to refuse to open the document.
Is there a way to load this RadFixedDocument into a RadPdfViewer without writing the document to a file first and then loading it in the viewer?
Workaround:
You can achieve the desired functionality by exporting the RadFixedDocument to a MemoryStream instead of a file in the file system and then load it in the PdfViewer:
RadFixedDocument document = CreateRadFixedDocument();
PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
Stream ms = new MemoryStream();
pdfFormatProvider.Export(document, ms);
radPdfViewer1.LoadDocument(ms);
When creating many instances of RadPdfViewer:
static void Main(string[] args)
{
int i = 1;
try
{
Stopwatch stopwatch = Stopwatch.StartNew();
while (true)
{
using (RadPdfViewer pdfViewer = new RadPdfViewer())
{
}
Console.WriteLine($"iteration {i}, elapsed seconds: {stopwatch.Elapsed.TotalSeconds}");
i++;
}
}
catch (Exception e)
{
Console.WriteLine($"Exception occurred at iteration {i}");
Console.WriteLine(e);
Console.ReadLine();
}
}
the following error occurs:
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+. at System.Drawing.Bitmap.GetHicon() at Telerik.WinControls.PdfViewer.MouseHandlers.PanHandler..ctor(MouseHandlersController controller, IFixedDocumentPresenter presenter) at Telerik.WinControls.PdfViewer.MouseHandlers.MouseHandlersController.BuildHandlers(IFixedDocumentPresenter presenter) at Telerik.WinControls.PdfViewer.MouseHandlers.MouseHandlersController..ctor(IFixedDocumentPresenter presenter) at Telerik.WinControls.UI.RadPdfViewerElement..ctor() at Telerik.WinControls.UI.RadPdfViewer.CreateViewerElement() at Telerik.WinControls.UI.RadPdfViewer.CreateChildItems(RadElement parent) at Telerik.WinControls.RadControl.Telerik.WinControls.IComponentTreeHandler.CreateChildItems(RadElement parent) at Telerik.WinControls.RadElementTree.InitializeRootElement() at Telerik.WinControls.RadControl.Construct() at Telerik.WinControls.RadControl..ctor() at Telerik.WinControls.UI.RadPdfViewer..ctor()
Handled InvalidDataException occurs while Zip Library tries to decompress wrongly decrypted stream.
According to PDF format specification, there are three valid encoding name values (MacRomanEncoding, MacExpertEncoding and WinAnsiEncoding). There are documents that instead of skipping the optional Encoding property, are writing invalid /NULL name value in the font dictionary. Currently, in this invalid document scenario RadPdfViewer throws and catches Exception and this results in missing text content. We may handle this invalid document scenario by ignoring the invalid Encoding value.
It seems that this is a regression in R1 2023 SP1 after addressing this item:
Open the Demo application >> Interactive Forms example and apply the Office2019Dark theme. You will notice that if the text field enters edit mode, it is difficult to read the input due to black fore color and black backcolor:
Run the project and load a document with bookmarks. Try to click the two buttons in order to switch between thumbnails/bookmarks.
private void radButton1_Click(object sender, EventArgs e)
{
this.radPdfViewer1.ShowThumbnails();
}
private void radButton2_Click(object sender, EventArgs e)
{
this.radPdfViewer1.ShowBookmarks();
}
Expected: clicking the two buttons should switch between bookmarks/thumbnails
Actual: the user is stuck to bookmarks
With the R1 2021 version of our controls RadPdfViewer is using the RadPdfProcessing library model. In this scenario, the PDF document contains images with sizes 87380, 87654. Internally the control is using RenderTargetBitmap to draw the image. So when we pass these values as Width and Height to the constructor of this object an exception occurs. This is a limitation of the RenderTargetBitmap class. It can be reproduced outside of the RadPdfViewer.
RenderTargetBitmap bmp = new RenderTargetBitmap(87380, 87654,96,96,PixelFormats.Pbgra32);
As a workaround, we can use the old rendering engine of the control by setting the RadPdfViewer.UsePdfProcessingModel property to false.