Embed fonts in PDF document using C# with Aspose.PDF - Embedding font changes the text direction in the PDF

Embedding font changes the text direction in the PDF

Used below code to Embedding font in the PDF

Stream from_stream = File.OpenRead(@“C:\WorkSpace\2.pdf”);
Document doc = new Document(from_stream);
doc.EmbedStandardFonts = true;
foreach (Page page in doc.Pages)
{
if (page.Resources.Fonts != null)
{
foreach (Aspose.Pdf.Text.Font pageFont in page.Resources.Fonts)
{
if (!pageFont.IsEmbedded)
{
pageFont.IsEmbedded = true;
}
}
}
doc.Save(@“C:\WorkSpace\output.pdf”);

Horizontal text is becoming vertical

Files attached : Before.pdf - before Embedding Font , After.pdf - afer Embedding Font

textAfter.pdf (90.7 KB)
Before.pdf (50.2 KB)

@raja.csharp

Would you kindly try using API with valid license. In case you do not have one, please consider applying 30-days free temporary license as we have tested the scenario in our environment and issue was not reproduced. For your kind reference, an output PDF is also attached.
After_20.1.pdf (50.2 KB)

Thanks for the reply, Your file size looks same as before so it looks like you have not Embed the font to the file

Scenario : Use before.pdf and set EmbedStandardFonts = true and IsEmbedded = true like the code snipped in the ticket , Saved file will have the fonts embedded , now open and see pdf , text direction become vertical.

@raja.csharp

Sorry for the confusion.

We missed “EmbedStandardFonts = true” command during testing and after testing with this, we were able to notice the issue. Hence, we have logged it as PDFNET-47603 in our issue tracking system for further investigation. We will let you know as soon as we have additional updates regarding its resolution. Please be patient and spare us little time.

We are sorry for the inconvenience.

Any update on this issue ?

@raja.csharp

As the issue was recently logged in our issue tracking system, it is pending for analysis. Please note that issues logged under free support model are resolved on first come first serve basis. We will surely inform you as soon as it is resolved. Please spare us some time.

We are sorry for the inconvenience.

i am getting fonts as null what is the else part to add fonts

if (page.Resources.Fonts != null)

@rameshsakthiganesan

There is no else part in this condition. You can add text in the PDF or perform any other modifications. Once the PDF is generated and saved using the API, it will embed fonts accordingly. Furthermore, please share the complete code snippet and your requirements details so that we can further investigate and share our feedback with you accordingly.