Answered by:
Create Arabic PDF

Question
-
User-1392077014 posted
Hello I use ItextShorp Dll but I want to Create Arabic Pdf and ItextShorp dosent Work with arabic valu Help Me
Monday, April 4, 2011 3:11 PM
Answers
-
User-1392077014 posted
this is my code help me
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net.Mail; using System; using System.IO; using System.Diagnostics; using iTextSharp.text; using iTextSharp.text.pdf; public partial class Test_Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var document = new Document(PageSize.A4, 50, 50, 25, 25); var output = new MemoryStream(); var writer = PdfWriter.GetInstance(document, output); document.Open(); BaseFont bf = BaseFont.CreateFont("c:\\windows\\fonts\\times.ttf", BaseFont.IDENTITY_H, true); string fontpath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\arabtype.ttf"; var titleFont = FontFactory.GetFont(fontpath, 18, Font.BOLD); var subTitleFont = FontFactory.GetFont(fontpath, 14, Font.BOLD); var boldTableFont = FontFactory.GetFont(fontpath, 12, Font.BOLD); var endingMessageFont = FontFactory.GetFont(fontpath, 10, Font.ITALIC); var bodyFont = FontFactory.GetFont(fontpath, 12, Font.NORMAL); document.Add(new Paragraph("sdfsdfsdfsdf", titleFont)); document.Add(new Paragraph("صثقثصقصثقص", bodyFont)); document.Add(Chunk.NEWLINE); document.Add(new Paragraph("Order Information", subTitleFont)); var orderInfoTable = new PdfPTable(2); orderInfoTable.HorizontalAlignment = 0; orderInfoTable.SpacingBefore = 10; orderInfoTable.SpacingAfter = 10; orderInfoTable.DefaultCell.Border = 0; orderInfoTable.SetWidths(new int[] { 1, 2 }); ContactsDateSet.tbl_ContactsDataTable oContactsDataTable = BLL.Contacts.Contacts.GetContacts(30); orderInfoTable.AddCell(new Phrase("MobileNumber", boldTableFont)); foreach (ContactsDateSet.tbl_ContactsRow item in oContactsDataTable) { orderInfoTable.AddCell(item.Contact_LastName); orderInfoTable.AddCell(item.Contact_PrimeryPhoneNumber); } document.Add(orderInfoTable); document.Add(new Paragraph("لیست شماره های ذخیره شده در لیست", subTitleFont)); // Add ending message var endingMessage = new Paragraph("لیست شماره های ذخیره شده در لیست", endingMessageFont); //endingMessage.SetAlignment("Center"); document.Add(endingMessage); // Finally, add an image in the upper right corner var logo = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/4guysfromrolla.gif")); logo.SetAbsolutePosition(440, 800); document.Add(logo); document.Close(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", string.Format("attachment;filename=Receipt-{0}.pdf", "ss")); Response.BinaryWrite(output.ToArray()); } } public class iTextDemo { public static void Main() { Console.WriteLine("iText Demo"); // step 1: creation of a document-object Document myDocument = new Document(PageSize.A4.Rotate()); try { } catch (DocumentException de) { Console.Error.WriteLine(de.Message); } catch (IOException ioe) { Console.Error.WriteLine(ioe.Message); } // step 5: Remember to close the documnet myDocument.Close(); } }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 5, 2011 9:29 AM
All replies
-
User-1392077014 posted
help me
Tuesday, April 5, 2011 7:13 AM -
User-1392077014 posted
this is my code help me
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net.Mail; using System; using System.IO; using System.Diagnostics; using iTextSharp.text; using iTextSharp.text.pdf; public partial class Test_Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var document = new Document(PageSize.A4, 50, 50, 25, 25); var output = new MemoryStream(); var writer = PdfWriter.GetInstance(document, output); document.Open(); BaseFont bf = BaseFont.CreateFont("c:\\windows\\fonts\\times.ttf", BaseFont.IDENTITY_H, true); string fontpath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\arabtype.ttf"; var titleFont = FontFactory.GetFont(fontpath, 18, Font.BOLD); var subTitleFont = FontFactory.GetFont(fontpath, 14, Font.BOLD); var boldTableFont = FontFactory.GetFont(fontpath, 12, Font.BOLD); var endingMessageFont = FontFactory.GetFont(fontpath, 10, Font.ITALIC); var bodyFont = FontFactory.GetFont(fontpath, 12, Font.NORMAL); document.Add(new Paragraph("sdfsdfsdfsdf", titleFont)); document.Add(new Paragraph("صثقثصقصثقص", bodyFont)); document.Add(Chunk.NEWLINE); document.Add(new Paragraph("Order Information", subTitleFont)); var orderInfoTable = new PdfPTable(2); orderInfoTable.HorizontalAlignment = 0; orderInfoTable.SpacingBefore = 10; orderInfoTable.SpacingAfter = 10; orderInfoTable.DefaultCell.Border = 0; orderInfoTable.SetWidths(new int[] { 1, 2 }); ContactsDateSet.tbl_ContactsDataTable oContactsDataTable = BLL.Contacts.Contacts.GetContacts(30); orderInfoTable.AddCell(new Phrase("MobileNumber", boldTableFont)); foreach (ContactsDateSet.tbl_ContactsRow item in oContactsDataTable) { orderInfoTable.AddCell(item.Contact_LastName); orderInfoTable.AddCell(item.Contact_PrimeryPhoneNumber); } document.Add(orderInfoTable); document.Add(new Paragraph("لیست شماره های ذخیره شده در لیست", subTitleFont)); // Add ending message var endingMessage = new Paragraph("لیست شماره های ذخیره شده در لیست", endingMessageFont); //endingMessage.SetAlignment("Center"); document.Add(endingMessage); // Finally, add an image in the upper right corner var logo = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/4guysfromrolla.gif")); logo.SetAbsolutePosition(440, 800); document.Add(logo); document.Close(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", string.Format("attachment;filename=Receipt-{0}.pdf", "ss")); Response.BinaryWrite(output.ToArray()); } } public class iTextDemo { public static void Main() { Console.WriteLine("iText Demo"); // step 1: creation of a document-object Document myDocument = new Document(PageSize.A4.Rotate()); try { } catch (DocumentException de) { Console.Error.WriteLine(de.Message); } catch (IOException ioe) { Console.Error.WriteLine(ioe.Message); } // step 5: Remember to close the documnet myDocument.Close(); } }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 5, 2011 9:29 AM