本文整理汇总了C#中iTextSharp.text.pdf.PdfWriter类的典型用法代码示例。如果您正苦于以下问题:C# PdfWriter类的具体用法?C# PdfWriter怎么用?C# PdfWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfWriter类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: WriteTOC
protected virtual void WriteTOC(List<PdfContentParameter> contents, PdfWriter writer, Document document)
{
document.NewPage();
PdfPTable t = new PdfPTable(2);
t.WidthPercentage = 100;
t.SetWidths(new float[] { 98f, 2f });
t.TotalWidth = document.PageSize.Width - (document.LeftMargin + document.RightMargin);
t.AddCell(new PdfPCell(
new Phrase(GlobalStringResource.TableOfContents,
FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16))
) { Colspan = 2, Border = Rectangle.NO_BORDER, PaddingBottom = 25 });
foreach (PdfContentParameter item in contents)
{
if (!string.IsNullOrEmpty(item.Header))
{
t.AddCell(
new PdfPCell(
new Phrase(item.Header,
FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)
)
) { Border = Rectangle.NO_BORDER, NoWrap = false, FixedHeight = 15, }
);
PdfPCell templateCell = new PdfPCell(Image.GetInstance(item.Template));
templateCell.HorizontalAlignment = Element.ALIGN_RIGHT;
templateCell.Border = Rectangle.NO_BORDER;
t.AddCell(templateCell);
}
}
float docHeight = document.PageSize.Height - heightOffset;
document.Add(t);
}
开发者ID:meanprogrammer,项目名称:sawebreports_migrated,代码行数:33,代码来源:PDFBuilderStrategyBase.cs
示例2: OnEndPage
public override void OnEndPage(PdfWriter writer, Document document) {
ColumnText.ShowTextAligned(
writer.DirectContentUnder,
Element.ALIGN_CENTER, new Phrase("FOOBAR FILM FESTIVAL", FONT),
297.5f, 421, writer.PageNumber % 2 == 1 ? 45 : -45
);
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例3: GetSpotObject
protected internal virtual PdfObject GetSpotObject(PdfWriter writer) {
PdfArray array = new PdfArray(PdfName.SEPARATION);
array.Add(name);
PdfFunction func = null;
if (altcs is ExtendedColor) {
int type = ((ExtendedColor)altcs).Type;
switch (type) {
case ExtendedColor.TYPE_GRAY:
array.Add(PdfName.DEVICEGRAY);
func = PdfFunction.Type2(writer, new float[]{0, 1}, null, new float[]{0}, new float[]{((GrayColor)altcs).Gray}, 1);
break;
case ExtendedColor.TYPE_CMYK:
array.Add(PdfName.DEVICECMYK);
CMYKColor cmyk = (CMYKColor)altcs;
func = PdfFunction.Type2(writer, new float[]{0, 1}, null, new float[]{0, 0, 0, 0},
new float[]{cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black}, 1);
break;
default:
throw new Exception(MessageLocalization.GetComposedMessage("only.rgb.gray.and.cmyk.are.supported.as.alternative.color.spaces"));
}
}
else {
array.Add(PdfName.DEVICERGB);
func = PdfFunction.Type2(writer, new float[]{0, 1}, null, new float[]{1, 1, 1},
new float[]{(float)altcs.R / 255, (float)altcs.G / 255, (float)altcs.B / 255}, 1);
}
array.Add(func.Reference);
return array;
}
开发者ID:,项目名称:,代码行数:29,代码来源:
示例4: PdfReaderInstance
internal PdfReaderInstance(PdfReader reader, PdfWriter writer)
{
this.reader = reader;
this.writer = writer;
file = reader.SafeFile;
myXref = new int[reader.XrefSize];
}
开发者ID:jomamorales,项目名称:createPDF,代码行数:7,代码来源:PdfReaderInstance.cs
示例5: Url
/**
* Creates a file specification of type URL.
* @param writer the <CODE>PdfWriter</CODE>
* @param url the URL
* @return the file specification
*/
public static PdfFileSpecification Url(PdfWriter writer, String url) {
PdfFileSpecification fs = new PdfFileSpecification();
fs.writer = writer;
fs.Put(PdfName.FS, PdfName.URL);
fs.Put(PdfName.F, new PdfString(url));
return fs;
}
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:13,代码来源:PdfFileSpecification.cs
示例6: OnChapter
/**
* Initialize one of the headers, based on the chapter title;
* reset the page number.
* @see com.itextpdf.text.pdf.PdfPageEventHelper#onChapter(
* com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document, float,
* com.itextpdf.text.Paragraph)
*/
public override void OnChapter(
PdfWriter writer, Document document,
float paragraphPosition, Paragraph title)
{
header[1] = new Phrase(title.Content);
pagenumber = 1;
}
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:14,代码来源:MovieHistory2.cs
示例7: PageFinished
/// <summary>
/// Fires when a page is finished, just before being written to the document.
/// </summary>
/// <param name="writer">PdfWriter</param>
/// <param name="document">PDF Document</param>
/// <param name="columnCellsSummaryData">List of all rows summaries data</param>
public void PageFinished(PdfWriter writer, Document document, IList<SummaryCellData> columnCellsSummaryData)
{
var footerTable = AddPageFooter(new FooterData
{
PdfDoc = document,
PdfWriter = writer,
SummaryData = columnCellsSummaryData,
CurrentPageNumber = writer.PageNumber,
TotalPagesCountImage = _totalPageCountImage
});
var table = new PdfGrid(1)
{
RunDirection = (int)FooterProperties.RunDirection,
WidthPercentage = FooterProperties.TableWidthPercentage
};
var tableCell = new PdfPCell(footerTable) { Border = 0 };
table.AddCell(tableCell);
var page = document.PageSize;
table.SetTotalWidth(new[] { page.Width - document.LeftMargin - document.RightMargin });
table.WriteSelectedRows(
rowStart: 0,
rowEnd: -1,
xPos: document.LeftMargin,
yPos: document.BottomMargin - FooterProperties.SpacingBeforeTable,
canvas: writer.DirectContent);
}
开发者ID:andycarmona,项目名称:TimelyDepotUps,代码行数:34,代码来源:InlineFooterProvider.cs
示例8: OnOpenDocument
// we override the onOpenDocument method
public override void OnOpenDocument(PdfWriter writer, Document document)
{
_bf = _normalFont.GetCalculatedBaseFont(false);
_cb = writer.DirectContent;
_ct = new ColumnText(_cb);
base.OnOpenDocument(writer, document);
}
开发者ID:jwebb-vtg,项目名称:WSCIEMP,代码行数:8,代码来源:rptFieldContracting.cs
示例9: OnOpenDocument
public override void OnOpenDocument(PdfWriter writer, Document document)
{
total = writer.DirectContent.CreateTemplate(100, 100);
total.BoundingBox = new Rectangle(-20, -20, 100, 100);
helv = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
}
开发者ID:woofwoof88,项目名称:first-place-processing,代码行数:7,代码来源:pdfPrintEnvelopes.ashx.cs
示例10: OnEndPage
public override void OnEndPage(PdfWriter writer, Document document)
{
PdfContentByte cb = writer.DirectContent;
cb.SaveState();
string text = "Page " + writer.PageNumber + " of ";
float textBase = document.Bottom - 20;
float textSize = 12; //helv.GetWidthPoint(text, 12);
cb.BeginText();
cb.SetFontAndSize(helv, 12);
if ((writer.PageNumber % 2) == 1)
{
cb.SetTextMatrix(document.Left, textBase);
cb.ShowText(text);
cb.EndText();
cb.AddTemplate(total, document.Left + textSize, textBase);
}
else
{
float adjust = helv.GetWidthPoint("0", 12);
cb.SetTextMatrix(document.Right - textSize - adjust, textBase);
cb.ShowText(text);
cb.EndText();
cb.AddTemplate(total, document.Right - adjust, textBase);
}
cb.RestoreState();
}
开发者ID:woofwoof88,项目名称:first-place-processing,代码行数:26,代码来源:pdfPrintEnvelopes.ashx.cs
示例11: Close
public override void Close(PdfWriter writer) {
base.Close(writer);
bool ok = false;
IXmpMeta xmpMeta = writer.XmpWriter.XmpMeta;
try {
String docFileName = xmpMeta.GetPropertyString(PdfAXmpWriter.zugferdSchemaNS,
PdfAXmpWriter.zugferdDocumentFileName);
foreach (PdfFileSpecification attachment in attachments) {
if (docFileName.Equals(attachment.GetAsString(PdfName.UF).ToString())) {
PdfName relationship = attachment.GetAsName(PdfName.AFRELATIONSHIP);
if (!AFRelationshipValue.Alternative.Equals(relationship)) {
attachments.Clear();
throw new PdfAConformanceException(attachment,
MessageLocalization.GetComposedMessage("afrelationship.value.shall.be.alternative"));
}
ok = true;
break;
}
}
} catch (Exception e) {
attachments.Clear();
throw e;
}
attachments.Clear();
if (!ok) {
throw new PdfAConformanceException(xmpMeta,
MessageLocalization.GetComposedMessage("zugferd.xmp.schema.shall.contain.attachment.name"));
}
}
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:29,代码来源:ZugferdChecker.cs
示例12: OnStartPage
public override void OnStartPage(PdfWriter writer, Document document) {
PdfPTable headerTable = new PdfPTable(1);
headerTable.AddCell(new Phrase("Header"));
WriteTable(writer.DirectContent, headerTable,
new Rectangle(0, document.PageSize.Height - 50f, document.PageSize.Width, document.PageSize.Height));
}
开发者ID:newlysoft,项目名称:itextsharp,代码行数:7,代码来源:TaggedPdfPageEventsTest.cs
示例13: CheckPdfAConformance
/**
*
* @param writer
* @param key
* @param obj1
*/
static public void CheckPdfAConformance(PdfWriter writer, int key, Object obj1) {
if (writer == null || !writer.IsPdfIso())
return;
switch (key) {
case PdfIsoKeys.PDFISOKEY_FONT:
if (!((BaseFont)obj1).IsEmbedded())
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont) obj1).PostscriptFontName));
break;
case PdfIsoKeys.PDFISOKEY_IMAGE:
PdfImage image = (PdfImage)obj1;
if (image.Get(PdfName.SMASK) != null)
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("the.smask.key.is.not.allowed.in.images"));
break;
case PdfIsoKeys.PDFISOKEY_GSTATE:
PdfDictionary gs = (PdfDictionary)obj1;
PdfObject obj = gs.Get(PdfName.BM);
if (obj != null && !PdfGState.BM_NORMAL.Equals(obj) && !PdfGState.BM_COMPATIBLE.Equals(obj))
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("blend.mode.1.not.allowed", obj.ToString()));
obj = gs.Get(PdfName.CA);
double v = 0.0;
if (obj != null && (v = ((PdfNumber)obj).DoubleValue) != 1.0)
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("transparency.is.not.allowed.ca.eq.1", v));
obj = gs.Get(PdfName.ca_);
v = 0.0;
if (obj != null && (v = ((PdfNumber)obj).DoubleValue) != 1.0)
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("transparency.is.not.allowed.ca.eq.1", v));
break;
case PdfIsoKeys.PDFISOKEY_LAYER:
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("layers.are.not.allowed"));
default:
break;
}
}
开发者ID:,项目名称:,代码行数:39,代码来源:
示例14: OnEndPage
//重写 关闭一个页面时
public override void OnEndPage(PdfWriter writer, Document document)
{
try
{
Font font = new Font(basefont, defaultFontSize);
Phrase head = new Phrase(header, font);
PdfContentByte cb = writer.DirectContent;
//页眉显示的位置
ColumnText.ShowTextAligned(cb, Element.ALIGN_RIGHT, head,
document.Right - 10 + document.LeftMargin, document.Top + 10, 0);
if (PAGE_NUMBER)
{
Phrase footer = new Phrase("第 " + writer.PageNumber + " / " + " "+" 頁", font);
cb = writer.DirectContent;
//tpl = cb.CreateTemplate(100, 100);
//模版 显示总共页数
cb.AddTemplate(tpl, document.Left / 2 + document.Right / 2 , document.Bottom - 10);//调节模版显示的位置
//页脚显示的位置
ColumnText.ShowTextAligned(cb, Element.ALIGN_RIGHT, footer,
document.Left / 2+document.Right/ 2+23, document.Bottom - 10, 0);
}
}
catch (Exception ex)
{
throw new Exception("HeaderAndFooterEvent-->OnEndPage-->" + ex.Message);
}
}
开发者ID:lxh2014,项目名称:gigade-net,代码行数:31,代码来源:HeaderAndFooterEvent.cs
示例15: CreateTitle
/**
* Creates a title layer. A title layer is not really a layer but a collection of layers
* under the same title heading.
* @param title the title text
* @param writer the <CODE>PdfWriter</CODE>
* @return the title layer
*/
public static PdfLayer CreateTitle(String title, PdfWriter writer) {
if (title == null)
throw new ArgumentNullException("Title cannot be null.");
PdfLayer layer = new PdfLayer(title);
writer.RegisterLayer(layer);
return layer;
}
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:14,代码来源:PdfLayer.cs
示例16: OnOpenDocument
public override void OnOpenDocument(PdfWriter writer, Document document)
{
base.OnOpenDocument(writer, document);
font = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
dc = writer.DirectContent;
tpl = dc.CreateTemplate(50, 50);
}
开发者ID:stevesloka,项目名称:bvcms,代码行数:7,代码来源:EnrollmentControlResult.cs
示例17: OnEndPage
public override void OnEndPage(PdfWriter writer, Document document)
{
base.OnEndPage(writer, document);
Rectangle pageSize = document.PageSize;
int pageN = writer.PageNumber;
String text = "Page " + pageN + "/";
float len = bf.GetWidthPoint(text, 8);
cb.SetRGBColorFill(0, 0, 0);
// Line separated fotter from rest of sheet
cb.MoveTo(50, pageSize.Bottom + 60);
cb.LineTo(pageSize.Right - 50, pageSize.Bottom + 60);
cb.SetLineWidth(0.75f);
cb.Fill();
cb.Stroke();
cb.BeginText();
cb.SetFontAndSize(gf, 8);
cb.SetTextMatrix(pageSize.GetLeft(((pageSize.Width - 80) / 2) + len), pageSize.GetBottom(50));
cb.ShowText(text);
cb.EndText();
cb.AddTemplate(template, pageSize.GetLeft(((pageSize.Width - 80) / 2) + len + len - 2), pageSize.GetBottom(50));
cb.BeginText();
cb.SetFontAndSize(gf, 8);
cb.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, "generated on Ticketing System", pageSize.GetRight(50), pageSize.GetBottom(50), 0);
cb.EndText();
}
开发者ID:karolgornicki,项目名称:TicketingSystem,代码行数:31,代码来源:HeaderFooter.cs
示例18: initFile
protected void initFile(bool bBlackAndWhite = false)
{
m_doc = new Document();
string folder = Settings.Default["pdffolder"].ToString() + m_strFolder;
System.IO.Directory.CreateDirectory(folder );
string fileName = folder + "/"+m_strTitle;
if (bBlackAndWhite)
fileName += "BW.pdf";
else
fileName += ".pdf";
m_writer = PdfWriter.GetInstance(m_doc, new System.IO.FileStream(fileName, System.IO.FileMode.Create));
m_doc.Open();
m_fSmall = new iTextSharp.text.Font();
m_fSmall.Size = 10;
m_fBig = new iTextSharp.text.Font();
m_fBig.Size = 40;
m_fBig.Color = bBlackAndWhite ? BaseColor.BLACK : getNextColor();
// m_fBig.SetStyle("bold");
m_fNorm = new iTextSharp.text.Font();
m_fNorm.Size = 20;
m_fNorm.Color = new BaseColor(m_colorText);
m_doc.Add(new Paragraph("Name:____________________________________________ Date:______________"/*, fSmall*/));
m_doc.Add(new Paragraph(m_strTitle, m_fBig));
m_doc.Add(new Paragraph(" "));
}
开发者ID:mangalambigai,项目名称:WorksheetGen,代码行数:29,代码来源:Worksheet.cs
示例19: PdfPatternPainter
internal PdfPatternPainter(PdfWriter wr, BaseColor defaultColor) : this(wr) {
stencil = true;
if (defaultColor == null)
this.defaultColor = BaseColor.GRAY;
else
this.defaultColor = defaultColor;
}
开发者ID:Gianluigi,项目名称:dssnet,代码行数:7,代码来源:PdfPatternPainter.cs
示例20: GetColorantDetails
public virtual ColorDetails[] GetColorantDetails(PdfWriter writer) {
if (altColorDetails == null && this.altcs is ExtendedColor &&
((ExtendedColor) this.altcs).Type == ExtendedColor.TYPE_LAB) {
altColorDetails = writer.AddSimple(((LabColor) altcs).LabColorSpace);
}
return new ColorDetails[] {altColorDetails};
}
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:7,代码来源:PdfSpotColor.cs
注:本文中的iTextSharp.text.pdf.PdfWriter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论