Hebrew Font for an element loading bad

Hi,

I am using following code to generate a pdf. when I use my own FONT(Hebrew) to generate the pdf, the text being cut from the top, I am adding the sample pdf file and font file. Request to investigate and update me ASAP.

public void GeneratePDF()
    {
        var dataDir = AppDomain.CurrentDomain.BaseDirectory;
        var lic = new Aspose.Pdf.License();
        lic.SetLicense("Aspose.Pdf.lic");

        string fontFile = dataDir + "/HPSimplified.TTF";
        // Load input PDF file
        Document doc = new Document();
        // Create text builder object for first page of document
        //TextBuilder textBuilder = new TextBuilder(doc.Pages[1]);
        // Create text fragment with sample string
        TextFragment textFragment = new TextFragment("Hello world");

        if (fontFile != "")
        {
            // Load the TrueType font into stream object
            using (FileStream fontStream = System.IO.File.OpenRead(fontFile))
            {
                // Set the font name for text string
                textFragment.TextState.Font = FontRepository.OpenFont(fontStream, FontTypes.TTF);
                // Specify the position for Text Fragment
                textFragment.Position = new Position(100, 600);
                // Add the text to TextBuilder so that it can be placed over the PDF file
                //textBuilder.AppendText(textFragment);
                var page = doc.Pages.Add();
                page.Paragraphs.Add(textFragment);
            }

            dataDir = dataDir + "LoadingFontFromStream_out.pdf";
            // Save resulting PDF document
            doc.Save(dataDir);
        }
    }

HPSimplified.zip (215.2 KB)

LoadingFontFromStream_out.pdf (17.3 KB)

@rajasekharbatchu

Thanks for contacting support.

I have tested the scenario with your shared file(s) and observed the same issue which you have mentioned. Hence, I have logged an issue as PDFNET-42959 in our issue tracking system. We will further look into the details of the issue and keep you posted on the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.


Best Regards,
Asad Ali

Hi,

Do you have any update for the mentioned issue? To give a background of the seriousness, we got this issue in the production environment which is impacting many of the users who are using the system. Kindly act upon with high priority and provide a resolution immediately.

@rajasekharbatchu

Thanks for your inquiry.

As we just have notified the product team about the issue, so it is pending for review. Please note that there are other issues in the queue which were logged prior to yours and relevant team has been busy in resolving them. As soon as we have some significant updates regarding resolution of the issue, we will certainly inform you. Please be patient and spare us little time.

We are sorry for the inconvenience.


Best Regards,
Asad Ali

Hi,

Its been a while, there is no update from your team. Would like to know the update on this issue.

Regards,
Raj.

@rajasekharbatchu

Thanks for your inquiry.

I am afraid that earlier logged issue has not been yet resolved due to other pending issues in queue. Though we have recorded your concerns and intimated relevant team about them. We are sure that product team will plan to provide a fix against your issue as per their development schedule. As soon as we have some certain updates regarding resolution progress, we will let you know. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi,

Thanks for the reply. Its been months now, the concern was raised with you and your team. Not sure, by when we have a resolution and will have tough time answering our customer as we moved to production.

@rajasekharbatchu

Thanks for writing back.

Please note that we do realize the severity of the issue, but there are other high priority issues in the queue, which are pending to be resolved and issues have been resolved on first come first serve basis. However, we have requested relevant team to share an ETA (if possible). We will definitely let you know once we make some progress towards resolution of your issue.

Your patience and comprehension is greatly appreciated in this regard. Please spare us little time.

We are sorry for this inconvenience.

@rajasekharbatchu

Thanks for your patience.

We are please to inform you that earlier logged issue PDFNET-42959, has been resolved. After further investigation of the issue, we have found that the problem was with the font “HPSimplified.ttf”, that has specific metrics. Every font has an abstract square whose height is the intended distance between lines of type in the same type size. This square is called the em square and it is the design grid on which the glyph outlines are defined. Many letters of input font have points which are placed out of font’s em square bounds.

In order to display this font correctly, usage of special setting is needed. Please note that every object of type TextFragment has a set of text formatting options. These options are accessible via properties TextState.FormattingOptions. Last property of this path is property of type Aspose.Pdf.Text.TextFormattingOptions. This class has a an enumeration LineSpacingMode which is designed for specific fonts like input font “HPSimplified.ttf”.

Also class Aspose.Pdf.Text.TextFormattingOptions has a property LineSpacing of type LineSpacingMode. Please just set LineSpacing into LineSpacingMode.FullSize. So, code snippet to get correct PDF will be like this:

string fontFile = dataDir + "HPSimplified.TTF";
// Load input PDF file
Document doc = new Document();
//Create TextFormattingOptions with LineSpacingMode.FullSize
TextFormattingOptions formattingOptions = new TextFormattingOptions();
formattingOptions.LineSpacing = TextFormattingOptions.LineSpacingMode.FullSize;            

// Create text builder object for first page of document
//TextBuilder textBuilder = new TextBuilder(doc.Pages[1]);
// Create text fragment with sample string
TextFragment textFragment = new TextFragment("Hello world");

if (fontFile != "")
{
  // Load the TrueType font into stream object
  using (FileStream fontStream = System.IO.File.OpenRead(fontFile))
  {
    // Set the font name for text string
    textFragment.TextState.Font = FontRepository.OpenFont(fontStream, FontTypes.TTF);
    // Specify the position for Text Fragment
    textFragment.Position = new Position(100, 600);
    //Set TextFormattingOptions of current fragment to predefined(which points to LineSpacingMode.FullSize)
    textFragment.TextState.FormattingOptions = formattingOptions;
    // Add the text to TextBuilder so that it can be placed over the PDF file
    //textBuilder.AppendText(textFragment);
    var page = doc.Pages.Add();
    page.Paragraphs.Add(textFragment);
   }

  dataDir = dataDir + "LoadingFontFromStream_out2.pdf";
  // Save resulting PDF document
  doc.Save(dataDir);
}

For your reference, resultant file for code snippet is attached - LoadingFontFromStream_out2.pdf (17.3 KB).

Please try using the latest release version Aspose.Pdf for .NET 17.11 and in case you face any issue, please feel free to contact us.