Declined
Last Updated: 05 Jan 2021 12:50 by ADMIN
Fadi
Created on: 18 Dec 2020 16:16
Category: Telerik Document Processing
Type: Bug Report
1
Form Field issues

Attached a project to demonstrate some issues we're seeing that need resolving in order to use the component.

1. When using a font like Tahoma on a form field, the value no longer displays or contains garbled text.

2. Input file is 24KB, output is 2MB!

3. Rotated field lose their rotation after being flattened.

4. Simulate merging with other files, 100 times the file is now 150MB! It's as though it's not re-using the fonts, but keeps adding the same ones.

5. when merging, but not flattening, the form fields are all lost on pages after page 1

Attached Files:
3 comments
ADMIN
Martin
Posted on: 05 Jan 2021 12:50

Hi Fadi,

Thank you for catching that. You can fix this behavior by changing the clipping rectangle of the widget`s content. I slightly modified the prevoiosly provided code snippet:

FormSource widgetAppearance = GetWidgetNormalAppearance(widget);
if (widgetAppearance == null)
{
	return;
}

using (pageEditor.SavePosition())
{
	Rotation rotation = Rotation.Rotate0;
	if (widget is VariableContentWidget)
	{
		rotation = ((VariableContentWidget)widget).AppearanceCharacteristics.Rotation;
	}

	double rotationAngle = 360 - (double)rotation;
	Point rotationCenter = CalculateRotationCenter(rotation, widget.Rect);
	pageEditor.Position.RotateAt(rotationAngle, rotationCenter.X, rotationCenter.Y);

	pageEditor.Position.Translate(widget.Rect.Left, widget.Rect.Top);

	if (rotationAngle == 90 || rotationAngle == 270)
	{
		widgetAppearance.Size = new Size(widgetAppearance.Size.Height, widgetAppearance.Size.Width);

		foreach (Telerik.Windows.Documents.Fixed.Model.Common.ContentElementBase element in widgetAppearance.Content)
		{
			if (element.Clipping != null && element.Clipping.Clip is RectangleGeometry clippingRectangle)
			{
				clippingRectangle.Rect = new Rect(clippingRectangle.Rect.X, clippingRectangle.Rect.Y, clippingRectangle.Rect.Height, clippingRectangle.Rect.Width);
			}
		}
	}

	pageEditor.DrawForm(widgetAppearance);
}
where CalculateRotationCenter is:
private static Point CalculateRotationCenter(Rotation rotation, Rect rect)
{
	Point rotationCenter;

	switch (rotation)
	{
		case Rotation.Rotate90:
			rotationCenter = new Point(rect.Height / 2, rect.Height / 2);
			break;
		case Rotation.Rotate180:
			rotationCenter = new Point(rect.Width / 2, rect.Height / 2);
			break;
		case Rotation.Rotate270:
			rotationCenter = new Point(rect.Width / 2, rect.Width / 2);
			break;
		default:
			rotationCenter = new Point();
			break;
	}

	return rotationCenter;
}

I hope this helps.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Fadi
Posted on: 04 Jan 2021 17:38
3. That works but appears to be clipping the text to the height.
ADMIN
Martin
Posted on: 22 Dec 2020 17:24

Hi Fadi,

Thank you for creating and sharing this project with us.

I will dive straight to the points.

  1. This behavior seems to be caused by a known issue: PdfProcessing: CharCodes to glyph indices are incorrectly mapped when exporting TextBoxField with TrueType font and defined encoding. You can check the provided in the description workaround.
  2. The reason for this behavior is because the PdfProcessing library is embedding the Arial font on export. According to PDF specification, all fonts should be embedded except from 14 Standard PDF fonts. However, we have an item logged to change this: PdfProcessing: Implement a setting that allows to choose if the fonts should be embedded in the document.
  3. The suggested workaround for flattening the Form Fields doesn't respect the widget rotation. So if you need to keep the initial rotation a custom optimization has to be made. This is a simple example of how to modify the FlattenWidgetAppearance() method:
    FormSource widgetAppearance = GetWidgetNormalAppearance(widget);
    if (widgetAppearance == null)
    {
    	return;
    }
    pageEditor.Position.Translate(widget.Rect.Left, widget.Rect.Top);
    
    Telerik.Windows.Documents.Fixed.Model.Data.Rotation rotation = Telerik.Windows.Documents.Fixed.Model.Data.Rotation.Rotate0;
    if (widget is VariableContentWidget)
    {
    	rotation = ((VariableContentWidget)widget).AppearanceCharacteristics.Rotation;
    }
    
    double rotationAngle = 360 - (double)rotation;
    if (rotationAngle == 270 || rotationAngle == 90)
    {
    	pageEditor.Position.Translate(widget.Rect.X, widget.Rect.Bottom);
    }
    pageEditor.Position.Rotate(rotationAngle);
    
    pageEditor.DrawForm(widgetAppearance, widget.Rect.Width, widget.Rect.Height);
  4. I already logged an item in our backlog: PdfProcessing: Provide a mechanism to reuse an already embedded font when merging documents with the PdfStreamWriter.
  5. I logged an item on your behalf to fix this: PdfProcessing: Form Fields are not copied when merging documents` pages using PdfStreamWriter. If it is an option you can merge PDF documents out-of-the-box with the Merge() method of RadFixedDocument.
    In appreciation for bringing this to our attention, I updated your Telerik points.

You can cast your vote for the implementation of all of the Feature requests and follow all the items in order to receive updates when their status changes.

In order to follow our item logging pattern I created all the necessary items (already mentioned) and I am declining this one.

I hope you find this information helpful.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.