本文整理汇总了C#中iTextSharp.text.pdf.PdfName类的典型用法代码示例。如果您正苦于以下问题:C# PdfName类的具体用法?C# PdfName怎么用?C# PdfName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfName类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfName类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestConstructionForType0WithoutToUnicodeMap
virtual public void TestConstructionForType0WithoutToUnicodeMap()
{
int pageNum = 2;
PdfName fontIdName = new PdfName("TT9");
string testFile = TestResourceUtils.GetResourceAsTempFile(TEST_RESOURCES_PATH, "type0FontWithoutToUnicodeMap.pdf");
RandomAccessFileOrArray f = new RandomAccessFileOrArray(testFile);
PdfReader reader = new PdfReader(f, null);
try
{
PdfDictionary fontsDic = reader.GetPageN(pageNum).GetAsDict(PdfName.RESOURCES).GetAsDict(PdfName.FONT);
PdfDictionary fontDicDirect = fontsDic.GetAsDict(fontIdName);
PRIndirectReference fontDicIndirect = (PRIndirectReference)fontsDic.Get(fontIdName);
Assert.AreEqual(PdfName.TYPE0, fontDicDirect.GetAsName(PdfName.SUBTYPE));
Assert.AreEqual("/Identity-H", fontDicDirect.GetAsName(PdfName.ENCODING).ToString());
Assert.IsNull(fontDicDirect.Get(PdfName.TOUNICODE), "This font should not have a ToUnicode map");
new DocumentFont(fontDicIndirect); // this used to throw an NPE
}
finally
{
reader.Close();
}
}
示例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);
}
}
示例3: AddItem
/**
* Sets the value of the collection item.
* @param value
*/
public void AddItem(String key, PdfNumber n) {
PdfName fieldname = new PdfName(key);
PdfCollectionField field = (PdfCollectionField)schema.Get(fieldname);
if (field.fieldType == PdfCollectionField.NUMBER) {
Put(fieldname, n);
}
}
示例4: PdfAppearance
static PdfAppearance()
{
stdFieldFontNames["Courier-BoldOblique"] = new PdfName("CoBO");
stdFieldFontNames["Courier-Bold"] = new PdfName("CoBo");
stdFieldFontNames["Courier-Oblique"] = new PdfName("CoOb");
stdFieldFontNames["Courier"] = new PdfName("Cour");
stdFieldFontNames["Helvetica-BoldOblique"] = new PdfName("HeBO");
stdFieldFontNames["Helvetica-Bold"] = new PdfName("HeBo");
stdFieldFontNames["Helvetica-Oblique"] = new PdfName("HeOb");
stdFieldFontNames["Helvetica"] = PdfName.HELV;
stdFieldFontNames["Symbol"] = new PdfName("Symb");
stdFieldFontNames["Times-BoldItalic"] = new PdfName("TiBI");
stdFieldFontNames["Times-Bold"] = new PdfName("TiBo");
stdFieldFontNames["Times-Italic"] = new PdfName("TiIt");
stdFieldFontNames["Times-Roman"] = new PdfName("TiRo");
stdFieldFontNames["ZapfDingbats"] = PdfName.ZADB;
stdFieldFontNames["HYSMyeongJo-Medium"] = new PdfName("HySm");
stdFieldFontNames["HYGoThic-Medium"] = new PdfName("HyGo");
stdFieldFontNames["HeiseiKakuGo-W5"] = new PdfName("KaGo");
stdFieldFontNames["HeiseiMin-W3"] = new PdfName("KaMi");
stdFieldFontNames["MHei-Medium"] = new PdfName("MHei");
stdFieldFontNames["MSung-Light"] = new PdfName("MSun");
stdFieldFontNames["STSong-Light"] = new PdfName("STSo");
stdFieldFontNames["MSungStd-Light"] = new PdfName("MSun");
stdFieldFontNames["STSongStd-Light"] = new PdfName("STSo");
stdFieldFontNames["HYSMyeongJoStd-Medium"] = new PdfName("HySm");
stdFieldFontNames["KozMinPro-Regular"] = new PdfName("KaMi");
}
示例5: Add
// methods
internal void Add(PdfName key, PdfDictionary resource) {
if (resource.Size == 0)
return;
PdfDictionary dic = GetAsDict(key);
if (dic == null)
Put(key, resource);
else
dic.Merge(resource);
}
示例6: Add
// methods
internal void Add(PdfName key, PdfDictionary resource)
{
if (resource.Size == 0)
return;
PdfDictionary dic = (PdfDictionary)PdfReader.GetPdfObject(Get(key));
if (dic == null)
Put(key, resource);
else
dic.Merge(resource);
}
示例7: ManipulatePdf
// ---------------------------------------------------------------------------
/**
* Manipulates a PDF file src with the byte array as result
*/
public byte[] ManipulatePdf(byte[] pdf)
{
PdfName key = new PdfName("ITXT_SpecialId");
PdfName value = new PdfName("123456789");
// Read the file
PdfReader reader = new PdfReader(pdf);
int n = reader.XrefSize;
PdfObject pdfObject;
PRStream prStream;
// Look for image and manipulate image prStream
for (int i = 0; i < n; i++) {
pdfObject = reader.GetPdfObject(i);
if (pdfObject == null || !pdfObject.IsStream()) continue;
prStream = (PRStream) pdfObject;
byte[] imageBytes;
if (value.Equals(prStream.Get(key))) {
PdfImageObject image = new PdfImageObject(prStream);
using (System.Drawing.Image original = image.GetDrawingImage()) {
if (original == null) continue;
int width = (int)(original.Width * FACTOR);
int height = (int)(original.Height * FACTOR);
using (System.Drawing.Image thumb = new Bitmap(width, height) ) {
using ( Graphics graphic = Graphics.FromImage(thumb) ) {
graphic.DrawImage(original, 0, 0, width, height);
using (MemoryStream ms = new MemoryStream()) {
thumb.Save(ms, ImageFormat.Jpeg);
imageBytes = ms.ToArray();
}
}
}
prStream.Clear();
prStream.SetData(imageBytes, false, PRStream.NO_COMPRESSION);
prStream.Put(PdfName.TYPE, PdfName.XOBJECT);
prStream.Put(PdfName.SUBTYPE, PdfName.IMAGE);
prStream.Put(key, value);
prStream.Put(PdfName.FILTER, PdfName.DCTDECODE);
prStream.Put(PdfName.WIDTH, new PdfNumber(width));
prStream.Put(PdfName.HEIGHT, new PdfNumber(height));
prStream.Put(PdfName.BITSPERCOMPONENT, new PdfNumber(8));
prStream.Put(PdfName.COLORSPACE, PdfName.DEVICERGB);
}
}
}
// Save altered PDF
using (MemoryStream ms = new MemoryStream()) {
using (PdfStamper stamper = new PdfStamper(reader, ms)) {
}
return ms.ToArray();
}
}
示例8: Close
virtual internal protected void Close(IDictionary<String, String> moreInfo) {
if (closed) {
return;
}
if (useVp) {
SetViewerPreferences();
}
if (flat) {
FlatFields();
}
if (flatFreeText) {
FlatFreeTextFields();
}
if (flatannotations) {
FlattenAnnotations();
}
AddFieldResources();
PdfDictionary catalog = reader.Catalog;
GetPdfVersion().AddToCatalog(catalog);
PdfDictionary acroForm = (PdfDictionary)PdfReader.GetPdfObject(catalog.Get(PdfName.ACROFORM), reader.Catalog);
if (acroFields != null && acroFields.Xfa.Changed) {
MarkUsed(acroForm);
if (!flat) {
acroFields.Xfa.SetXfa(this);
}
}
if (sigFlags != 0) {
if (acroForm != null) {
acroForm.Put(PdfName.SIGFLAGS, new PdfNumber(sigFlags));
MarkUsed(acroForm);
MarkUsed(catalog);
}
}
closed = true;
AddSharedObjectsToBody();
SetOutlines();
SetJavaScript();
AddFileAttachments();
// [C11] Output Intents
if (extraCatalog != null) {
catalog.MergeDifferent(extraCatalog);
}
if (openAction != null) {
catalog.Put(PdfName.OPENACTION, openAction);
}
if (pdf.pageLabels != null) {
catalog.Put(PdfName.PAGELABELS, pdf.pageLabels.GetDictionary(this));
}
// OCG
if (documentOCG.Count > 0) {
FillOCProperties(false);
PdfDictionary ocdict = catalog.GetAsDict(PdfName.OCPROPERTIES);
if (ocdict == null) {
reader.Catalog.Put(PdfName.OCPROPERTIES, OCProperties);
}
else {
ocdict.Put(PdfName.OCGS, OCProperties.Get(PdfName.OCGS));
PdfDictionary ddict = ocdict.GetAsDict(PdfName.D);
if (ddict == null) {
ddict = new PdfDictionary();
ocdict.Put(PdfName.D, ddict);
}
ddict.Put(PdfName.ORDER, OCProperties.GetAsDict(PdfName.D).Get(PdfName.ORDER));
ddict.Put(PdfName.RBGROUPS, OCProperties.GetAsDict(PdfName.D).Get(PdfName.RBGROUPS));
ddict.Put(PdfName.OFF, OCProperties.GetAsDict(PdfName.D).Get(PdfName.OFF));
ddict.Put(PdfName.AS, OCProperties.GetAsDict(PdfName.D).Get(PdfName.AS));
}
PdfWriter.CheckPdfIsoConformance(this, PdfIsoKeys.PDFISOKEY_LAYER, OCProperties);
}
// metadata
int skipInfo = -1;
PdfIndirectReference iInfo = reader.Trailer.GetAsIndirectObject(PdfName.INFO);
if (iInfo != null) {
skipInfo = iInfo.Number;
}
PdfDictionary oldInfo = reader.Trailer.GetAsDict(PdfName.INFO);
String producer = null;
if (oldInfo != null && oldInfo.Get(PdfName.PRODUCER) != null) {
producer = oldInfo.GetAsString(PdfName.PRODUCER).ToUnicodeString();
}
Version version = Version.GetInstance();
if (producer == null || version.GetVersion.IndexOf(version.Product) == -1) {
producer = version.GetVersion;
} else {
int idx = producer.IndexOf("; modified using");
StringBuilder buf;
if (idx == -1)
buf = new StringBuilder(producer);
else
buf = new StringBuilder(producer.Substring(0, idx));
buf.Append("; modified using ");
buf.Append(version.GetVersion);
producer = buf.ToString();
}
PdfIndirectReference info = null;
PdfDictionary newInfo = new PdfDictionary();
if (oldInfo != null) {
foreach (PdfName key in oldInfo.Keys) {
PdfObject value = PdfReader.GetPdfObject(oldInfo.Get(key));
newInfo.Put(key, value);
//.........这里部分代码省略.........
示例9: MoveRectangle
private static void MoveRectangle(PdfDictionary dic2, PdfReader r, int pageImported, PdfName key, String name) {
Rectangle m = r.GetBoxSize(pageImported, name);
if (m == null)
dic2.Remove(key);
else
dic2.Put(key, new PdfRectangle(m));
}
示例10: RichMediaInstance
/**
* Creates a RichMediaInstance. Also specifies the content type
* for the instance. Valid values are 3D, Flash, Sound, and Video.
* The subtype must match the asset file type of the instance.
* @param subtype possible values are:
* PdfName._3D, PdfName.FLASH, PdfName.SOUND, and PdfName.VIDEO.
*/
public RichMediaInstance(PdfName subtype) : base(PdfName.RICHMEDIAINSTANCE) {
Put(PdfName.SUBTYPE, subtype);
flash = PdfName.FLASH.Equals(subtype);
}