本文整理汇总了C#中iTextSharp.text.pdf.PdfDictionary类的典型用法代码示例。如果您正苦于以下问题:C# PdfDictionary类的具体用法?C# PdfDictionary怎么用?C# PdfDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfDictionary类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadTree
public static Hashtable ReadTree(PdfDictionary dic)
{
Hashtable items = new Hashtable();
if (dic != null)
IterateItems(dic, items);
return items;
}
示例2: ImageRenderInfo
private ImageRenderInfo(Matrix ctm, PdfIndirectReference refi, PdfDictionary colorSpaceDictionary)
{
this.ctm = ctm;
this.refi = refi;
this.inlineImageInfo = null;
this.colorSpaceDictionary = colorSpaceDictionary;
}
示例3: UnembedTTF
/**
* Processes a dictionary.
* In case of font dictionaries, the dictionary is processed.
*/
public void UnembedTTF(PdfDictionary dict)
{
// we ignore all dictionaries that aren't font dictionaries
if (!dict.IsFont())
return;
// we only remove TTF fonts
if (dict.GetAsDict(PdfName.FONTFILE2) != null)
{
return;
}
// check if a subset was used (in which case we remove the prefix)
PdfName baseFont = dict.GetAsName(PdfName.BASEFONT);
if (baseFont.GetBytes()[7] == '+')
{
baseFont = new PdfName(baseFont.ToString().Substring(8));
dict.Put(PdfName.BASEFONT, baseFont);
}
// we check if there's a font descriptor
PdfDictionary fontDescriptor = dict.GetAsDict(PdfName.FONTDESCRIPTOR);
if (fontDescriptor == null)
return;
// is there is, we replace the fontname and remove the font file
fontDescriptor.Put(PdfName.FONTNAME, baseFont);
fontDescriptor.Remove(PdfName.FONTFILE2);
}
示例4: GetDictionaryDetail
/**
* Shows the detail of a dictionary.
* @param dic the dictionary of which you want the detail
* @param depth the depth of the current dictionary (for nested dictionaries)
* @return a String representation of the dictionary
*/
public static String GetDictionaryDetail(PdfDictionary dic, int depth){
StringBuilder builder = new StringBuilder();
builder.Append('(');
IList<PdfName> subDictionaries = new List<PdfName>();
foreach (PdfName key in dic.Keys) {
PdfObject val = dic.GetDirectObject(key);
if (val.IsDictionary())
subDictionaries.Add(key);
builder.Append(key);
builder.Append('=');
builder.Append(val);
builder.Append(", ");
}
builder.Length = builder.Length-2;
builder.Append(')');
foreach (PdfName pdfSubDictionaryName in subDictionaries) {
builder.Append('\n');
for (int i = 0; i < depth+1; i++){
builder.Append('\t');
}
builder.Append("Subdictionary ");
builder.Append(pdfSubDictionaryName);
builder.Append(" = ");
builder.Append(GetDictionaryDetail(dic.GetAsDict(pdfSubDictionaryName), depth+1));
}
return builder.ToString();
}
示例5: CreatePdf
// ---------------------------------------------------------------------------
public byte[] CreatePdf() {
using (MemoryStream ms = new MemoryStream()) {
// step 1
using (Document document = new Document(new Rectangle(850, 600))) {
// step 2
PdfWriter writer = PdfWriter.GetInstance(document, ms);
// step 3
document.Open();
// step 4
PdfContentByte canvas = writer.DirectContent;
// add the clipped image
Image img = Image.GetInstance(
Path.Combine(Utility.ResourceImage, RESOURCE)
);
float w = img.ScaledWidth;
float h = img.ScaledHeight;
canvas.Ellipse(1, 1, 848, 598);
canvas.Clip();
canvas.NewPath();
canvas.AddImage(img, w, 0, 0, h, 0, -600);
// Create a transparent PdfTemplate
PdfTemplate t2 = writer.DirectContent.CreateTemplate(850, 600);
PdfTransparencyGroup transGroup = new PdfTransparencyGroup();
transGroup.Put( PdfName.CS, PdfName.DEVICEGRAY);
transGroup.Isolated = true;
transGroup.Knockout = false;
t2.Group = transGroup;
// Add transparent ellipses to the template
int gradationStep = 30;
float[] gradationRatioList = new float[gradationStep];
for(int i = 0; i < gradationStep; i++) {
/*
* gotta love .NET, guess they forgot to copy java.lang.Math.toRadians
*/
double radians = (Math.PI / 180) * 90.0f / gradationStep * (i + 1);
gradationRatioList[i] = 1 - (float) Math.Sin(radians);
}
for(int i = 1; i < gradationStep + 1; i++) {
t2.SetLineWidth(5 * (gradationStep + 1 - i));
t2.SetGrayStroke(gradationRatioList[gradationStep - i]);
t2.Ellipse(0, 0, 850, 600);
t2.Stroke();
}
// Create an image mask for the direct content
PdfDictionary maskDict = new PdfDictionary();
maskDict.Put(PdfName.TYPE, PdfName.MASK);
maskDict.Put(PdfName.S, new PdfName("Luminosity"));
maskDict.Put(new PdfName("G"), t2.IndirectReference);
PdfGState gState = new PdfGState();
gState.Put(PdfName.SMASK, maskDict );
canvas.SetGState(gState);
canvas.AddTemplate(t2, 0, 0);
}
return ms.ToArray();
}
}
示例6: MapRole
/**
* Maps the user tags to the standard tags. The mapping will allow a standard application to make some sense of the tagged
* document whatever the user tags may be.
* @param used the user tag
* @param standard the standard tag
*/
public void MapRole(PdfName used, PdfName standard) {
PdfDictionary rm = (PdfDictionary)Get(PdfName.ROLEMAP);
if (rm == null) {
rm = new PdfDictionary();
Put(PdfName.ROLEMAP, rm);
}
rm.Put(used, standard);
}
示例7: Write
// ---------------------------------------------------------------------------
public void Write(Stream stream)
{
// step 1
using (Document document = new Document()) {
// step 2
PdfWriter writer = PdfWriter.GetInstance(document, stream);
// step 3
document.Open();
// step 4
Rectangle rect = new Rectangle(100, 400, 500, 800);
rect.Border = Rectangle.BOX;
rect.BorderWidth = 0.5f;
rect.BorderColor = new BaseColor(0xFF, 0x00, 0x00);
document.Add(rect);
PdfIndirectObject streamObject = null;
using (FileStream fs =
new FileStream(RESOURCE, FileMode.Open, FileAccess.Read))
{
PdfStream stream3D = new PdfStream(fs, writer);
stream3D.Put(PdfName.TYPE, new PdfName("3D"));
stream3D.Put(PdfName.SUBTYPE, new PdfName("U3D"));
stream3D.FlateCompress();
streamObject = writer.AddToBody(stream3D);
stream3D.WriteLength();
}
PdfDictionary dict3D = new PdfDictionary();
dict3D.Put(PdfName.TYPE, new PdfName("3DView"));
dict3D.Put(new PdfName("XN"), new PdfString("Default"));
dict3D.Put(new PdfName("IN"), new PdfString("Unnamed"));
dict3D.Put(new PdfName("MS"), PdfName.M);
dict3D.Put(
new PdfName("C2W"),
new PdfArray(
new float[] { 1, 0, 0, 0, 0, -1, 0, 1, 0, 3, -235, 28 }
)
);
dict3D.Put(PdfName.CO, new PdfNumber(235));
PdfIndirectObject dictObject = writer.AddToBody(dict3D);
PdfAnnotation annot = new PdfAnnotation(writer, rect);
annot.Put(PdfName.CONTENTS, new PdfString("3D Model"));
annot.Put(PdfName.SUBTYPE, new PdfName("3D"));
annot.Put(PdfName.TYPE, PdfName.ANNOT);
annot.Put(new PdfName("3DD"), streamObject.IndirectReference);
annot.Put(new PdfName("3DV"), dictObject.IndirectReference);
PdfAppearance ap = writer.DirectContent.CreateAppearance(
rect.Width, rect.Height
);
annot.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, ap);
annot.SetPage();
writer.AddAnnotation(annot);
}
}
示例8: 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);
}
示例9: AddPage
internal void AddPage(PdfDictionary page) {
if ((pages.Count % leafSize) == 0)
parents.Add(writer.PdfIndirectReference);
PdfIndirectReference parent = parents[parents.Count - 1];
page.Put(PdfName.PARENT, parent);
PdfIndirectReference current = writer.CurrentPage;
writer.AddToBody(page, current);
pages.Add(current);
}
示例10: PdfAXmpWriter
/**
* Creates and XMP writer that adds info about the PDF/A conformance level.
* @param os
* @param info
* @param conformanceLevel
* @throws IOException
*/
public PdfAXmpWriter(Stream os, PdfDictionary info, PdfAConformanceLevel conformanceLevel)
: base(os, info) {
try {
AddRdfDescription(conformanceLevel);
}
catch (XmpException xmpExc) {
throw new IOException(xmpExc.Message);
}
}
示例11: 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);
}
示例12: PdfMediaClipData
internal PdfMediaClipData(String file, PdfFileSpecification fs, String mimeType) {
Put(PdfName.TYPE,new PdfName("MediaClip"));
Put(PdfName.S, new PdfName("MCD"));
Put(PdfName.N, new PdfString("Media clip for "+file));
Put(new PdfName("CT"), new PdfString(mimeType));
PdfDictionary dic = new PdfDictionary();
dic.Put(new PdfName("TF"), new PdfString("TEMPACCESS"));
Put(new PdfName("P"), dic);
Put(PdfName.D, fs.Reference);
}
示例13: addAsAttachment
private void addAsAttachment(IDataExporter exporter, byte[] data)
{
if (string.IsNullOrEmpty(exporter.FileName))
throw new InvalidOperationException("Please fill the exporter.FileName.");
if (string.IsNullOrEmpty(exporter.Description))
exporter.Description = "Exported data";
var pdfDictionary = new PdfDictionary();
pdfDictionary.Put(PdfName.MODDATE, new PdfDate(DateTime.Now));
var fs = PdfFileSpecification.FileEmbedded(_sharedData.PdfWriter, null, exporter.FileName, data, true, null, pdfDictionary);
_sharedData.PdfWriter.AddFileAttachment(exporter.Description, fs);
}
示例14: CMapAwareDocumentFont
/**
* Creates an instance of a CMapAwareFont based on an indirect reference to a font.
* @param refFont the indirect reference to a font
*/
public CMapAwareDocumentFont(PRIndirectReference refFont) : base(refFont){
fontDic = (PdfDictionary)PdfReader.GetPdfObjectRelease(refFont);
ProcessToUnicode();
//if (toUnicodeCmap == null)
ProcessUni2Byte();
spaceWidth = base.GetWidth(' ');
if (spaceWidth == 0){
spaceWidth = ComputeAverageWidth();
}
}
示例15: PdfStructureElement
internal PdfStructureElement(PdfDictionary parent, PdfName structureType) {
if (parent is PdfStructureElement) {
top = ((PdfStructureElement) parent).top;
Init(parent, structureType);
this.parent = (PdfStructureElement) parent;
Put(PdfName.P, ((PdfStructureElement) parent).reference);
Put(PdfName.TYPE, PdfName.STRUCTELEM);
} else if (parent is PdfStructureTreeRoot) {
top = (PdfStructureTreeRoot) parent;
Init(parent, structureType);
Put(PdfName.P, ((PdfStructureTreeRoot) parent).Reference);
Put(PdfName.TYPE, PdfName.STRUCTELEM);
} else {}
}