本文整理匯總了C#中iTextSharp.text.pdf.PdfLayer.AddChild方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfLayer.AddChild方法的具體用法?C# PdfLayer.AddChild怎麽用?C# PdfLayer.AddChild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfLayer
的用法示例。
在下文中一共展示了PdfLayer.AddChild方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AddOrder
/**
* Recursive method to reconstruct the documentOCGorder variable in the writer.
* @param parent a parent PdfLayer (can be null)
* @param arr an array possibly containing children for the parent PdfLayer
* @param ocgmap a Hashtable with indirect reference Strings as keys and PdfLayer objects as values.
* @since 2.1.2
*/
private void AddOrder(PdfLayer parent, PdfArray arr, Dictionary<string,PdfLayer> ocgmap) {
PdfObject obj;
PdfLayer layer;
for (int i = 0; i < arr.Size; i++) {
obj = arr[i];
if (obj.IsIndirect()) {
layer = ocgmap[obj.ToString()];
if (layer != null) {
layer.OnPanel = true;
RegisterLayer(layer);
if (parent != null) {
parent.AddChild(layer);
}
if (arr.Size > i + 1 && arr[i + 1].IsArray()) {
i++;
AddOrder(layer, (PdfArray)arr[i], ocgmap);
}
}
}
else if (obj.IsArray()) {
PdfArray sub = (PdfArray)obj;
if (sub.IsEmpty()) return;
obj = sub[0];
if (obj.IsString()) {
layer = new PdfLayer(obj.ToString());
layer.OnPanel = true;
RegisterLayer(layer);
if (parent != null) {
parent.AddChild(layer);
}
PdfArray array = new PdfArray();
for (ListIterator<PdfObject> j = sub.GetListIterator(); j.HasNext(); ) {
array.Add(j.Next());
}
AddOrder(layer, array, ocgmap);
}
else {
AddOrder(parent, (PdfArray)obj, ocgmap);
}
}
}
}
示例2: LayerCheckTest2
public void LayerCheckTest2()
{
string filename = OUT + "LayerCheckTest2.pdf";
FileStream fos = new FileStream(filename, FileMode.Create);
Document document = new Document();
PdfWriter writer = PdfAWriter.GetInstance(document, fos, PdfAConformanceLevel.PDF_A_2B);
writer.ViewerPreferences = PdfWriter.PageModeUseOC;
writer.PdfVersion = PdfWriter.VERSION_1_5;
document.Open();
PdfContentByte cb = writer.DirectContent;
PdfLayer nested = new PdfLayer("Nested layers", writer);
PdfLayer nested_1 = new PdfLayer("Nested layer 1", writer);
PdfLayer nested_2 = new PdfLayer("Nested layer 2", writer);
nested.AddChild(nested_1);
nested.AddChild(nested_2);
writer.LockLayer(nested_2);
cb.BeginLayer(nested);
Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, true);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("nested layers", font), 50, 775, 0);
cb.EndLayer();
cb.BeginLayer(nested_1);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("nested layer 1", font), 100, 800, 0);
cb.EndLayer();
cb.BeginLayer(nested_2);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("nested layer 2", font), 100, 750, 0);
cb.EndLayer();
document.Close();
}
示例3: LayerCheckTest2
public void LayerCheckTest2() {
string filename = OUT + "LayerCheckTest2.pdf";
FileStream fos = new FileStream(filename, FileMode.Create);
Document document = new Document();
PdfWriter writer = PdfAWriter.GetInstance(document, fos, PdfAConformanceLevel.PDF_A_2B);
writer.CreateXmpMetadata();
writer.ViewerPreferences = PdfWriter.PageModeUseOC;
writer.PdfVersion = PdfWriter.VERSION_1_5;
document.Open();
PdfContentByte cb = writer.DirectContent;
PdfLayer nested = new PdfLayer("Nested layers", writer);
PdfLayer nested_1 = new PdfLayer("Nested layer 1", writer);
PdfLayer nested_2 = new PdfLayer("Nested layer 2", writer);
nested.AddChild(nested_1);
nested.AddChild(nested_2);
writer.LockLayer(nested_2);
cb.BeginLayer(nested);
Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, true);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("nested layers", font), 50, 775, 0);
cb.EndLayer();
cb.BeginLayer(nested_1);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("nested layer 1", font), 100, 800, 0);
cb.EndLayer();
cb.BeginLayer(nested_2);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("nested layer 2", font), 100, 750, 0);
cb.EndLayer();
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);
document.Close();
}
示例4: Write
// ===========================================================================
public void Write(Stream stream) {
// step 1
using (Document document = new Document()) {
// step 2
PdfWriter writer = PdfWriter.GetInstance(document, stream);
writer.PdfVersion = PdfWriter.VERSION_1_5;
// step 3
document.Open();
// step 4
PdfContentByte cb = writer.DirectContent;
PdfLayer nested = new PdfLayer("Nested layers", writer);
PdfLayer nested_1 = new PdfLayer("Nested layer 1", writer);
PdfLayer nested_2 = new PdfLayer("Nested layer 2", writer);
nested.AddChild(nested_1);
nested.AddChild(nested_2);
writer.LockLayer(nested_2);
cb.BeginLayer(nested);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT,
new Phrase("nested layers"), 50, 775, 0
);
cb.EndLayer();
cb.BeginLayer(nested_1);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT,
new Phrase("nested layer 1"), 100, 800, 0
);
cb.EndLayer();
cb.BeginLayer(nested_2);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT,
new Phrase("nested layer 2"), 100, 750, 0
);
cb.EndLayer();
PdfLayer group = PdfLayer.CreateTitle("Grouped layers", writer);
PdfLayer layer1 = new PdfLayer("Group: layer 1", writer);
PdfLayer layer2 = new PdfLayer("Group: layer 2", writer);
group.AddChild(layer1);
group.AddChild(layer2);
cb.BeginLayer(layer1);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT,
new Phrase( "layer 1 in the group"), 50, 700, 0
);
cb.EndLayer();
cb.BeginLayer(layer2);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT,
new Phrase("layer 2 in the group"), 50, 675, 0
);
cb.EndLayer();
PdfLayer radiogroup = PdfLayer.CreateTitle("Radio group", writer);
PdfLayer radio1 = new PdfLayer("Radiogroup: layer 1", writer);
radio1.On = true;
PdfLayer radio2 = new PdfLayer("Radiogroup: layer 2", writer);
radio2.On = false;
PdfLayer radio3 = new PdfLayer("Radiogroup: layer 3", writer);
radio3.On = false;
radiogroup.AddChild(radio1);
radiogroup.AddChild(radio2);
radiogroup.AddChild(radio3);
List<PdfLayer> options = new List<PdfLayer>();
options.Add(radio1);
options.Add(radio2);
options.Add(radio3);
writer.AddOCGRadioGroup(options);
cb.BeginLayer(radio1);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT,
new Phrase("option 1"), 50, 600, 0
);
cb.EndLayer();
cb.BeginLayer(radio2);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT,
new Phrase("option 2"), 50, 575, 0
);
cb.EndLayer();
cb.BeginLayer(radio3);
ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT,
new Phrase(
"option 3"
), 50, 550, 0
);
cb.EndLayer();
PdfLayer not_printed = new PdfLayer("not printed", writer);
not_printed.OnPanel = false;
not_printed.SetPrint("Print", false);
cb.BeginLayer(not_printed);
ColumnText.ShowTextAligned(cb, Element.ALIGN_CENTER,
new Phrase(
"PRINT THIS PAGE"
), 300, 700, 90
);
cb.EndLayer();
PdfLayer zoom = new PdfLayer("Zoom 0.75-1.25", writer);
zoom.OnPanel = false;
zoom.SetZoom(0.75f, 1.25f);
cb.BeginLayer(zoom);
ColumnText.ShowTextAligned(
cb, Element.ALIGN_LEFT,
new Phrase(
//.........這裏部分代碼省略.........