当前位置: 首页>>代码示例>>C#>>正文


C# pdf.PdfString类代码示例

本文整理汇总了C#中iTextSharp.text.pdf.PdfString的典型用法代码示例。如果您正苦于以下问题:C# PdfString类的具体用法?C# PdfString怎么用?C# PdfString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PdfString类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseDAParam

        IDictionary<string, IList<object>> ParseDAParam(PdfString DA) {
            IDictionary<string, IList<object>> commandArguments = new Dictionary<string, IList<object>>();

            PRTokeniser tokeniser = new PRTokeniser(new RandomAccessFileOrArray(new RandomAccessSourceFactory().CreateSource(DA.GetBytes())));
            IList<object> currentArguments = new List<object>();

            while (tokeniser.NextToken()) {
                if (tokeniser.TokenType == PRTokeniser.TokType.OTHER) {
                    String key = tokeniser.StringValue;

                    if (key == "RG" || key == "G" || key == "K") {
                        key = STROKE_COLOR;
                    } else if (key == "rg" || key == "g" || key == "k") {
                        key = FILL_COLOR;
                    }

                    if (commandArguments.ContainsKey(key)) {
                        commandArguments[key] = currentArguments;
                    } else {
                        commandArguments.Add(key, currentArguments);
                    }

                    currentArguments = new List<object>();
                } else {
                    switch (tokeniser.TokenType) {
                        case PRTokeniser.TokType.NUMBER:
                            currentArguments.Add(new PdfNumber(tokeniser.StringValue));
                            break;

                        case PRTokeniser.TokType.NAME:
                            currentArguments.Add(new PdfName(tokeniser.StringValue));
                            break;

                        default:
                            currentArguments.Add(tokeniser.StringValue);
                            break;
                    }
                }
            }

            return commandArguments;
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:42,代码来源:PdfCleanUpProcessor.cs

示例2: AddItem

 /**
 * Sets the value of the collection item.
 * @param value
 */
 virtual public void AddItem(String key, PdfString value) {
     PdfName fieldname = new PdfName(key);
     PdfCollectionField field = (PdfCollectionField)schema.Get(fieldname);
     if (field.fieldType == PdfCollectionField.TEXT) {
         Put(fieldname, value);
     }
 }
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:11,代码来源:PdfCollectionItem.cs

示例3: AddRange

 internal void AddRange(PdfString from, PdfString to, PdfObject code) {
     byte[] a1 = DecodeStringToByte(from);
     byte[] a2 = DecodeStringToByte(to);
     if (a1.Length != a2.Length || a1.Length == 0)
         throw new ArgumentException("Invalid map.");
     byte[] sout = null;
     if (code is PdfString)
         sout = DecodeStringToByte((PdfString)code);
     int start = a1[a1.Length - 1] & 0xff;
     int end = a2[a2.Length - 1] & 0xff;
     for (int k = start; k <= end; ++k) {
         a1[a1.Length - 1] = (byte)k;
         PdfString s = new PdfString(a1);
         s.SetHexWriting(true);
         if (code is PdfArray) {
             AddChar(s, ((PdfArray)code)[k - start]);
         }
         else if (code is PdfNumber) {
             int nn = ((PdfNumber)code).IntValue + k - start;
             AddChar(s, new PdfNumber(nn));
         }
         else if (code is PdfString) {
             PdfString s1 = new PdfString(sout);
             s1.SetHexWriting(true);
             ++sout[sout.Length - 1];
             AddChar(s, s1);
         }
     }
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:29,代码来源:AbstractCMap.cs

示例4: AddChar

 internal override void AddChar(PdfString mark, PdfObject code) {
     if (!(code is PdfNumber))
         return;
     int codepoint;
     String s = DecodeStringToUnicode(mark);
     if (Utilities.IsSurrogatePair(s, 0))
         codepoint = Utilities.ConvertToUtf32(s, 0);
     else
         codepoint = (int)s[0];
     map[((PdfNumber)code).IntValue] = codepoint;
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:11,代码来源:CMapCidUni.cs

示例5: stringObjects

 virtual public void stringObjects()
 {
     byte[] bytes = new byte[256];
     for (int i = 0; i < 256; i++)
         bytes[i] = (byte) i;
     PdfString str = new PdfString(bytes);
     MemoryStream baos = new MemoryStream();
     str.SetHexWriting(true);
     str.ToPdf(null, baos);
     String s = Encoding.UTF8.GetString(baos.ToArray());
     Assert.AreEqual(514, s.Length);
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:12,代码来源:PdfAFileStructureTest.cs

示例6: AddChar

 internal override void AddChar(PdfString mark, PdfObject code)
 {
     byte[] src = mark.GetBytes();
     String dest = CreateStringFromBytes(code.GetBytes());
     if (src.Length == 1) {
         singleByteMappings[src[0] & 0xff] = dest;
     } else if (src.Length == 2) {
         int intSrc = src[0] & 0xFF;
         intSrc <<= 8;
         intSrc |= src[1] & 0xFF;
         doubleByteMappings[intSrc] = dest;
     } else {
         throw new IOException(MessageLocalization.GetComposedMessage("mapping.code.should.be.1.or.two.bytes.and.not.1", src.Length));
     }
 }
开发者ID:jomamorales,项目名称:createPDF,代码行数:15,代码来源:CMapToUnicode.cs

示例7: PdfOutline

 /**
  * Constructs a <CODE>PdfOutline</CODE>.
  * <P>
  * This is the constructor for an <CODE>outline entry</CODE>. The open mode is
  * <CODE>true</CODE>.
  *
  * @param parent the parent of this outline item
  * @param destination the destination for this outline item
  * @param title the title of this outline item
  */
 public PdfOutline(PdfOutline parent, PdfDestination destination, PdfString title)
     : this(parent, destination, title, true)
 {
 }
开发者ID:medvedttn,项目名称:itextsharp_mod-src,代码行数:14,代码来源:PdfOutline.cs

示例8: Close

 /**
 * Closes the document. No more content can be written after the
 * document is closed.
 * <p>
 * If closing a signed document with an external signature the closing must be done
 * in the <CODE>PdfSignatureAppearance</CODE> instance.
 * @throws DocumentException on error
 * @throws IOException on error
 */
 public void Close() {
     if (!hasSignature) {
         stamper.Close(moreInfo);
         return;
     }
     sigApp.PreClose();
     PdfSigGenericPKCS sig = sigApp.SigStandard;
     PdfLiteral lit = (PdfLiteral)sig.Get(PdfName.CONTENTS);
     int totalBuf = (lit.PosLength - 2) / 2;
     byte[] buf = new byte[8192];
     int n;
     Stream inp = sigApp.RangeStream;
     while ((n = inp.Read(buf, 0, buf.Length)) > 0) {
         sig.Signer.Update(buf, 0, n);
     }
     buf = new byte[totalBuf];
     byte[] bsig = sig.SignerContents;
     Array.Copy(bsig, 0, buf, 0, bsig.Length);
     PdfString str = new PdfString(buf);
     str.SetHexWriting(true);
     PdfDictionary dic = new PdfDictionary();
     dic.Put(PdfName.CONTENTS, str);
     sigApp.Close(dic);
     stamper.reader.Close();
 }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:34,代码来源:PdfStamper.cs

示例9: ReadPRObject

 /**
 * Reads a pdf object.
 * @return the pdf object
 * @throws IOException on error
 */
 public PdfObject ReadPRObject()
 {
     if (!NextValidToken())
         return null;
     PRTokeniser.TokType type = tokeniser.TokenType;
     switch (type) {
         case PRTokeniser.TokType.START_DIC: {
             PdfDictionary dic = ReadDictionary();
             return dic;
         }
         case PRTokeniser.TokType.START_ARRAY:
             return ReadArray();
         case PRTokeniser.TokType.STRING:
             PdfString str = new PdfString(tokeniser.StringValue, null).SetHexWriting(tokeniser.IsHexString());
             return str;
         case PRTokeniser.TokType.NAME:
             return new PdfName(tokeniser.StringValue, false);
         case PRTokeniser.TokType.NUMBER:
             return new PdfNumber(tokeniser.StringValue);
          case PRTokeniser.TokType.OTHER:
             return new PdfLiteral(COMMAND_TYPE, tokeniser.StringValue);
         default:
             return new PdfLiteral(-(int)type, tokeniser.StringValue);
     }
 }
开发者ID:jomamorales,项目名称:createPDF,代码行数:30,代码来源:PdfContentParser.cs

示例10: RenameField

 /**
 * Renames a field. Only the last part of the name can be renamed. For example,
 * if the original field is "ab.cd.ef" only the "ef" part can be renamed.
 * @param oldName the old field name
 * @param newName the new field name
 * @return <CODE>true</CODE> if the renaming was successful, <CODE>false</CODE>
 * otherwise
 */
 public bool RenameField(String oldName, String newName)
 {
     int idx1 = oldName.LastIndexOf('.') + 1;
     int idx2 = newName.LastIndexOf('.') + 1;
     if (idx1 != idx2)
         return false;
     if (!oldName.Substring(0, idx1).Equals(newName.Substring(0, idx2)))
         return false;
     if (fields.ContainsKey(newName))
         return false;
     Item item = (Item)fields[oldName];
     if (item == null)
         return false;
     newName = newName.Substring(idx2);
     PdfString ss = new PdfString(newName, PdfObject.TEXT_UNICODE);
     item.WriteToAll( PdfName.T, ss, Item.WRITE_VALUE | Item.WRITE_MERGED);
     item.MarkUsed( this, Item.WRITE_VALUE );
     fields.Remove(oldName);
     fields[newName] = item;
     return true;
 }
开发者ID:JamieMellway,项目名称:iTextSharpLGPL-Monotouch,代码行数:29,代码来源:AcroFields.cs

示例11: ReadPRObject

        virtual protected internal PdfObject ReadPRObject() {
            tokens.NextValidToken();
            PRTokeniser.TokType type = tokens.TokenType;
            switch (type) {
                case PRTokeniser.TokType.START_DIC: {
                    ++readDepth;
                    PdfDictionary dic = ReadDictionary();
                    --readDepth;
					long pos = tokens.FilePointer;
                    // be careful in the trailer. May not be a "next" token.
                    bool hasNext;
                    do {
                        hasNext = tokens.NextToken();
                    } while (hasNext && tokens.TokenType == PRTokeniser.TokType.COMMENT);

                    if (hasNext && tokens.StringValue.Equals("stream")) {
                        //skip whitespaces
                        int ch;
                        do {
                            ch = tokens.Read();                        
                        } while (ch == 32 || ch == 9 || ch == 0 || ch == 12);
                        if (ch != '\n')
                            ch = tokens.Read();
                        if (ch != '\n')
                            tokens.BackOnePosition(ch);
                        PRStream stream = new PRStream(this, tokens.FilePointer);
                        stream.Merge(dic);
                        stream.ObjNum = objNum;
                        stream.ObjGen = objGen;
                        return stream;
                    }
                    else {
                        tokens.Seek(pos);
                        return dic;
                    }
                }
                case PRTokeniser.TokType.START_ARRAY: {
                    ++readDepth;
                    PdfArray arr = ReadArray();
                    --readDepth;
                    return arr;
                }
                case PRTokeniser.TokType.NUMBER:
                    return new PdfNumber(tokens.StringValue);
                case PRTokeniser.TokType.STRING:
                    PdfString str = new PdfString(tokens.StringValue, null).SetHexWriting(tokens.IsHexString());
                    str.SetObjNum(objNum, objGen);
                    if (strings != null)
                        strings.Add(str);
                    return str;
                case PRTokeniser.TokType.NAME: {
                    PdfName cachedName;
                    PdfName.staticNames.TryGetValue(tokens.StringValue, out cachedName);
                    if (readDepth > 0 && cachedName != null) {
                        return cachedName;
                    } else {
                        // an indirect name (how odd...), or a non-standard one
                        return new PdfName(tokens.StringValue, false);
                    }
                }
                case PRTokeniser.TokType.REF:
                    int num = tokens.Reference;
                    PRIndirectReference refi = new PRIndirectReference(this, num, tokens.Generation);
                    return refi;
                case PRTokeniser.TokType.ENDOFFILE:
                    throw new IOException(MessageLocalization.GetComposedMessage("unexpected.end.of.file"));
                default:
                    String sv = tokens.StringValue;
                    if ("null".Equals(sv)) {
                        if (readDepth == 0) {
                            return new PdfNull();
                        } //else
                        return PdfNull.PDFNULL;
                    }
                    else if ("true".Equals(sv)) {
                        if (readDepth == 0) {
                            return new PdfBoolean( true );
                        } //else
                        return PdfBoolean.PDFTRUE;
                    }
                    else if ("false".Equals(sv)) {
                        if (readDepth == 0) {
                            return new PdfBoolean( false );
                        } //else
                        return PdfBoolean.PDFFALSE;
                    }
                    return new PdfLiteral(-(int)type, tokens.StringValue);
            }
        }
开发者ID:,项目名称:,代码行数:89,代码来源:

示例12: PdfObjectCheckTest3

        virtual public void PdfObjectCheckTest3()
        {
            string filename = OUT + "PdfObjectCheckTest3.pdf";
            FileStream fos = new FileStream(filename, FileMode.Create);

            Document document = new Document();

            PdfAWriter writer = PdfAWriter.GetInstance(document, fos, PdfAConformanceLevel.PDF_A_1B);
            writer.CreateXmpMetadata();

            document.Open();


            Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12);
            document.Add(new Paragraph("Hello World", font));

            FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read);
            ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream);
            iccProfileFileStream.Close();

            writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);

            String str = "";
            for (int i = 0; i < 65535; i++)
            {
                str += 'a';
            }
            PdfString pdfStr = new PdfString(str);
            writer.ExtraCatalog.Put(new PdfName("TestString"), pdfStr);
            document.Close();
        }
开发者ID:,项目名称:,代码行数:31,代码来源:

示例13: CreateAnnotation

 public override PdfAnnotation CreateAnnotation(float llx, float lly, float urx, float ury, PdfString title, PdfString content, PdfName subtype)
 {
     PdfAnnotation a = base.CreateAnnotation(llx, lly, urx, ury, title, content, subtype);
     if (!PdfName.POPUP.Equals(subtype))
         a.Put(PdfName.F, new PdfNumber(PdfAnnotation.FLAGS_PRINT));
     return a;
 }
开发者ID:unifamz,项目名称:UniversityManagementSystem,代码行数:7,代码来源:PdfAStamperImp.cs

示例14: DrawOverlayText

        private void DrawOverlayText(PdfContentByte canvas, IList<Rectangle> textRectangles, PdfString overlayText, 
                                     PdfString otDA, PdfNumber otQ, PdfBoolean otRepeat) {
            ColumnText ct = new ColumnText(canvas);
            ct.SetLeading(0, 1.2F);
            ct.UseAscender = true;

            String otStr = overlayText.ToUnicodeString();

            canvas.SaveState();
            IDictionary<string, IList<object>> parsedDA = ParseDAParam(otDA);

            Font font = null;

            if (parsedDA.ContainsKey(STROKE_COLOR)) {
                IList<object> strokeColorArgs = parsedDA[STROKE_COLOR];
                SetStrokeColor(canvas, strokeColorArgs);
            }

            if (parsedDA.ContainsKey(FILL_COLOR)) {
                IList<object> fillColorArgs = parsedDA[FILL_COLOR];
                SetFillColor(canvas, fillColorArgs);
            }

            if (parsedDA.ContainsKey("Tf")) {
                IList<object> tfArgs = parsedDA["Tf"];
                font = RetrieveFontFromAcroForm((PdfName) tfArgs[0], (PdfNumber) tfArgs[1]);
            }

            foreach (Rectangle textRect in textRectangles) {
                ct.SetSimpleColumn(textRect);

                if (otQ != null) {
                    ct.Alignment = otQ.IntValue;
                }

                Phrase otPhrase;

                if (font != null) {
                    otPhrase = new Phrase(otStr, font);
                } else {
                    otPhrase = new Phrase(otStr);
                }

                float y = ct.YLine;

                if (otRepeat != null && otRepeat.BooleanValue) {
                    int status = ct.Go(true);

                    while (!ColumnText.HasMoreText(status)) {
                        otPhrase.Add(otStr);
                        ct.SetText(otPhrase);
                        ct.YLine = y;
                        status = ct.Go(true);
                    }
                }

                ct.SetText(otPhrase);
                ct.YLine = y;
                ct.Go();
            }

            canvas.RestoreState();
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:63,代码来源:PdfCleanUpProcessor.cs

示例15: SetLabel

 /**
  * A text string specifying a label for displaying the units represented by
  * this NumberFormat in a user interface; the label should use a universally
  * recognized abbreviation.
  * 
  * @param label
  */
 virtual public void SetLabel(PdfString label) {
     base.Put(PdfName.U, label);
 }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:10,代码来源:NumberFormatDictionary.cs


注:本文中的iTextSharp.text.pdf.PdfString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。