var pageMarginsPropInfo = typeof(PagesLayoutManagerBase).GetField("pageMargins", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
pageMarginsPropInfo.SetValue(null, new Size(0, 0));
Provide a default appearance for fields that do not contain one.
Workaround: set border and background manually:
var provider = new PdfFormatProvider();
var document = provider.Import(File.ReadAllBytes(@"..\..\..\Systemvariablen.pdf"));
foreach (var item in document.AcroForm.FormFields)
{
var widget = item.Widgets.First() as VariableContentWidget;
if (widget != null)
{
widget.AppearanceCharacteristics.Background = new RgbColor(255, 0, 0);
widget.AppearanceCharacteristics.BorderColor = new RgbColor(0, 0, 255);
widget.Border = new AnnotationBorder(2, AnnotationBorderStyle.Solid, null);
widget.RecalculateContent();
}
}
pdfViewer.Document = document;
From the PDF Specification: "An ink annotation represents a freehand “scribble” composed of one or more disjoint paths. When opened, it displays a pop-up window containing the text of the associated note."
Sometimes the Ink annotations are imported as UnsupportedAnnotation and not displayed as expected. In such cases, the annotations could be removed from the RadFixedPage content in the following manner:
foreach (RadFixedPage page in document.Pages)
{
List<Annotation> inkAnnotations = page.Annotations.Where(a => a.Type == AnnotationType.Ink).ToList();
foreach (Annotation inkAnnotation in inkAnnotations)
{
page.Annotations.Remove(inkAnnotation);
}
}
According to the PDF specification (Adobe® Portable Document Format Version 1.7):
Append a rectangle to the current path as a complete subpath, with lower-left corner (x, y) and dimensions width and height in user space.
The operation:
x y width height re
An invalid case:
0 - 595 -842 re
This leads to an exception thrown: System.NullReferenceException: 'Object reference not set to an instance of an object.'
When extracting text from a composite font the ToUnicode mapping should be used but when this mapping is missing the char codes must be mapped by constructing a secondary map from fonts ordering and registry.
A possible workaround could be to register a TrueType font using the FontsRepository.RegisterFont() method:
FontsRepository.RegisterFont(new FontFamily(fontName), FontStyles.Normal, FontWeights.Normal, File.ReadAllBytes(pathToFont));
FontsRepository.TryCreateFont(new FontFamily(fontName), FontStyles.Normal, FontWeights.Normal, out FontBase font);
foreach (RadFixedPage page in document.Pages)
{
foreach (ContentElementBase contentElement in page.Content)
{
if (contentElement is TextFragment textFragment)
{
if (textFragment.Font.Name == fontName)
{
textFragment.Font = font;
}
}
}
}