Some special charecter not printing on Pdf

We are trying to print some special charecter on pdf using "Arial.ttf" font but we are not able to print. and not getting any error also. am providing  code snipet  below.


PdfDocument document = new PdfDocument(PdfConformanceLevel.Pdf_A3B);

         //Add a page.

         PdfPage page = document.Pages.Add();


         //Create a PdfGrid.

         PdfGrid pdfGrid = new PdfGrid();


         //Create a DataTable.

         DataTable dataTable = new DataTable();

         string dataPath = @"C:\src\viklele\experiments\SyncFusion\TestData\";

         FileStream fontStream = new FileStream(dataPath + "Arial.ttf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

         PdfTrueTypeFont headerFont = new PdfTrueTypeFont(fontStream, true, PdfFontStyle.Regular, 30);

         pdfGrid.Style.Font = headerFont;

         dataTable.Columns.Add("ID");

         dataTable.Columns.Add("Name");


         //Add columns to the DataTable.

         for (int i = 0; i < 1; i++)

         {

            //Add rows to the DataTable.

            dataTable.Rows.Add(new object[] { "★ AANi & DAANI ★", "★ AANi & DAANI ★" });

            dataTable.Rows.Add(new object[] { "Ⱥ Adidas Ⱥ", "Ⱥ قسائم شرائية Ⱥ" });

         }

         //Assign data source.

         pdfGrid.DataSource = dataTable;


         //Draw grid to the page of PDF document.

         pdfGrid.Draw(page, new PointF(10, 10));


         //Create file stream.

         string outpath = @"C:\src\viklele\experiments\SyncFusion\TestData\TableTest2.pdf";

         using (FileStream outputFileStream = new FileStream(Path.GetFullPath(outpath), FileMode.Create, FileAccess.ReadWrite))

         {

            //Save the PDF document to file stream.

            document.Save(outputFileStream);

         }


         //Close the document.

         document.Close(true);


please provide support.




2 Replies

RB Ravikumar Baladhandapani Syncfusion Team August 9, 2023 04:50 PM UTC

Hi Dinesh,



We were able to reproduce the reported behavior with provided details on our end. Currently, we are validating on this and will update further details on August 11th, 2023.


Regards,

Ravikumar B.



SN Santhiya Narayanan Syncfusion Team August 11, 2023 12:34 PM UTC

On analysis, we found that the character ” was not supported by Arial font. Kindly use a font that supports the character.

Kindly use following code snippet for reference,

            //Create a new PDF document

            PdfDocument document = new PdfDocument(PdfConformanceLevel.Pdf_A3B);

 

            //Add a page.

            PdfPage page = document.Pages.Add();

 

            //Create a PdfGrid.

            PdfGrid pdfGrid = new PdfGrid();

 

            //Create a DataTable.

            DataTable dataTable = new DataTable();

            string dataPath = @"C:\src\viklele\experiments\SyncFusion\TestData\";

            FileStream fontStream = new FileStream(dataPath + "Arial.ttf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            PdfTrueTypeFont headerFont = new PdfTrueTypeFont(fontStream, true, PdfFontStyle.Regular, 30);

            pdfGrid.Style.Font = headerFont;

            dataTable.Columns.Add("ID");

            dataTable.Columns.Add("Name");

 

            //Add columns to the DataTable.

            for (int i = 0; i < 1; i++)

            {

                //Add rows to the DataTable.

                dataTable.Rows.Add(new object[] { " AANi & DAANI ", " AANi & DAANI " });

                dataTable.Rows.Add(new object[] { "Ⱥ Adidas Ⱥ", قسائم شرائية Ⱥ" });

            }

 

            //Assign data source.

            pdfGrid.DataSource = dataTable;

 

            pdfGrid.Rows[0].Style.Font = new PdfTrueTypeFont(File.OpenRead("Arial Unicode MS.TTF"), true, PdfFontStyle.Regular, 30);

 

            PdfStringFormat format = new PdfStringFormat();

            format.TextDirection = PdfTextDirection.RightToLeft;

            pdfGrid.Rows[1].Cells[1].StringFormat = format;

 

            //Draw grid to the page of PDF document.

            pdfGrid.Draw(page, new PointF(10, 10));

 

            //Create file stream.

            string outpath = @"C:\src\viklele\experiments\SyncFusion\TestData\TableTest2.pdf";

            using (FileStream outputFileStream = new FileStream(Path.GetFullPath(outpath), FileMode.Create, FileAccess.ReadWrite))

            {

                //Save the PDF document to file stream.

                document.Save(outputFileStream);

 

            }

 

            //Close the document.

            document.Close(true);


Loader.
Up arrow icon