Print Page | Close Window

AddTrueTypeFont not working as expected

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3517
Printed Date: 03 May 24 at 3:06AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: AddTrueTypeFont not working as expected
Posted By: donna
Subject: AddTrueTypeFont not working as expected
Date Posted: 23 Oct 17 at 1:49AM
Hi,

Please refer to below code. 
I passed m_titleFont as parameter to ConvertFontType method. 
When the server is executing line AddTrueFontType, the code is like hanging at there.
No exception was caught though.
Please advise. :)


Font m_titleFont = new Font("Arial", 18);

public void ConvertFontType(Font font)
        {
            try
            {
                string subfix = "";
                if (font.Bold && font.Italic)
                {
                    subfix = " [BoldItalic]";
                }
                else if (font.Bold)
                {
                    subfix = " [Bold]";
                }
                else if (font.Italic)
                {
                    subfix = " [Italic]";
                }

                bool found = false;
                string requestFontName = font.FontFamily.Name;
                int fontCount = m_qPdf.FontCount();
                requestFontName = font.FontFamily.Name + subfix;

                for (int i = 0; i < fontCount; i++)
                {
                   var selectFont = m_qPdf.SelectFont(i);
                    if (selectFont == 0)
                    {
                        // show error
                        return;
                    }

                    if (m_qPdf.FontName() == requestFontName)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    int fontID = m_qPdf.AddTrueTypeFont(requestFontName, 0); //<< hanging here
                    var selectFont = m_qPdf.SelectFont(fontID);
                    if (selectFont == 0)
                    {
                        // show error
                        return;
                    }
                }

                int _increment = 2;
                var setTextSize = m_qPdf.SetTextSize(font.Size + _increment);
                if (setTextSize == 0)
                {
                    // show error
                    return;
                }
            }
            catch(Exception ex)
            {
                // show error
            }
        }    



Replies:
Posted By: Ingo
Date Posted: 23 Oct 17 at 12:18PM
Hi Donna,

did you read all about AddTrueTypeFont here?
http://www.debenu.com/docs/pdf_library_reference/AddTrueTypeFont.php
If i understand your code there's the relevant font missing - so you want to add it.
I would assume that the font name in requestFontName is a bit different to the fontnamefile in the font-path of your system.
You should check the content of "requestFontName" and then you should have a look into your system if there's a fontfile with the same name.




-------------
Cheers,
Ingo




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk