Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, July 28, 2020 10:11:08 AM(UTC)
Abdul Rahman

Groups: Registered
Posts: 60


I'm converting my legacy annotation to web annotation. However font size looks very large in web viewer. After reading the following link https://www.leadtools.co...ac/annfont-fontsize.html I did some conversion manually in font size for all childrens in the annotation container as shown in the below code.

Here is my code:
Code:

XDocument rootXmllDocument;
string GetLicensePath = System.Web.HttpContext.Current.Server.MapPath("~");
string licenseFilePath = Path.Combine(GetLicensePath, "License", "LEADTOOLS.lic");
string licenseKeyFilePath = Path.Combine(GetLicensePath, "License", "LEADTOOLS.lic.key");
string developerKey = string.Empty;
using (StreamReader reader = new StreamReader(licenseKeyFilePath))
{
    developerKey = reader.ReadToEnd();
}
try
{
    RasterSupport.SetLicense(licenseFilePath, developerKey);
    if (RasterSupport.KernelExpired)
    {
        throw new Exception("LEADTOOLS License has Expired!");
    }
    string rootXmlString = "";
    int PageNumber;
    AnnContainer[] containers = new AnnContainer[annotationPathInfo.AnnotationFilePathList.Count];
    AnnCodecs annCodecs = new AnnCodecs();
    int i = 0;
    foreach (var annFilePath in annotationPathInfo.AnnotationFilePathList)
    {
        var annFile = new FileInfo(annFilePath);
        string fileExt = annFile.Extension;
        double dpiX = 96.0;
        double dpiY = 96.0;

        using (var codecs = new RasterCodecs())
        {
            if (!string.IsNullOrEmpty(annotationPathInfo.DocExtension))
            {
                codecs.Options.Load.Name = $"anything.{annotationPathInfo.DocExtension}";
            }
            string[] nameParts = annFile.Name.Split('.');
            PageNumber = int.Parse(nameParts[1]);
            RasterImage image = codecs.Load(annotationPathInfo.DocumentPath, PageNumber);

            double height = image.ImageHeight * (720 / (double)image.YResolution);
            double width = image.ImageWidth * (720 / (double)image.XResolution);

            if (image != null)
            {
                dpiX = image.XResolution;
                dpiY = image.YResolution;
            }

            var tempContainer = annCodecs.LoadAll(annFile.FullName, dpiX, dpiY).First();
            tempContainer.PageNumber = PageNumber;
            tempContainer.Size = new LeadSizeD(width, height);
            tempContainer.Mapper.MapResolutions(image.XResolution, image.YResolution, image.XResolution, image.YResolution);
            tempContainer.Resize(new LeadSizeD(width, height), AnnResizeContainerFlags.ResizeObjects, AnnResizeMode.Stretch);

            foreach (var child in tempContainer.Children)
            {
                //child.FixedStateOperations = AnnFixedStateOperations.FontSize;
               // Manual conversion I did to reduce font size. Is this correct approach?
                child.Font.FontSize = child.Font.FontSize * (child.Font.FontSize / 72);
            }

            containers[i] = tempContainer;
            image.Dispose();
        }

        i++;
    }
    rootXmlString = annCodecs.SaveAllToString(containers, AnnFormat.Annotations);
    rootXmllDocument = XDocument.Parse(rootXmlString);

}
catch (Exception ex)
{
    throw new Exception("Annotation Conversion Failed - " + ex.Message);
}

return rootXmllDocument.ToString(SaveOptions.DisableFormatting);



Please assist if this is correct or this can be done by configuring some options?
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, July 30, 2020 2:48:29 PM(UTC)
Matthew Bresson

Groups: Registered, Tech Support, Administrators
Posts: 98

Was thanked: 3 time(s) in 3 post(s)

Hello Abdul,

The method you are using looks like it does adjust the AnnFont to the size you desire. However, with the said, the AnnFont should not change when converting legacy annotations to the v20 annotations xml format. If you would like, I can take a look into this if you would like. I would need to see the legacy .ann file to do so.

I look forward to your reply.

Thanks
Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS
 
#3 Posted : Thursday, July 30, 2020 7:02:00 PM(UTC)
Abdul Rahman

Groups: Registered
Posts: 60


Dear Matt,

Sure. I'll attach the .ann file for your reference. I have a question. I have ceated a Text Annotation in legacy with text font size to 36. In the converted XML the font size is also 36. But both have the same units? Or different units? In this case 36 has the unit of Pt in legacy desktop annotations and Px in web annotations? Which means the rendered text size will be visually different in both places. Am I correct?

Here is the legacy .ann file.
File Attachment(s):
A00000e.0001.004.txt (4kb) downloaded 16 time(s).


Thanks,
Abdul Rahman

Edited by user Monday, August 3, 2020 7:42:21 AM(UTC)  | Reason: Not specified

 
#4 Posted : Tuesday, August 4, 2020 1:35:02 PM(UTC)
Abdul Rahman

Groups: Registered
Posts: 60


Dear Matt,

Any updates on this. Looking forward for your reply.

Thanks,
Abdul Rahman
 
#5 Posted : Wednesday, August 5, 2020 4:05:36 PM(UTC)
Matthew Bresson

Groups: Registered, Tech Support, Administrators
Posts: 98

Was thanked: 3 time(s) in 3 post(s)

Hello Abdul,

I am still currently working on replicating this issue that you are having. The different units, Pt and Px, I assume are points and pixels respectively. However, with that said the AnnTextObject size should not change from v13 legacy to v20 XML format. I will continue looking into this and revert back to you when I have an update. Let me know if you have any questions or comments in the meantime.

Thanks
Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS
 
#6 Posted : Friday, August 7, 2020 1:40:36 PM(UTC)
Matthew Bresson

Groups: Registered, Tech Support, Administrators
Posts: 98

Was thanked: 3 time(s) in 3 post(s)

Hello Abdul,

I am still currently working on your case. In the meantime, can you send me screenshots showing the font size difference from v13 desktop to v20 web?

Thanks
Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS
 
#7 Posted : Monday, August 10, 2020 9:17:13 AM(UTC)
Abdul Rahman

Groups: Registered
Posts: 60


Originally Posted by: Matthew Bresson Go to Quoted Post
Hello Abdul,

I am still currently working on your case. In the meantime, can you send me screenshots showing the font size difference from v13 desktop to v20 web?

Thanks


Dear Matt,

Here is the attachments. Image showing comparison between legacy and web. And legacy annotation file.

Font Size - Leg Vs Web.png
File Attachment(s):
A000027.0001.004.txt (2kb) downloaded 15 time(s).

 
#8 Posted : Tuesday, August 11, 2020 12:33:57 PM(UTC)
Matthew Bresson

Groups: Registered, Tech Support, Administrators
Posts: 98

Was thanked: 3 time(s) in 3 post(s)

Hello Abdul,

I have reproduced this problem and have reported it to our engineers. For your records, you may refer to this incident by the case number "CAS-131718-L7V6B1". This incident will be reviewed and prioritized by our engineering department. I will contact you when I get more information from our developers.

If you have any more questions, please let me know.

Thanks
Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS
 
#9 Posted : Wednesday, August 19, 2020 2:04:31 PM(UTC)
Matthew Bresson

Groups: Registered, Tech Support, Administrators
Posts: 98

Was thanked: 3 time(s) in 3 post(s)

Hello Abdul,

I received an update regarding your current reported issue. The issue could be stemming from setting FontRelativeToImageDpi to true.
https://www.leadtools.co...trelativetoimagedpi.html
This setting is true by default. Please see the screenshots attached below.

Please test this and let me know your results. Also, let me know if you have any questions about the information above.

File Attachment(s):
AbdulFontSizeIssue.zip (50kb) downloaded 16 time(s).


Thanks
Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS
 
#10 Posted : Thursday, August 20, 2020 2:03:12 AM(UTC)
Abdul Rahman

Groups: Registered
Posts: 60


Dear Matt,

I have set the FontRelativeToImageDpi = false. But still getting the same font size.

Here is the code change:

Code:

var tempContainer = annCodecs.LoadAll(annFile.FullName, dpiX, dpiY).First();
tempContainer.PageNumber = PageNumber;
tempContainer.Size = new LeadSizeD(width, height);
tempContainer.Mapper.MapResolutions(image.XResolution, image.YResolution, image.XResolution, image.YResolution);
tempContainer.Mapper.FontRelativeToImageDpi = false;
tempContainer.Resize(new LeadSizeD(width, height), AnnResizeContainerFlags.ResizeObjects, AnnResizeMode.Stretch);

// Temporary fix for font size issue
//foreach (var child in tempContainer.Children)
//{
//    //child.FixedStateOperations = AnnFixedStateOperations.FontSize;
//    child.Font.FontSize = child.Font.FontSize / 2;
//}

containers[i] = tempContainer;
containers[i].Mapper.FontRelativeToImageDpi = false;
image.Dispose();


Please can you assist on what I'm doing wrong?

Thanks,
Abdul Rahman
 
#11 Posted : Monday, August 24, 2020 10:38:24 AM(UTC)
Matthew Bresson

Groups: Registered, Tech Support, Administrators
Posts: 98

Was thanked: 3 time(s) in 3 post(s)

Hello Abdul,

I am not seeing anything that is indicating that you are not setting the property correctly. Can you send me a screenshot of a side by side comparison of v13 and v20 with the setting disabled? I want to see what you are getting on your end so I can pass that along to our engineers.

Thanks
Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.123 seconds.