當前位置: 首頁>>代碼示例>>C#>>正文


C# pdf.PdfWriter類代碼示例

本文整理匯總了C#中iTextSharp.text.pdf.PdfWriter的典型用法代碼示例。如果您正苦於以下問題:C# PdfWriter類的具體用法?C# PdfWriter怎麽用?C# PdfWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PdfWriter類屬於iTextSharp.text.pdf命名空間,在下文中一共展示了PdfWriter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的iTextSharp.text.pdf.PdfWriter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。