Example #1
0
        public void SendToPDF(string filename, clsFont jfont)
        {
            //New document, 8.5"x11" in landscape orientation.
            iTextSharp.text.Document doc = new iTextSharp.text.Document(PageSize.LETTER.Rotate());

            //add metadata
            doc.AddTitle("Font preview for font " + jfont.SelectedFontName());
            doc.AddSubject("font family " + jfont.SelectedFontName());
            doc.AddAuthor("JLION.COM jFONT font preview utility");
            doc.AddCreationDate();

            //create a pdfwriter
            iTextSharp.text.pdf.PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(filename, FileMode.Create));

            //trap events
            PDFPageEvent pdfevent = new PDFPageEvent();

            writer.PageEvent = pdfevent;

            //create the doc
            doc.Open();
            doc.SetMargins(.75f * 72, .75f * 72, 0, 0);

            for (int currentPage = 0; currentPage < jfont.CountOfPages(); currentPage++)
            {
                //convert image to a pdf image for inclusion in the doc
                System.Drawing.Image jfontimage = jfont.MakeCharList(currentPage);
                //System.Drawing.Image jfontimage = jfont.MakeCharacterSample();
                iTextSharp.text.Image convertedimage = iTextSharp.text.Image.GetInstance(jfontimage, System.Drawing.Imaging.ImageFormat.Bmp);

                //determine size to scale to. PDF is 72 dpi, so 1 point is 1/72.
                System.Drawing.Rectangle PDFImageSize = jfont.ImageSize(72);

                convertedimage.ScaleAbsolute(PDFImageSize.Width, PDFImageSize.Height);

                //Add some blank space at the top of the document
                doc.Add(new Paragraph("Font: " + jfont.SelectedFontName()));
                doc.Add(new Paragraph("Style: " + jfont.SelectedFontStyle()));
                doc.Add(new Paragraph(""));
                doc.Add(new Paragraph(""));
                doc.Add(convertedimage);

                doc.NewPage();
            }

            doc.Close();
        }
Example #2
0
 private void setFont()
 {
     pictImage.SizeMode = PictureBoxSizeMode.AutoSize;
     pictImage.Image    = m_font.MakeCharList(0);
     //pictImage.Image = m_font.MakeCharacterSample();
 }