本文整理汇总了C#中iTextSharp.text.pdf.PdfRectangle类的典型用法代码示例。如果您正苦于以下问题:C# PdfRectangle类的具体用法?C# PdfRectangle怎么用?C# PdfRectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfRectangle类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfRectangle类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ManipulatePdf
// ---------------------------------------------------------------------------
/**
* Manipulates a PDF file src with the file dest as result
* @param src the original PDF
*/
public byte[] ManipulatePdf(byte[] src) {
PdfReader reader = new PdfReader(src);
int n = reader.NumberOfPages;
PdfDictionary pageDict;
PdfRectangle rect = new PdfRectangle(55, 76, 560, 816);
for (int i = 1; i <= n; i++) {
pageDict = reader.GetPageN(i);
pageDict.Put(PdfName.CROPBOX, rect);
}
using (MemoryStream ms = new MemoryStream()) {
using (PdfStamper stamper = new PdfStamper(reader, ms)) {
}
return ms.ToArray();
}
}
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:20,代码来源:CropPages.cs
示例2: AddPage
/**
* Adds a blank page.
* @param rect The page dimension
* @param rotation The rotation angle in degrees
* @since 2.1.5
* @throws DocumentException
*/
public void AddPage(Rectangle rect, int rotation) {
if (mergeFields && !mergeFieldsInternalCall) {
throw new ArgumentException(MessageLocalization.GetComposedMessage("1.method.cannot.be.used.in.mergeFields.mode.please.use.addDocument", "addPage"));
}
PdfRectangle mediabox = new PdfRectangle(rect, rotation);
PageResources resources = new PageResources();
PdfPage page = new PdfPage(mediabox, new Dictionary<String, PdfRectangle>(), resources.Resources, 0);
page.Put(PdfName.TABS, Tabs);
root.AddPage(page);
++currentPageNumber;
}
开发者ID:,项目名称:,代码行数:18,代码来源:
示例3: WriteAttributes
private void WriteAttributes(Image image)
{
if (image != null)
{
if (image.Width > 0)
this.SetAttribute(PdfName.WIDTH, new PdfNumber(image.Width));
if (image.Height > 0)
this.SetAttribute(PdfName.HEIGHT, new PdfNumber(image.Height));
image.Rotation = 10;
image.Rotation = 10f;
PdfRectangle rect = new PdfRectangle(image, ((Rectangle) image).Rotation);
this.SetAttribute(PdfName.BBOX, rect);
if (image.Alt != null)
Put(PdfName.ALT, new PdfString(image.Alt));
if (image.BackgroundColor != null)
{
BaseColor color = image.BackgroundColor;
this.SetAttribute(PdfName.BACKGROUNDCOLOR, new PdfArray(new float[] { color.R / 255f, color.G / 255f, color.B / 255f }));
}
}
}
开发者ID:,项目名称:,代码行数:21,代码来源:
示例4: RotateAnnotations
virtual public PdfArray RotateAnnotations(PdfWriter writer, Rectangle pageSize) {
PdfArray array = new PdfArray();
int rotation = pageSize.Rotation % 360;
int currentPage = writer.CurrentPageNumber;
for (int k = 0; k < annotations.Count; ++k) {
PdfAnnotation dic = annotations[k];
int page = dic.PlaceInPage;
if (page > currentPage) {
delayedAnnotations.Add(dic);
continue;
}
if (dic.IsForm()) {
if (!dic.IsUsed()) {
Dictionary<PdfTemplate,object> templates = dic.Templates;
if (templates != null)
acroForm.AddFieldTemplates(templates);
}
PdfFormField field = (PdfFormField)dic;
if (field.Parent == null)
acroForm.AddDocumentField(field.IndirectReference);
}
if (dic.IsAnnotation()) {
array.Add(dic.IndirectReference);
if (!dic.IsUsed()) {
PdfArray tmp = dic.GetAsArray(PdfName.RECT);
PdfRectangle rect;
if (tmp.Size == 4)
{
rect = new PdfRectangle(tmp.GetAsNumber(0).FloatValue, tmp.GetAsNumber(1).FloatValue, tmp.GetAsNumber(2).FloatValue, tmp.GetAsNumber(3).FloatValue);
} else {
rect = new PdfRectangle(tmp.GetAsNumber(0).FloatValue, tmp.GetAsNumber(1).FloatValue);
}
if (rect != null) {
switch (rotation) {
case 90:
dic.Put(PdfName.RECT, new PdfRectangle(
pageSize.Top - rect.Bottom,
rect.Left,
pageSize.Top - rect.Top,
rect.Right));
break;
case 180:
dic.Put(PdfName.RECT, new PdfRectangle(
pageSize.Right - rect.Left,
pageSize.Top - rect.Bottom,
pageSize.Right - rect.Right,
pageSize.Top - rect.Top));
break;
case 270:
dic.Put(PdfName.RECT, new PdfRectangle(
rect.Bottom,
pageSize.Right - rect.Left,
rect.Top,
pageSize.Right - rect.Right));
break;
}
}
}
}
if (!dic.IsUsed()) {
dic.SetUsed();
writer.AddToBody(dic, dic.IndirectReference);
}
}
return array;
}
开发者ID:,项目名称:,代码行数:66,代码来源:
示例5: PdfPage
// constructors
/**
* Constructs a <CODE>PdfPage</CODE>.
*
* @param mediaBox a value for the <B>MediaBox</B> key
* @param resources an indirect reference to a <CODE>PdfResources</CODE>-object
* @param rotate a value for the <B>Rotate</B> key
* @throws DocumentException
*/
internal PdfPage(PdfRectangle mediaBox, Dictionary<string, PdfRectangle> boxSize, PdfDictionary resources, int rotate) : base(PAGE) {
this.mediaBox = mediaBox;
if (mediaBox != null && (mediaBox.Width > 14400 || mediaBox.Height > 14400)) {
throw new DocumentException(MessageLocalization.GetComposedMessage("the.page.size.must.be.smaller.than.14400.by.14400.its.1.by.2", mediaBox.Width, mediaBox.Height));
}
Put(PdfName.MEDIABOX, mediaBox);
Put(PdfName.RESOURCES, resources);
if (rotate != 0) {
Put(PdfName.ROTATE, new PdfNumber(rotate));
}
for (int k = 0; k < boxStrings.Length; ++k) {
if (!boxSize.ContainsKey(boxStrings[k]))
continue;
Put(boxNames[k], boxSize[boxStrings[k]]);
}
}
开发者ID:,项目名称:,代码行数:27,代码来源:
示例6: NewPage
/**
* Makes a new page and sends it to the <CODE>PdfWriter</CODE>.
*
* @return a <CODE>bool</CODE>
* @throws DocumentException on error
*/
public override bool NewPage()
{
lastElementType = -1;
isNewpage = true;
if (writer == null || (writer.DirectContent.Size == 0 && writer.DirectContentUnder.Size == 0 && (pageEmpty || writer.IsPaused()))) {
return false;
}
if (!open || close) {
throw new Exception("The document isn't open.");
}
IPdfPageEvent pageEvent = writer.PageEvent;
if (pageEvent != null)
pageEvent.OnEndPage(writer, this);
//Added to inform any listeners that we are moving to a new page (added by David Freels)
base.NewPage();
// the following 2 lines were added by Pelikan Stephan
imageIndentLeft = 0;
imageIndentRight = 0;
// we flush the arraylist with recently written lines
FlushLines();
// we prepare the elements of the page dictionary
// [U1] page size and rotation
int rotation = pageSize.Rotation;
// [C10]
if (writer.IsPdfX()) {
if (thisBoxSize.ContainsKey("art") && thisBoxSize.ContainsKey("trim"))
throw new PdfXConformanceException("Only one of ArtBox or TrimBox can exist in the page.");
if (!thisBoxSize.ContainsKey("art") && !thisBoxSize.ContainsKey("trim")) {
if (thisBoxSize.ContainsKey("crop"))
thisBoxSize["trim"] = thisBoxSize["crop"];
else
thisBoxSize["trim"] = new PdfRectangle(pageSize, pageSize.Rotation);
}
}
// [M1]
pageResources.AddDefaultColorDiff(writer.DefaultColorspace);
PdfDictionary resources = pageResources.Resources;
// we create the page dictionary
PdfPage page = new PdfPage(new PdfRectangle(pageSize, rotation), thisBoxSize, resources, rotation);
// we complete the page dictionary
// [U3] page actions: transition, duration, additional actions
if (this.transition!=null) {
page.Put(PdfName.TRANS, this.transition.TransitionDictionary);
transition = null;
}
if (this.duration>0) {
page.Put(PdfName.DUR,new PdfNumber(this.duration));
duration = 0;
}
if (pageAA != null) {
page.Put(PdfName.AA, writer.AddToBody(pageAA).IndirectReference);
pageAA = null;
}
// [U4] we add the thumbs
if (thumb != null) {
page.Put(PdfName.THUMB, thumb);
thumb = null;
}
// [U8] we check if the userunit is defined
if (writer.Userunit > 0f) {
page.Put(PdfName.USERUNIT, new PdfNumber(writer.Userunit));
}
// [C5] and [C8] we add the annotations
if (annotationsImp.HasUnusedAnnotations()) {
PdfArray array = annotationsImp.RotateAnnotations(writer, pageSize);
if (array.Size != 0)
page.Put(PdfName.ANNOTS, array);
}
// [F12] we add tag info
if (writer.IsTagged())
page.Put(PdfName.STRUCTPARENTS, new PdfNumber(writer.CurrentPageNumber - 1));
if (text.Size > textEmptySize)
text.EndText();
else
text = null;
writer.Add(page, new PdfContents(writer.DirectContentUnder, graphics, text, writer.DirectContent, pageSize));
// we initialize the new page
InitPage();
isNewpage = false;
//.........这里部分代码省略.........
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:101,代码来源:PdfDocument.cs
示例7: SetBoxSize
internal void SetBoxSize(String boxName, Rectangle size) {
if (size == null)
boxSize.Remove(boxName);
else
boxSize[boxName] = new PdfRectangle(size);
}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:6,代码来源:PdfDocument.cs
示例8: PdfPage
// constructors
/**
* Constructs a <CODE>PdfPage</CODE>.
*
* @param mediaBox a value for the <B>MediaBox</B> key
* @param resources an indirect reference to a <CODE>PdfResources</CODE>-object
* @param rotate a value for the <B>Rotate</B> key
*/
internal PdfPage(PdfRectangle mediaBox, Dictionary<string, PdfRectangle> boxSize, PdfDictionary resources, int rotate)
: base(PAGE)
{
this.mediaBox = mediaBox;
Put(PdfName.MEDIABOX, mediaBox);
Put(PdfName.RESOURCES, resources);
if (rotate != 0) {
Put(PdfName.ROTATE, new PdfNumber(rotate));
}
for (int k = 0; k < boxStrings.Length; ++k) {
if (!boxSize.ContainsKey(boxStrings[k]))
continue;
Put(boxNames[k], boxSize[boxStrings[k]]);
}
}
开发者ID:boecko,项目名称:iTextSharp,代码行数:23,代码来源:PdfPage.cs
示例9: ApplyCTM
public void ApplyCTM(System.Drawing.Drawing2D.Matrix ctm) {
PdfArray origRect = GetAsArray(PdfName.RECT);
if(origRect != null) {
PdfRectangle rect;
if(origRect.Size == 4) {
rect = new PdfRectangle(origRect.GetAsNumber(0).FloatValue, origRect.GetAsNumber(1).FloatValue, origRect.GetAsNumber(2).FloatValue, origRect.GetAsNumber(3).FloatValue);
}
else {
rect = new PdfRectangle(origRect.GetAsNumber(0).FloatValue, origRect.GetAsNumber(1).FloatValue);
}
Put(PdfName.RECT, rect.Transform(ctm));
}
}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:13,代码来源:PdfAnnotation.cs
示例10: NewPage
/**
* Makes a new page and sends it to the <CODE>PdfWriter</CODE>.
*
* @return a <CODE>bool</CODE>
* @throws DocumentException on error
*/
public override bool NewPage() {
lastElementType = -1;
if (PageEmpty) {
SetNewPageSizeAndMargins();
return false;
}
if (!open || close) {
throw new Exception(MessageLocalization.GetComposedMessage("the.document.is.not.open"));
}
IPdfPageEvent pageEvent = writer.PageEvent;
if (pageEvent != null)
pageEvent.OnEndPage(writer, this);
//Added to inform any listeners that we are moving to a new page (added by David Freels)
base.NewPage();
// the following 2 lines were added by Pelikan Stephan
indentation.imageIndentLeft = 0;
indentation.imageIndentRight = 0;
// we flush the arraylist with recently written lines
FlushLines();
// we prepare the elements of the page dictionary
// [U1] page size and rotation
int rotation = pageSize.Rotation;
// [C10]
if (writer.IsPdfX()) {
if (thisBoxSize.ContainsKey("art") && thisBoxSize.ContainsKey("trim"))
throw new PdfXConformanceException(MessageLocalization.GetComposedMessage("only.one.of.artbox.or.trimbox.can.exist.in.the.page"));
if (!thisBoxSize.ContainsKey("art") && !thisBoxSize.ContainsKey("trim")) {
if (thisBoxSize.ContainsKey("crop"))
thisBoxSize["trim"] = thisBoxSize["crop"];
else
thisBoxSize["trim"] = new PdfRectangle(pageSize, pageSize.Rotation);
}
}
// [M1]
pageResources.AddDefaultColorDiff(writer.DefaultColorspace);
if (writer.RgbTransparencyBlending) {
PdfDictionary dcs = new PdfDictionary();
dcs.Put(PdfName.CS, PdfName.DEVICERGB);
pageResources.AddDefaultColorDiff(dcs);
}
PdfDictionary resources = pageResources.Resources;
// we create the page dictionary
PdfPage page = new PdfPage(new PdfRectangle(pageSize, rotation), thisBoxSize, resources, rotation);
page.Put(PdfName.TABS, writer.Tabs);
// we complete the page dictionary
// [C9] if there is XMP data to add: add it
if (xmpMetadata != null) {
PdfStream xmp = new PdfStream(xmpMetadata);
xmp.Put(PdfName.TYPE, PdfName.METADATA);
xmp.Put(PdfName.SUBTYPE, PdfName.XML);
PdfEncryption crypto = writer.Encryption;
if (crypto != null && !crypto.IsMetadataEncrypted()) {
PdfArray ar = new PdfArray();
ar.Add(PdfName.CRYPT);
xmp.Put(PdfName.FILTER, ar);
}
page.Put(PdfName.METADATA, writer.AddToBody(xmp).IndirectReference);
}
// [U3] page actions: transition, duration, additional actions
if (this.transition!=null) {
page.Put(PdfName.TRANS, this.transition.TransitionDictionary);
transition = null;
}
if (this.duration>0) {
page.Put(PdfName.DUR,new PdfNumber(this.duration));
duration = 0;
}
if (pageAA != null) {
page.Put(PdfName.AA, writer.AddToBody(pageAA).IndirectReference);
pageAA = null;
}
// [U4] we add the thumbs
if (thumb != null) {
page.Put(PdfName.THUMB, thumb);
thumb = null;
}
// [U8] we check if the userunit is defined
if (writer.Userunit > 0f) {
page.Put(PdfName.USERUNIT, new PdfNumber(writer.Userunit));
}
//.........这里部分代码省略.........
开发者ID:pusp,项目名称:o2platform,代码行数:101,代码来源:PdfDocument.cs
示例11: ApplyCTM
virtual public void ApplyCTM(AffineTransform ctm) {
PdfArray origRect = GetAsArray(PdfName.RECT);
if(origRect != null) {
PdfRectangle rect;
if(origRect.Size == 4) {
rect = new PdfRectangle(origRect.GetAsNumber(0).FloatValue, origRect.GetAsNumber(1).FloatValue,
origRect.GetAsNumber(2).FloatValue, origRect.GetAsNumber(3).FloatValue);
}
else {
rect = new PdfRectangle(origRect.GetAsNumber(0).FloatValue, origRect.GetAsNumber(1).FloatValue);
}
Put(PdfName.RECT, rect.Transform(ctm));
}
}
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:14,代码来源:PdfAnnotation.cs
示例12: EndPage
public IList<IAccessibleElement> EndPage() {
if (PageEmpty) {
return null;
}
IList<IAccessibleElement> savedMcBlocks = null;
FlushFloatingElements();
lastElementType = -1;
IPdfPageEvent pageEvent = writer.PageEvent;
if (pageEvent != null)
pageEvent.OnEndPage(writer, this);
// we flush the arraylist with recently written lines
FlushLines();
// we prepare the elements of the page dictionary
// [U1] page size and rotation
int rotation = pageSize.Rotation;
// [C10]
if (writer.IsPdfIso()) {
if (thisBoxSize.ContainsKey("art") && thisBoxSize.ContainsKey("trim"))
throw new PdfXConformanceException(MessageLocalization.GetComposedMessage("only.one.of.artbox.or.trimbox.can.exist.in.the.page"));
if (!thisBoxSize.ContainsKey("art") && !thisBoxSize.ContainsKey("trim")) {
if (thisBoxSize.ContainsKey("crop"))
thisBoxSize["trim"] = thisBoxSize["crop"];
else
thisBoxSize["trim"] = new PdfRectangle(pageSize, pageSize.Rotation);
}
}
// [M1]
pageResources.AddDefaultColorDiff(writer.DefaultColorspace);
if (writer.RgbTransparencyBlending) {
PdfDictionary dcs = new PdfDictionary();
dcs.Put(PdfName.CS, PdfName.DEVICERGB);
pageResources.AddDefaultColorDiff(dcs);
}
PdfDictionary resources = pageResources.Resources;
// we create the page dictionary
PdfPage page = new PdfPage(new PdfRectangle(pageSize, rotation), thisBoxSize, resources, rotation);
if (IsTagged(writer)) {
page.Put(PdfName.TABS, PdfName.S);
} else {
page.Put(PdfName.TABS, writer.Tabs);
}
page.Merge(writer.PageDictEntries);
writer.ResetPageDictEntries();
// we complete the page dictionary
// [U3] page actions: additional actions
if (pageAA != null) {
page.Put(PdfName.AA, writer.AddToBody(pageAA).IndirectReference);
pageAA = null;
}
// [C5] and [C8] we add the annotations
if (annotationsImp.HasUnusedAnnotations()) {
PdfArray array = annotationsImp.RotateAnnotations(writer, pageSize);
if (array.Size != 0)
page.Put(PdfName.ANNOTS, array);
}
// [F12] we add tag info
if (IsTagged(writer))
page.Put(PdfName.STRUCTPARENTS, new PdfNumber(GetStructParentIndex(writer.CurrentPage)));
if (text.Size > textEmptySize || IsTagged(writer))
text.EndText();
else
text = null;
if (IsTagged(writer)) {
savedMcBlocks = writer.DirectContent.SaveMCBlocks();
}
writer.Add(page, new PdfContents(writer.DirectContentUnder, graphics, !IsTagged(writer) ? text : null, writer.DirectContent, pageSize));
annotationsImp.ResetAnnotations();
writer.ResetContent();
return savedMcBlocks;
}
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:86,代码来源:PdfDocument.cs
示例13: ReadPdfFile
public List<LocationModel> ReadPdfFile(String fileName)
{
string strText = string.Empty;
PdfReader reader = new PdfReader(fileName);
var locationList = new List<LocationModel>();
for (int page = 1; page <= reader.NumberOfPages; page++)
{
var p = reader.GetPageN(page);
var pageSize = reader.GetPageSizeWithRotation(page);
var rotation = pageSize.Rotation;
float factor;
if (pageSize.Height > pageSize.Width)
{
//Portait
factor = 2000 / pageSize.Width;
}
else{
//landscape
factor = 1700 / pageSize.Height;
}
var annotationList = p.GetAsArray(iTextSharp.text.pdf.PdfName.ANNOTS);
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
string currentText = PdfTextExtractor.GetTextFromPage(reader, page, strategy);
currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText)));
foreach (PdfObject annot in annotationList.ArrayList)
{
PdfDictionary annotationDict = (PdfDictionary)PdfReader.GetPdfObject(annot);
var subtype = annotationDict.Get(PdfName.SUBTYPE);
if (subtype == PdfName.FREETEXT)
{
var content = annotationDict.GetAsString(PdfName.CONTENTS);
var tmp = annotationDict.GetAsArray(PdfName.RECT);
var rect = new PdfRectangle(tmp.GetAsNumber(0).FloatValue, tmp.GetAsNumber(1).FloatValue, tmp.GetAsNumber(2).FloatValue, tmp.GetAsNumber(3).FloatValue);
var left = Convert.ToDouble(rect.Right);
var top = Convert.ToDouble(pageSize.Height - rect.Top); // Convert Bottom to Top Coordinate System
//Comment this line if the coordinate is weird
/*
if (rotation == 90)
{
left = pageSize.Height > pageSize.Width ? Convert.ToDouble(rect[3].ToString()) : pageSize.Height - float.Parse(rect[2].ToString());
top = pageSize.Height > pageSize.Width ? float.Parse(rect[2].ToString()) : float.Parse(rect[3].ToString());
}
*/
//Comment this line if the coordinate is weird
//left = Convert.ToDouble(rect[3].ToString());
//top = Convert.ToDouble(rect[0].ToString());
var offsetX = 30;
var offsetY = 20;
var location = new LocationModel {
X = Convert.ToInt32(Double.Parse(left.ToString()) * factor) + offsetX,
Y = Convert.ToInt32(Double.Parse(top.ToString()) * factor) + offsetY,
Title = content.ToString() };
locationList.Add(location);
}
}
}
reader.Close();
return locationList;
}
开发者ID:KuroroSam,项目名称:PDFExtractor,代码行数:74,代码来源:ReadPDF.cs
示例14: PdfPage
/**
* Constructs a <CODE>PdfPage</CODE>.
*
* @param mediaBox a value for the <B>MediaBox</B> key
* @param resources an indirect reference to a <CODE>PdfResources</CODE>-object
*/
internal PdfPage(PdfRectangle mediaBox, Hashtable boxSize, PdfDictionary resources) : this(mediaBox, boxSize, resources, 0) {
}
开发者ID:pusp,项目名称:o2platform,代码行数:9,代码来源:PdfPage.cs
示例15: RotateMediaBox
/**
* Rotates the mediabox, but not the text in it.
*
* @return a <CODE>PdfRectangle</CODE>
*/
internal PdfRectangle RotateMediaBox()
{
this.mediaBox = mediaBox.Rotate;
Put(PdfName.MEDIABOX, this.mediaBox);
return this.mediaBox;
}
开发者ID:boecko,项目名称:iTextSharp,代码行数:11,代码来源:PdfPage.cs
示例16: AddPage
/**
* Adds a blank page.
* @param rect The page dimension
* @param rotation The rotation angle in degrees
* @since 2.1.5
*/
public void AddPage(Rectangle rect, int rotation)
{
PdfRectangle mediabox = new PdfRectangle(rect, rotation);
PageResources resources = new PageResources();
PdfPage page = new PdfPage(mediabox, new Dictionary<String, PdfRectangle>(), resources.Resources, 0);
page.Put(PdfName.TABS, Tabs);
root.AddPage(page);
++currentPageNumber;
}
开发者ID:boecko,项目名称:iTextSharp,代码行数:15,代码来源:PdfCopy.cs
示例17: NewPage
/**
* Makes a new page and sends it to the <CODE>PdfWriter</CODE>.
*
* @return a <CODE>bool</CODE>
* @throws DocumentException on error
*/
public override bool NewPage() {
FlushFloatingElements();
lastElementType = -1;
if (PageEmpty) {
SetNewPageSizeAndMargins();
return false;
}
if (!open || close) {
throw new Exception(MessageLocalization.GetComposedMessage("the.document.is.not.open"));
}
IPdfPageEvent pageEvent = writer.PageEvent;
if (pageEvent != null)
pageEvent.OnEndPage(writer, this);
//Added to inform any listeners that we are moving to a new page (added by David Freels)
base.NewPage();
// the following 2 lines were added by Pelikan Stephan
indentation.imageIndentLeft = 0;
indentation.imageIndentRight = 0;
// we flush the arraylist with recently written lines
FlushLines();
// we prepare the elements of the page dictionary
// [U1] page size and rotation
int rotation = pageSize.Rotation;
// [C10]
if (writer.IsPdfIso()) {
if (thisBoxSize.ContainsKey("art") && thisBoxSize.ContainsKey("trim"))
throw new PdfXConformanceException(MessageLocalization.GetComposedMessage("only.one.of.artbox.or.trimbox.can.exist.in.the.page"));
if (!thisBoxSize.ContainsKey("art") && !thisBoxSize.ContainsKey("trim")) {
if (thisBoxSize.ContainsKey("crop"))
thisBoxSize["trim"] = thisBoxSize["crop"];
else
thisBoxSize["trim"] = new PdfRectangle(pageSize, pageSize.Rotation);
}
}
// [M1]
pageResources.AddDefaultColorDiff(writer.DefaultColorspace);
if (writer.RgbTransparencyBlending) {
PdfDictionary dcs = new PdfDictionary();
dcs.Put(PdfName.CS, PdfName.DEVICERGB);
pageResources.AddDefaultColorDiff(dcs);
}
PdfDictionary resources = pageResources.Resources;
// we create the page dictionary
PdfPage page = new PdfPage(new PdfRectangle(pageSize, rotation), thisBoxSize, resources, rotation);
if (IsTagged(writer)) {
page.Put(PdfName.TABS, PdfName.S);
} else {
page.Put(PdfName.TABS, writer.Tabs);
}
page.Merge(writer.PageDictEntries);
writer.ResetPageDictEntries();
// we complete the page dictionary
// [U3] page actions: additional actions
if (pageAA != null) {
page.Put(PdfName.AA, writer.AddToBody(pageAA).IndirectReference);
pageAA = null;
}
// [C5] and [C8] we add the annotations
if (annotationsImp.HasUnusedAnnotations()) {
PdfArray array = annotationsImp.RotateAnnotations(writer, pageSize);
if (array.Size != 0)
page.Put(PdfName.ANNOTS, array);
}
// [F12] we add tag info
if (IsTagged(writer))
page.Put(PdfName.STRUCTPARENTS, new PdfNumber(GetStructParentIndex(writer.CurrentPage)));
if (text.Size > textEmptySize || IsTagged(writer))
text.EndText();
else
text = null;
IList<IAccessibleElement> mcBlocks = null;
if (IsTagged(writer)) {
mcBlocks = writer.DirectContent.SaveMCBlocks();
}
writer.Add(page, new PdfContents(writer.DirectContentUnder, graphics, !IsTagged(writer) ? text : null, writer.DirectContent, pageSize));
// we initialize the new page
InitPage();
if (IsTagged(writer)) {
writer.DirectContentUnder.RestoreMCBlocks(mcBlocks);
}
//.........这里部分代码省略.........
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:101,代码来源:PdfDocument.cs
注:本文中的iTextSharp.text.pdf.PdfRectangle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论