How To Set Dictionary To Annotation

Not sure if i missed it but looking at the api the only available related to dictionary is an appearance dictionary and this is not what i need.


Does aspose.PDF support setting dictionaries where a lower level of code blocks are needed?

Hi Chit,


Thanks for your inquiry. Please note currently Aspose.Pdf does not support to set annotation dictionary directly. We will appreciate it if you please share some more details of your requirement along with input and expected output PDF documents, so we will further investigate and log the issue accordingly.

Best Regards,

HI tilal. i posted inquiries regarding creating LineDimension and PolygonDimension (which i have done) annotations and not working when resized and you said you will log an issue # for them.


Have not heard any updates about it so i thought i could make the annotation by myself with the use of dictionaries.

Can you please instead post sample code how to create LineDimension and PolygonDimension annotations?

thank you

Hi Chit,


Thanks for your feedback. Are you referring the issue(PDFNET-41609) logged against your this post? I am afraid this issue is still not resolved, it is pending for investigation. However we have already raised the issue priority and our product team will plan its investigation very soon. So we will provide you some ETA/solution accordingly.

We are sorry for the inconvenience.

Best Regards,

The issues you have found earlier (filed as PDFNET-41609) have been fixed in Aspose.Pdf for .NET 17.5.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(3)

Hi,


Please check the following code snippet, which demonstrates how to create annotations with measurements:


Document doc = new Document();
Page asposePage = doc.Pages.Add();
Rectangle location = new Rectangle(100, 100, 600, 600);
PolygonAnnotation polyAnnot = new PolygonAnnotation(asposePage, location,
new Point[] {new Point(200, 200), new Point(400, 400), new Point(200, 400)});
polyAnnot.Color = Color.Red;
polyAnnot.StartingStyle = LineEnding.OpenArrow;
polyAnnot.EndingStyle = LineEnding.OpenArrow;
polyAnnot.Contents = “133 mm”;
polyAnnot.Measure = new Measure(polyAnnot);
polyAnnot.Measure.DistanceFormat = new Measure.NumberFormatList(polyAnnot.Measure);
polyAnnot.Measure.DistanceFormat.Add(new Measure.NumberFormat(polyAnnot.Measure));
polyAnnot.Measure.DistanceFormat[1].UnitLabel = “mm”;
polyAnnot.Measure.DistanceFormat[1].FractionSeparator = “.”;
polyAnnot.Measure.DistanceFormat[1].ConvresionFactor = 1;
polyAnnot.Measure.AreaFormat = new Measure.NumberFormatList(polyAnnot.Measure);
polyAnnot.Measure.AreaFormat.Add(new Measure.NumberFormat(polyAnnot.Measure));
polyAnnot.Measure.AreaFormat[1].UnitLabel = “mm”;
polyAnnot.Measure.AreaFormat[1].FractionSeparator = “.”;
polyAnnot.Measure.AreaFormat[1].ConvresionFactor = 1;
polyAnnot.Measure.XFormat = new Measure.NumberFormatList(polyAnnot.Measure);
polyAnnot.Measure.XFormat.Add(new Measure.NumberFormat(polyAnnot.Measure));
polyAnnot.Measure.XFormat[1].UnitLabel = “mm”;
polyAnnot.Measure.XFormat[1].FractionSeparator = “.”;
polyAnnot.Measure.XFormat[1].ConvresionFa


Thanks,

Hi, the line annotation distance measurement does not work. when i resize it, it does not recalculate. i already have this code


can you please confirm if i do not use license key, then it won’t resize? or will it? because this may be the problem. need verification from you

also, can you please provide a working sample?

PolygonAnnotation does not have getMeasure() (Only LineAnnotation). i am using Aspose PDF Java 17.4.

chitgoks:
Hi, the line annotation distance measurement does not work. when i resize it, it does not recalculate. i already have this code

can you please confirm if i do not use license key, then it won’t resize? or will it? because this may be the problem. need verification from you
Hi,

Thanks for contacting support.

I have again tested the scenario in trail as well as licensed mode and I am unable to notice any issue. As per my observations, when resizing the PolygonAnnotation annotation is properly recalculating. For your reference, I have also attached the output files generated with Aspose.Pdf for .NET 17.5 when using following code snippet.

chitgoks:
also, can you please provide a working sample?
Please try using following code snippet.
[C#]

Document doc = new
Document();

Page asposePage = doc.Pages.Add();

Aspose.Pdf.Rectangle
location = new Aspose.Pdf.Rectangle(100, 100, 600, 600);

Aspose.Pdf.Annotations.PolygonAnnotation
polyAnnot = new Aspose.Pdf.Annotations.PolygonAnnotation(asposePage, location,

new Aspose.Pdf.Point[]
{new Aspose.Pdf.Point(200,
200), new Aspose.Pdf.Point(400,
400), new Aspose.Pdf.Point(200,
400)});

polyAnnot.Color = Aspose.Pdf.Color.Red;

polyAnnot.StartingStyle = Aspose.Pdf.Annotations.LineEnding.OpenArrow;

polyAnnot.EndingStyle = Aspose.Pdf.Annotations.LineEnding.OpenArrow;

polyAnnot.Contents = “133
mm”
;

polyAnnot.Measure = new
Aspose.Pdf.Annotations.Measure(polyAnnot);

polyAnnot.Measure.DistanceFormat = new Aspose.Pdf.Annotations.Measure.NumberFormatList(polyAnnot.Measure);

polyAnnot.Measure.DistanceFormat.Add(new Aspose.Pdf.Annotations.Measure.NumberFormat(polyAnnot.Measure));

polyAnnot.Measure.DistanceFormat[1].UnitLabel = “mm”;

polyAnnot.Measure.DistanceFormat[1].FractionSeparator
= “.”;

polyAnnot.Measure.DistanceFormat[1].ConvresionFactor
= 1;

polyAnnot.Measure.AreaFormat = new Aspose.Pdf.Annotations.Measure.NumberFormatList(polyAnnot.Measure);

polyAnnot.Measure.AreaFormat.Add(new Aspose.Pdf.Annotations.Measure.NumberFormat(polyAnnot.Measure));

polyAnnot.Measure.AreaFormat[1].UnitLabel = “mm”;

polyAnnot.Measure.AreaFormat[1].FractionSeparator =
“.”;

polyAnnot.Measure.AreaFormat[1].ConvresionFactor =
1;

polyAnnot.Measure.XFormat = new Aspose.Pdf.Annotations.Measure.NumberFormatList(polyAnnot.Measure);

polyAnnot.Measure.XFormat.Add(new Aspose.Pdf.Annotations.Measure.NumberFormat(polyAnnot.Measure));

polyAnnot.Measure.XFormat[1].UnitLabel = “mm”;

polyAnnot.Measure.XFormat[1].FractionSeparator = “.”;

polyAnnot.Measure.XFormat[1].ConvresionFactor = 1;

polyAnnot.Measure.ScaleRatio = “1 mm = 1 mm”;

polyAnnot.Intent = Aspose.Pdf.Annotations.PolyIntent.PolygonDimension;

asposePage.Annotations.Add(polyAnnot);

doc.ExportAnnotationsToXfdf(“c:/pdftest/data.xfdf”);

doc.Save(“c:/pdftest/out-1.pdf”);

Document doc1 = new
Document();

doc1.Pages.Add();

doc1.ImportAnnotationsFromXfdf(“c:/pdftest/data.xfdf”);

doc1.Save(“c:/pdftest/out-2.pdf”);

chitgoks:
PolygonAnnotation does not have getMeasure() (Only LineAnnotation). i am using Aspose PDF Java 17.4.
I have managed to notice the same issue. For the sake of correction, I have logged it as PDFJAVA-36785 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for your inconvenience.

hi nayyer. appreciate the response.


however, you always give me code for .net. wherein im checking it for java. and it does not work.

can you please verify in java? because there is no version 17.5 in java, only 17.4.

Hi,


Thanks for sharing the details.

The reasons .NET code was shared is because the earlier reported issues was under Aspose.Pdf for .NET project. However as shared in my last comments, the PolygonAnnotation class is missing getMeasure(…) so the equivalent code cannot be executed. As soon as the problem is resolved, we will share the required code snippet. We are sorry for this confusion and inconvenience.

great! i’ll wait for the java lib. then i’ll do both testing in java and c#.


i assumed that when you release one for c#, its java counterpart will also be released at the same time.

thank you

Hi Chit,


Thanks for contacting support.

Yes your understanding is correct. First the issue is resolved in Aspose.Pdf for .NET and then same fix or any newly added feature is ported to its sibling Aspose.Pdf for Java. Please note that Aspose.Pdf for Java release is usually after the release of Aspose.Pdf for .NET.

Should you have any related query, please feel free to contact.

Hi Chit,


Adding more to my previous comments, the issue recently logged regarding missing getMeasure(…) object from PolygonAnnotation class is resolved. In fact the classes were not publicly available but they will become available starting next release of Aspose.Pdf for Java 17.5.

hi nayer. ive tried your code in .net for 17.5 and it worked


however, the re-measurement value is incorrect.

i wanted to have it based on inches so i changed mm to in

but when i resize the annotation, the values become big. is it different if inches?

please advise.

Hi Chit,


Thanks for sharing the details.

Are you observing this issue with LineAnnotation as PolygonAnnotation cannot be used, because of missing getMeasure(…) object. Can you please share the code snippet and resultant PDF which you have generated, so that we can further look into this matter. We are sorry for this inconvenience.

hi codewarrior here is my snippet

i tried to also add the area and xarea code as in your example but the resize value is still incorrect

Measure Distance

LineAnnotation lineAnnot = new LineAnnotation(asposePage, location, start, end);
lineAnnot.Title = firstComment.Username;
lineAnnot.Contents = firstComment.CommentText;
lineAnnot.Modified = firstComment.DateModified;
lineAnnot.Color = Color.FromRgb(Util.Hex2Rgb(annotation.Color).ToRgb());
lineAnnot.EndingStyle = LineEnding.OpenArrow;
lineAnnot.Contents = MeasureTool.ConvertToInch(
MeasureTool.GetMeasurementFromPixels(annotation.MeasurementType,
MeasureTool.GetDistance(start.X, start.Y, end.X, end.Y)),
annotation.MeasurementType);
lineAnnot.StartingStyle = LineEnding.OpenArrow;
lineAnnot.Intent = LineIntent.LineDimension ;
lineAnnot.Measure = new Measure(lineAnnot);
lineAnnot.Measure.DistanceFormat = new Measure.NumberFormatList(lineAnnot.Measure);
lineAnnot.Measure.DistanceFormat.Add(new Measure.NumberFormat(lineAnnot.Measure));
lineAnnot.Measure.DistanceFormat[1].UnitLabel = MeasureTool.GetMeasurementUnitInString(annotation.MeasurementType);
lineAnnot.Measure.DistanceFormat[1].FractionSeparator = ".";
lineAnnot.Measure.DistanceFormat[1].ConvresionFactor = 1;
lineAnnot.ShowCaption = true;
lineAnnot.CaptionPosition = CaptionPosition.Top;

asposePage.Annotations.Add(lineAnnot);

-----------------------------------------------

Measure Area

Used PolygonAnnotation


Hi,

Thanks for contacting support.

I have tried executing your code but I am afraid the method MeasureTool is currently not defined. Can you please share complete code snippet so that we can test the scenario in our environment. We are sorry for your inconvenience.

[C#]

Document doc = new Document();
Page asposePage = doc.Pages.Add();
Aspose.Pdf.Annotations.LineAnnotation lineAnnot = new Aspose.Pdf.Annotations.LineAnnotation(asposePage,new Aspose.Pdf.Rectangle(10,10,50,50), new Aspose.Pdf.Point(10,10), new Aspose.Pdf.Point(100,100));
lineAnnot.Title = firstComment.Username;
lineAnnot.Contents = firstComment.CommentText;
lineAnnot.Modified = firstComment.DateModified;
lineAnnot.Color = Aspose.Pdf.Color.FromRgb(Util.Hex2Rgb(annotation.Color).ToRgb());
lineAnnot.EndingStyle = Aspose.Pdf.Annotations.LineEnding.OpenArrow;
lineAnnot.Contents = MeasureTool.ConvertToInch(
MeasureTool.GetMeasurementFromPixels(annotation.MeasurementType,
MeasureTool.GetDistance(start.X, start.Y, end.X, end.Y)),
annotation.MeasurementType);
lineAnnot.StartingStyle = Aspose.Pdf.Annotations.LineEnding.OpenArrow;
lineAnnot.Intent = Aspose.Pdf.Annotations.LineIntent.LineDimension;
lineAnnot.Measure = new Aspose.Pdf.Annotations.Measure(lineAnnot);
lineAnnot.Measure.DistanceFormat = new Aspose.Pdf.Annotations.Measure.NumberFormatList(lineAnnot.Measure);
lineAnnot.Measure.DistanceFormat.Add(new Aspose.Pdf.Annotations.Measure.NumberFormat(lineAnnot.Measure));
lineAnnot.Measure.DistanceFormat[1].UnitLabel = MeasureTool.GetMeasurementUnitInString(annotation.MeasurementType);
lineAnnot.Measure.DistanceFormat[1].FractionSeparator = ".";
lineAnnot.Measure.DistanceFormat[1].ConvresionFactor = 1;
lineAnnot.ShowCaption = true;
lineAnnot.CaptionPosition = Aspose.Pdf.Annotations.CaptionPosition.Top;
asposePage.Annotations.Add(lineAnnot);

hi nayer, apologies


you can set the content to any value or just an empty string. it does not matter, because when the annotation gets resized, its Content value will be changed based on the measurement value.

Hi Chit,

Thanks for the acknowledgement.

I have tested the scenario using following code snippet but I am afraid I am unable to observe the issue when resizing the LineAnnotation in resultant PDF file. Can you please share some further details which can help us in understanding the problem. We are sorry for this inconvenience.

[C#]

Document doc = new Document();

Page asposePage = doc.Pages.Add();

Aspose.Pdf.Annotations.LineAnnotation lineAnnot = new Aspose.Pdf.Annotations.LineAnnotation(asposePage, new Aspose.Pdf.Rectangle(10, 10, 50, 50), new Aspose.Pdf.Point(10, 10), new Aspose.Pdf.Point(100, 100));

lineAnnot.Title = "firstComment.Username";

lineAnnot.Contents = "firstComment.CommentText";

//lineAnnot.Modified = "firstComment.DateModified";

lineAnnot.Color = Aspose.Pdf.Color.Aqua;

lineAnnot.EndingStyle = Aspose.Pdf.Annotations.LineEnding.OpenArrow;

lineAnnot.Contents = "Sample Content";

lineAnnot.StartingStyle = Aspose.Pdf.Annotations.LineEnding.OpenArrow;

lineAnnot.Intent = Aspose.Pdf.Annotations.LineIntent.LineDimension;

lineAnnot.Measure = new Aspose.Pdf.Annotations.Measure(lineAnnot);

lineAnnot.Measure.DistanceFormat = new Aspose.Pdf.Annotations.Measure.NumberFormatList(lineAnnot.Measure);

lineAnnot.Measure.DistanceFormat.Add(new Aspose.Pdf.Annotations.Measure.NumberFormat(lineAnnot.Measure));

lineAnnot.Measure.DistanceFormat[1].UnitLabel = "Unit Label";// MeasureTool.GetMeasurementUnitInString(annotation.MeasurementType);

lineAnnot.Measure.DistanceFormat[1].FractionSeparator = ".";

lineAnnot.Measure.DistanceFormat[1].ConvresionFactor = 1;

lineAnnot.ShowCaption = true;

lineAnnot.CaptionPosition = Aspose.Pdf.Annotations.CaptionPosition.Top;

asposePage.Annotations.Add(lineAnnot);

doc.Save(“c:/pdftest/AnnotationResize.pdf”);

hi codewarrior


please change the value of

lineAnnot.Measure.DistanceFormat[1].UnitLabel to “in” since i want the measurement to be in inches.

Now, let’s say

lineAnnot.Contents value is “17 in” which means 17 inches. what i meant by resize measurement is that when you move the arrows (expand or not), its measurement value caption should also reflect.

please see attached images so you can understand

distance1.jpg is the distance annotation.

distance2.jpg is after we move the other arrow end point and made it a smaller arrow, see the measurement of inches also changed? that is what i wish to achieve together with polygonAnnotation