We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

TextStamp with Courier font doesn't show underscores

Having an issue using TextStamp with Courier font pt. 12. Any underscore in the text doesn’t print because the rendering box for the text doesn’t have enough height. If I edit the PDF to give more height to the Text element I can make the underscores appear. Code is below:

static void Main(string[] args)
{
// Open document
Document pdfDocument = new Document("");
//Draw text in private method
DrawText(“FLOOR AMENDMENT NO.____”, pdfDocument.Pages[1], 0.10732387f, 0.7249726f, “Courier”, false, 12f);
// Save output document
pdfDocument.Save(“C:\AddTextStamp_out.pdf”);
}

private static void DrawText(string text, Page page, float x, float y, string fontName, bool isUnderlined, float fontSize)
{
TextStamp stamp = new TextStamp(text);
// Specify font name for Stamp object
stamp.TextState.Font = FontRepository.FindFont(fontName);
// Specify Font size for TextStamp
stamp.TextState.FontSize = fontSize;
stamp.TextState.Underline = isUnderlined;
// Set the XIndent for Stamp
stamp.XIndent = x * page.CropBox.Width;
// Set the YIndent for Stamp
stamp.YIndent = y * page.CropBox.Height;
// Add textual stamp to page instance
page.AddStamp(stamp);
}

Seems to be an issue with any PDF used.

@StatePeon

The same issue has been replicated in our environment while using 22.8 version of the API. Hence, it has been logged as PDFNET-52343 in our issue tracking system. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

Thanks Asad. Is there a workaround or some way to get the text onto a PDF in the meantime?

@StatePeon

The issue looks related to Adobe PDF as well because we found similar posts on Adobe Reader forums. We are afraid that we cannot offer any workaround without performing analysis against this ticket. You can however try changing the font in case it helps. We will let you know once we have further updates.