iTextSharp.text.pdf.Pfm2afm.Convert C# (CSharp) Метод

Convert() публичный статический Метод

public static Convert ( RandomAccessFileOrArray inp, Stream outp ) : void
inp RandomAccessFileOrArray
outp Stream
Результат void
        public static void Convert(RandomAccessFileOrArray inp, Stream outp)
        {
            Pfm2afm p = new Pfm2afm(inp, outp);
            p.Openpfm();
            p.Putheader();
            p.Putchartab();
            p.Putkerntab();
            p.Puttrailer();
            p.outp.Flush();
        }

Usage Example

Пример #1
0
        /** Creates a new Type1 font.
         * @param ttfAfm the AFM file if the input is made with a <CODE>byte</CODE> array
         * @param pfb the PFB file if the input is made with a <CODE>byte</CODE> array
         * @param afmFile the name of one of the 14 built-in fonts or the location of an AFM file. The file must end in '.afm'
         * @param enc the encoding to be applied to this font
         * @param emb true if the font is to be embedded in the PDF
         * @throws DocumentException the AFM file is invalid
         * @throws IOException the AFM file could not be read
         */
        internal Type1Font(string afmFile, string enc, bool emb, byte[] ttfAfm, byte[] pfb, bool forceRead)
        {
            if (emb && ttfAfm != null && pfb == null)
            {
                throw new DocumentException(MessageLocalization.GetComposedMessage("two.byte.arrays.are.needed.if.the.type1.font.is.embedded"));
            }
            if (emb && ttfAfm != null)
            {
                this.pfb = pfb;
            }
            encoding = enc;
            embedded = emb;
            fileName = afmFile;
            FontType = FONT_TYPE_T1;
            RandomAccessFileOrArray rf = null;
            Stream istr = null;

            if (BuiltinFonts14.ContainsKey(afmFile))
            {
                embedded    = false;
                builtinFont = true;
                byte[] buf = new byte[1024];
                try {
                    istr = GetResourceStream(RESOURCE_PATH + afmFile + ".afm");
                    if (istr == null)
                    {
                        string msg = MessageLocalization.GetComposedMessage("1.not.found.as.resource", afmFile);
                        Console.Error.WriteLine(msg);
                        throw new DocumentException(msg);
                    }
                    MemoryStream ostr = new MemoryStream();
                    while (true)
                    {
                        int size = istr.Read(buf, 0, buf.Length);
                        if (size == 0)
                        {
                            break;
                        }
                        ostr.Write(buf, 0, size);
                    }
                    buf = ostr.ToArray();
                }
                finally {
                    if (istr != null)
                    {
                        try {
                            istr.Close();
                        }
                        catch {
                            // empty on purpose
                        }
                    }
                }
                try {
                    rf = new RandomAccessFileOrArray(buf);
                    Process(rf);
                }
                finally {
                    if (rf != null)
                    {
                        try {
                            rf.Close();
                        }
                        catch {
                            // empty on purpose
                        }
                    }
                }
            }
            else if (afmFile.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".afm"))
            {
                try {
                    if (ttfAfm == null)
                    {
                        rf = new RandomAccessFileOrArray(afmFile, forceRead);
                    }
                    else
                    {
                        rf = new RandomAccessFileOrArray(ttfAfm);
                    }
                    Process(rf);
                }
                finally {
                    if (rf != null)
                    {
                        try {
                            rf.Close();
                        }
                        catch {
                            // empty on purpose
                        }
                    }
                }
            }
            else if (afmFile.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".pfm"))
            {
                try {
                    MemoryStream ba = new MemoryStream();
                    if (ttfAfm == null)
                    {
                        rf = new RandomAccessFileOrArray(afmFile, forceRead);
                    }
                    else
                    {
                        rf = new RandomAccessFileOrArray(ttfAfm);
                    }
                    Pfm2afm.Convert(rf, ba);
                    rf.Close();
                    rf = new RandomAccessFileOrArray(ba.ToArray());
                    Process(rf);
                }
                finally {
                    if (rf != null)
                    {
                        try {
                            rf.Close();
                        }
                        catch  {
                            // empty on purpose
                        }
                    }
                }
            }
            else
            {
                throw new DocumentException(MessageLocalization.GetComposedMessage("1.is.not.an.afm.or.pfm.font.file", afmFile));
            }
            EncodingScheme = EncodingScheme.Trim();
            if (EncodingScheme.Equals("AdobeStandardEncoding") || EncodingScheme.Equals("StandardEncoding"))
            {
                fontSpecific = false;
            }
            if (!encoding.StartsWith("#"))
            {
                PdfEncodings.ConvertToBytes(" ", enc); // check if the encoding exists
            }
            CreateEncoding();
        }
All Usage Examples Of iTextSharp.text.pdf.Pfm2afm::Convert