How to correctly set the size of an SignatureField-Rectangle in Aspose.PDF

Hi

Its not realy clear for me how to define the accurate size of an SignatureField-Rectangle.(Documentation)

If i want to set an image for the Signature-Field
(assign pdfFileSignature.SignatureAppearanceStream property - using a memorystream as source) - which values should i assing to the required System.Drawing.Rectangle.Size property required by the PdfFileSignature.Sign() method?

Do i have to set the size in Pixels from the System.Drawing.Image? Or in Points?
Because as documented:
https://docs.aspose.com/pdf/net/working-with-pages/
https://docs.aspose.com/pdf/net/changing-page-sizes-in-a-pdf-file/
the Aspose API works with Points!

So why is the required rectangle a System.Drawing.Rectangle which only allows integers for location and size… why isnt it a RectangleF? Or should i use pixels in this case?

I have tried several approaches (image size, converting from points to pixel and vise versa) - but the result never looks satisfying - the image is always a bit “blurry”.

Thanks a lot for any Information!

Hi Johannes,

Thanks for contacting support.

The default unit in Aspose.Pdf is point and in order to figure out the reasons behind issue which you are facing, can you please share the sample project and resource files, so that we can test the scenario in our environment. We are sorry for this inconvenience.

Hi!

I’m sorry - maybe it was a little bit late :wink:
…the problem is not related to the size of the annotation rectangle (SignatureField).
It seems that the created image itself isnt sharp.

I try to render an image out of an Aspose.Words.Document (MSWord-Docx) - but the reuslt is not really sharp. Especially small text in size 8 gets blurry.

Are there any suggestions for rendering the document as sharp as possible (like printed or in ms word?) - Im using the following code to save the document as an image:

var docSo = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Bmp); 
docSo.DmlEffectsRenderingMode = Aspose.Words.Saving.DmlEffectsRenderingMode.None; docSo.DmlRenderingMode = Aspose.Words.Saving.DmlRenderingMode.DrawingML; docSo.UseHighQualityRendering = true;
docSo.UseAntiAliasing = false;
docSo.PageCount = 1;
docSo.PageIndex = 0;

Thanks a lot!

Hi Johannes,

Thanks for your feedback. We will appreciate it if you please share your sample DOCX file as well. We will look into it and will guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

Hi!

I have attached the docx.

Thank you!

PS: I found this post on the forum - may its related to my issue? Is the feature implemented in newer versions already? → Small-fonts-blurry-when-rendering-rtf

Hi Johannes,

Thanks for sharing the document. Please use ImageSaveOptions.Resolution property to set the resolution for the generated images, in dots per inch. Hope this helps you. We have attached the output Bmp file with this post for your kind reference.

Document doc = new Document(MyDir + "egovSignaturblock.docx");
var docSo = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Bmp);
docSo.DmlEffectsRenderingMode = Aspose.Words.Saving.DmlEffectsRenderingMode.None;
docSo.DmlRenderingMode = Aspose.Words.Saving.DmlRenderingMode.DrawingML;
docSo.Resolution = 300;
docSo.UseHighQualityRendering = true;
docSo.UseAntiAliasing = false;
docSo.PageCount = 1;
docSo.PageIndex = 0;
doc.Save(MyDir + "Out.Bmp", docSo);

Hi!

Thank you for your response!
Unfortunately changeing the resoultion isnt really an option for me.
The lines of the table are thinner and my graphical operations on the image need more time because of the higher resoultion. I have to consider the performance because its one step in a large workflow.

The image should look like the Word-Document as faar as possible. So i have to use the default 96dpi. I’m sorry but i have to ask you again: Is my problem related to the link i provided above? (issue WORDSNET-13010: Will it help in my case?

Thanks!

Hi Johannes,

Thanks for your inquiry.

fankhauser@kufgem.at:
Is my problem related to the link i provided above? (issue WORDSNET-13010: Will it help in my case?

Please note that we just call default GDI+ function DrawString with some parameters. The problematic text (logged in WORDSNET-13010) has lower font size which do not render correctly in output image file format.

In your document, some text has bold formatting and this text seems to be a little bit blurry in output bmp. We have logged this problem in our issue tracking system as WORDSNET-13356. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

fankhauser@kufgem.at:
The lines of the table are thinner and my graphical operations on the image need more time because of the higher resoultion.

We have not found any issue with table’s border. You may increase the table’s border (line width) using Table.SetBorders method. Hope this helps you.

Document doc = new Document(MyDir + "egovSignaturblock.docx");
Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
table.SetBorders(LineStyle.Single, 1.5, Color.Black);

@fankhauserkufgem.at,

Thanks for your patience. It is to inform you that the issue (WORDSNET-13356) is actually not a bug in Aspose.Words. So, we have closed this issue as ‘Not a Bug’.

Aspose.Words have the methods Document.RenderToSize and Document.RenderToScale which accepts user Graphics object. So you can set any TextRenderingHint you want and then save Graphics object to the image. We suggest you please use Document.RenderToSize or Document.RenderToScale method. Hope this helps you.