本文整理汇总了C#中iTextSharp.text.pdf.PdfDocument类的典型用法代码示例。如果您正苦于以下问题:C# PdfDocument类的具体用法?C# PdfDocument怎么用?C# PdfDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfDocument类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfDocument类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInstance
/**
* Use this method to get an instance of the <CODE>PdfWriter</CODE>.
* @param document The <CODE>Document</CODE> that has to be written
* @param os The <CODE>Stream</CODE> the writer has to write to.
* @param conformanceLevel PDF/A conformance level of a new PDF document
* @return a new <CODE>PdfWriter</CODE>
* @throws DocumentException on error
*/
public static PdfAWriter GetInstance(Document document, Stream os, PdfAConformanceLevel conformanceLevel) {
PdfDocument pdf = new PdfDocument();
document.AddDocListener(pdf);
PdfAWriter writer = new PdfAWriter(pdf, os, conformanceLevel);
pdf.AddWriter(writer);
return writer;
}
示例2: WriteToPdf
public override void WriteToPdf(PdfDocument doc)
{
doc.GetWriter.SetCMYKColorStroke(0, 0, 0, 255);
doc.GetWriter.SetCMYKColorFill(0, 0, 0, 255);
doc.GetWriter.BeginText();
doc.GetWriter.SetTextMatrix(PosX+2, PosY+2);
while ((customfont.GetWidthPointKerned(Text, FontSize) > Width) || (FontSize == 2)) FontSize--;
doc.GetWriter.SetFontAndSize(customfont, FontSize);
doc.GetWriter.ShowText(Text);
doc.GetWriter.EndText();
doc.Flush();
}
示例3: PdfWriter
/**
* Constructs a <CODE>PdfWriter</CODE>.
* <P>
* Remark: a PdfWriter can only be constructed by calling the method
* <CODE>getInstance(Document document, Stream os)</CODE>.
*
* @param document The <CODE>PdfDocument</CODE> that has to be written
* @param os The <CODE>Stream</CODE> the writer has to write to.
*/
protected PdfWriter(PdfDocument document, Stream os) : base(document, os) {
pdfIsoConformance = GetPdfIsoConformance();
root = new PdfPages(this);
pdf = document;
directContentUnder = new PdfContentByte(this);
directContent = directContentUnder.Duplicate;
}
示例4: PdfContentByte
// constructors
/**
* Constructs a new <CODE>PdfContentByte</CODE>-object.
*
* @param wr the writer associated to this content
*/
public PdfContentByte(PdfWriter wr)
{
if (wr != null) {
writer = wr;
pdf = writer.PdfDocument;
autoControlTextBlocks = !pdf.UseSeparateCanvasesForTextAndGraphics;
}
}
示例5: PdfContentByte
// constructors
/**
* Constructs a new <CODE>PdfContentByte</CODE>-object.
*
* @param wr the writer associated to this content
*/
public PdfContentByte(PdfWriter wr) {
if (wr != null) {
writer = wr;
pdf = writer.PdfDocument;
}
}
示例6: PdfAWriter
/**
* Constructs a <CODE>PdfAWriter</CODE>.
* <P>
* Remark: a PdfAWriter can only be constructed by calling the method <CODE>getInstance(Document document, Stream os, PdfAconformanceLevel conformanceLevel)</CODE>.
* @param document the <CODE>PdfDocument</CODE> that has to be written
* @param os the <CODE>Stream</CODE> the writer has to write to
* @param conformanceLevel PDF/A conformance level of a new PDF document
*/
protected internal PdfAWriter(PdfDocument document, Stream os, PdfAConformanceLevel conformanceLevel)
: base(document, os) {
((IPdfAConformance) pdfIsoConformance).SetConformanceLevel(conformanceLevel);
SetPdfVersion(this, conformanceLevel);
}
示例7: Write
/**
* Write out the columns. After writing, use
* {@link #isOverflow()} to see if all text was written.
* @param canvas PdfContentByte to write with
* @param document document to write to (only used to get page limit info)
* @param documentY starting y position to begin writing at
* @return the current height (y position) after writing the columns
* @throws DocumentException on error
*/
public float Write(PdfContentByte canvas, PdfDocument document, float documentY)
{
this.document = document;
columnText.Canvas = canvas;
if (columnDefs.Count == 0) {
throw new DocumentException(MessageLocalization.GetComposedMessage("multicolumntext.has.no.columns"));
}
overflow = false;
float currentHeight = 0;
bool done = false;
while (!done) {
if (top == AUTOMATIC) {
top = document.GetVerticalPosition(true);
}
else if (nextY == AUTOMATIC) {
nextY = document.GetVerticalPosition(true); // RS - 07/07/2005 - - Get current doc writing position for top of columns on new page.
}
ColumnDef currentDef = columnDefs[CurrentColumn];
columnText.YLine = top;
float[] left = currentDef.ResolvePositions(Rectangle.LEFT_BORDER);
float[] right = currentDef.ResolvePositions(Rectangle.RIGHT_BORDER);
if (document.IsMarginMirroring() && document.PageNumber % 2 == 0){
float delta = document.RightMargin - document.Left;
left = (float[])left.Clone();
right = (float[])right.Clone();
for (int i = 0; i < left.Length; i += 2) {
left[i] -= delta;
}
for (int i = 0; i < right.Length; i += 2) {
right[i] -= delta;
}
}
currentHeight = Math.Max(currentHeight, GetHeight(left, right));
if (currentDef.IsSimple()) {
columnText.SetSimpleColumn(left[2], left[3], right[0], right[1]);
} else {
columnText.SetColumns(left, right);
}
int result = columnText.Go();
if ((result & ColumnText.NO_MORE_TEXT) != 0) {
done = true;
top = columnText.YLine;
} else if (ShiftCurrentColumn()) {
top = nextY;
} else { // check if we are done because of height
totalHeight += currentHeight;
if ((desiredHeight != AUTOMATIC) && (totalHeight >= desiredHeight)) {
overflow = true;
break;
} else { // need to start new page and reset the columns
documentY = nextY;
NewPage();
currentHeight = 0;
}
}
}
if (desiredHeight == AUTOMATIC && columnDefs.Count == 1) {
currentHeight = documentY - columnText.YLine;
}
return currentHeight;
}
示例8: PdfWriter
/**
* Constructs a <CODE>PdfWriter</CODE>.
* <P>
* Remark: a PdfWriter can only be constructed by calling the method
* <CODE>getInstance(Document document, Stream os)</CODE>.
*
* @param document The <CODE>PdfDocument</CODE> that has to be written
* @param os The <CODE>Stream</CODE> the writer has to write to.
*/
protected PdfWriter(PdfDocument document, Stream os)
: base(document, os)
{
root = new PdfPages(this);
pdf = document;
directContent = new PdfContentByte(this);
directContentUnder = new PdfContentByte(this);
}
示例9: GetXmpWriter
protected internal virtual XmpWriter GetXmpWriter(MemoryStream baos, PdfDocument.PdfInfo info)
{
if (xmpWriter == null)
xmpWriter = new XmpWriter(baos, info);
return xmpWriter;
}
示例10: PDFFromTemplateHelper
private PDFFromTemplateHelper( PdfDocument pdfDocument )
{
_pdfDocument = pdfDocument;
}
示例11: GetXmpWriter
/**
* @see PdfWriter#getXmpWriter(java.io.MemoryStream, com.itextpdf.text.pdf.PdfDocument.PdfInfo)
*/
override protected XmpWriter GetXmpWriter(MemoryStream baos, PdfDocument.PdfInfo info)
{
if (xmpWriter == null)
xmpWriter = new PdfAXmpWriter(baos, info, ((IPdfAConformance)pdfIsoConformance).GetConformanceLevel());
return xmpWriter;
}
示例12: Initialize
public override void Initialize()
{
// instantiate document
pdfDocument = new PdfDocument();
pdfDocument.Info.Title = title;
pdfDocument.Info.Author = author;
// add a page
PdfPage page = pdfDocument.AddPage();
page.Orientation = PageOrientation.Portrait;
// set page size
page.Width = XUnit.FromMillimeter(bbox.Width);
page.Height = XUnit.FromMillimeter(bbox.Height);
// get graphics
this.pdfGfx = XGraphics.FromPdfPage(page);
// draw a bounding box
XRect rect = new XRect(0.5, 0.5, page.Width - 1, page.Height - 1);
this.pdfGfx.DrawRectangle(XBrushes.White, rect);
// initialize cotation
PicCotation._globalCotationProperties._arrowLength = XUnit.FromMillimeter(bbox.Height) / 50.0;
}
示例13: WriteToPdf
public override void WriteToPdf(PdfDocument doc)
{
// LABEL
// ---------------
// | Hodnota(Text) |
// ---------------
// biely stvorec obsahujuci hodnotu elementu (ulozenu v Text)
// sirka bieleho pola je priamoumerna dlzke textu ktory v nej bude vykresleny
if (FieldWidth == -1)
FieldWidth = 15 + (int)customfont.GetWidthPointKerned(Text, FieldFontSize);
if (FieldHeight == -1)
FieldHeight = FieldFontSize + 2;
RectArea r = new RectArea(PosX + 1, PosY +2, FieldWidth+2, FieldHeight);
r.SetFillColor(0, 0, 0, 0);
r.AddToDocument(doc);
if (Label.Text != "")
{
// vykreslenie labelu, ktory popisuje hodnoty nizsie
Label.PosX = this.PosX + 3;
Label.PosY = this.PosY + FieldHeight + 3;
Label.WriteToPdf(doc);
}
// vpisanie hodnoty elementu do bieleho pola
Label l = new Label();
l.Width = FieldWidth-10;
l.Height = FieldHeight;
l.Text = this.Text;
l.PosX = PosX ;
l.PosY = PosY + 4;
l.FontSize = FieldFontSize;
if (FieldWidth > -1)
l.Width = FieldWidth;
if (FieldHeight >= -1)
l.Height = FieldHeight;
l.WriteToPdf(doc);
}