• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# PdfWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PdfWriter的典型用法代码示例。如果您正苦于以下问题:C# PdfWriter类的具体用法?C# PdfWriter怎么用?C# PdfWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PdfWriter类属于命名空间,在下文中一共展示了PdfWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnStartPage

    public override void OnStartPage(PdfWriter writer, Document document)
    {
        base.OnStartPage(writer, document);

        if ((tipoDocumento == "contrato") || (tipoDocumento == "contrato_preimpreso")) //no se ponen cabeceras ni fotter
        {

        }
        else
        {
            if (tipoDocumento == "clausula")
            {
                //imagen de la cabecera
                float escala = 85; //%

                Image imagenHeader = Image.GetInstance(dirImagenHeader);
                imagenHeader.ScalePercent(escala);

                PdfPTable table = new PdfPTable(1);
                table.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;

                //logo
                PdfPCell cell = new PdfPCell(imagenHeader);
                cell.Border = 0;
                cell.BorderWidth = 0;
                table.AddCell(cell);

                table.WriteSelectedRows(0, -1, document.LeftMargin, document.PageSize.Height - 20, writer.DirectContent);
            }
            else
            {
                if (tipoDocumento == "apertura_cuenta")
                {
                    //imagen de la cabecera
                    float escala = 70; //%

                    Image imagenHeader = Image.GetInstance(dirImagenHeader);
                    imagenHeader.ScalePercent(escala);

                    PdfPTable table = new PdfPTable(1);
                    table.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;

                    //logo
                    PdfPCell cell = new PdfPCell(imagenHeader);
                    cell.Border = 0;
                    cell.BorderWidth = 0;
                    table.AddCell(cell);

                    table.WriteSelectedRows(0, -1, document.LeftMargin, document.PageSize.Height - 90, writer.DirectContent);
                }
                else
                {
                    if (tipoDocumento == "autos_recomendacion")
                    {
                        //imagen de la cabecera
                        float escala = 70; //%

                        Image imagenHeader = Image.GetInstance(dirImagenHeader);
                        imagenHeader.ScalePercent(escala);

                        PdfPTable table = new PdfPTable(1);
                        table.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;

                        //logo
                        PdfPCell cell = new PdfPCell(imagenHeader);
                        cell.Border = 0;
                        cell.BorderWidth = 0;
                        table.AddCell(cell);

                        table.WriteSelectedRows(0, -1, document.LeftMargin, document.PageSize.Height - 20, writer.DirectContent);
                    }
                    else
                    {
                        if (tipoDocumento == "orden_compra")
                        {
                            //imagen de la cabecera
                            float escala = 70; //%

                            Image imagenHeader = Image.GetInstance(dirImagenHeader);
                            imagenHeader.ScalePercent(escala);

                            PdfPTable table = new PdfPTable(1);
                            table.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;

                            //logo
                            PdfPCell cell = new PdfPCell(imagenHeader);
                            cell.Border = 0;
                            cell.BorderWidth = 0;
                            table.AddCell(cell);

                            table.WriteSelectedRows(0, -1, document.LeftMargin, document.PageSize.Height - 20, writer.DirectContent);
                        }
                        else
                        {
                            if (tipoDocumento == "entrevista")
                            {
                                //imagen de la cabecera
                                float escala = 85; //%

                                Image imagenHeader = Image.GetInstance(dirImagenHeader);
//.........这里部分代码省略.........
开发者ID:jquirogadesarrollador,项目名称:Varu,代码行数:101,代码来源:pdfEvents.cs


示例2: UserReport

 public UserReport()
 {
     doc = new Document(PageSize.A4.Rotate(), 35, 35, 35, 35);
     writer = PdfWriter.GetInstance(doc, ms);
     MyPageEvents events = new MyPageEvents();
     writer.PageEvent = events;
 }
开发者ID:paulallies,项目名称:tsdt,代码行数:7,代码来源:UserReport.cs


示例3: CheckFileSpec

        protected override void CheckFileSpec(PdfWriter writer, int key, Object obj1) {
            if (obj1 is PdfFileSpecification) {
                PdfDictionary fileSpec = (PdfFileSpecification) obj1;
                if (!fileSpec.Contains(PdfName.UF) || !fileSpec.Contains(PdfName.F)
                    || !fileSpec.Contains(PdfName.DESC)) {
                    throw new PdfAConformanceException(obj1, MessageLocalization.GetComposedMessage("file.specification.dictionary.shall.contain.f.uf.and.desc.entries"));
                }

                PdfObject obj = fileSpec.Get(PdfName.AFRELATIONSHIP);

                if (obj == null || !obj.IsName() || !allowedAFRelationships.Contains(obj as PdfName)) {
                    throw new PdfAConformanceException(obj1, MessageLocalization.GetComposedMessage("file.specification.dictionary.shall.contain.correct.afrelationship.key"));
                }

                if (fileSpec.Contains(PdfName.EF)) {
                    PdfDictionary dict = GetDirectDictionary(fileSpec.Get(PdfName.EF));
                    if (dict == null || !dict.Contains(PdfName.F)) {
                        throw new PdfAConformanceException(obj1,
                            MessageLocalization.GetComposedMessage("ef.key.of.file.specification.dictionary.shall.contain.dictionary.with.valid.f.key"));
                    }

                    PdfDictionary embeddedFile = GetDirectDictionary(dict.Get(PdfName.F));
                    if (embeddedFile == null) {
                        throw new PdfAConformanceException(obj1,
                            MessageLocalization.GetComposedMessage("ef.key.of.file.specification.dictionary.shall.contain.dictionary.with.valid.f.key"));
                    }

                    CheckEmbeddedFile(embeddedFile);
                }
            }
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:31,代码来源:PdfA3Checker.cs


示例4: CheckGState

 protected override void CheckGState(PdfWriter writer, int key, Object obj1) {
     PdfDictionary gs = (PdfDictionary) obj1;
     PdfObject obj = gs.Get(PdfName.BM);
     if (obj != null && !allowedBlendModes.Contains((PdfName)obj)) {
         throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("blend.mode.1.not.allowed", obj.ToString()));
     }
 }
开发者ID:,项目名称:,代码行数:7,代码来源:


示例5: OnCloseDocument

 // we override the onCloseDocument method
 public override void OnCloseDocument(PdfWriter writer, Document document)
 {
     template.BeginText();
     template.SetFontAndSize(bf, 8);
     template.ShowText((writer.PageNumber - 1).ToString());
     template.EndText();
 }
开发者ID:paulallies,项目名称:tsdt,代码行数:8,代码来源:PDFPager.cs


示例6: Write

        /// <summary>
        ///     Writes the cross reference section to the passed PDF writer.
        /// </summary>
        internal void Write(PdfWriter writer)
        {
            // Write the 'xref' keyword.
            writer.WriteKeywordLine(Keyword.XRef);

            // Get the one and only subsection to write itself.
            subsection.Write(writer);
        }
开发者ID:nholik,项目名称:Fo.Net,代码行数:11,代码来源:XRefSection.cs


示例7: OnChapter

 // we override the onChapter method
 public override void OnChapter(PdfWriter writer, Document document, float paragraphPosition, Paragraph title)
 {
     System.Text.StringBuilder buf = new System.Text.StringBuilder();
     foreach (Chunk chunk in title.Chunks)
     {
         buf.Append(chunk.Content);
     }
     act = buf.ToString();
 }
开发者ID:paulallies,项目名称:tsdt,代码行数:10,代码来源:PDFPager.cs


示例8: Write

 protected internal override void Write(PdfWriter writer)
 {
     writer.WriteKeyword(Keyword.ArrayBegin);
     writer.WriteSpace();
     writer.Write(startCID);
     writer.WriteSpace();
     array.Write(writer);
     writer.WriteKeyword(Keyword.ArrayEnd);
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:9,代码来源:PdfWArray.cs


示例9: Write

 protected internal override void Write(PdfWriter writer)
 {
     writer.WriteKeywordLine(Keyword.Trailer);
     base.Write(writer);
     writer.WriteLine();
     writer.WriteKeywordLine(Keyword.StartXRef);
     writer.WriteLine(xrefOffset);
     writer.WriteKeyword(Keyword.Eof);
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:9,代码来源:PdfFileTrailer.cs


示例10: Write

 protected internal override void Write(PdfWriter writer)
 {
     PdfArray dest = new PdfArray();
     dest.Add(pageReference);
     dest.Add(PdfName.Names.XYZ);
     dest.Add(new PdfNumeric(xPosition));
     dest.Add(new PdfNumeric(yPosition));
     dest.Add(PdfNull.Null);
     this[PdfName.Names.D] = dest;
     base.Write(writer);
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:11,代码来源:PdfGoTo.cs


示例11: Write

 protected internal override void Write(PdfWriter writer)
 {
     if (fonts.Count > 0)
     {
         this[PdfName.Names.Font] = fonts;
     }
     if (xObjects.Count > 0)
     {
         this[PdfName.Names.XObject] = xObjects;
     }
     base.Write(writer);
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:12,代码来源:PdfResources.cs


示例12: CheckPdfAConformance

 internal void CheckPdfAConformance(PdfWriter writer, int key, Object obj1) {
     if(writer == null || !writer.IsPdfIso())
         return;
     switch(key) {
         case PdfIsoKeys.PDFISOKEY_FONT:
             CheckFont(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_IMAGE:
             CheckImage(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_GSTATE:
             CheckGState(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_LAYER:
             CheckLayer(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_TRAILER:
             CheckTrailer(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_STREAM:
             CheckStream(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_FILESPEC:
             CheckFileSpec(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_OBJECT:
             CheckPdfObject(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_CANVAS:
             CheckCanvas(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_COLOR:
         case PdfIsoKeys.PDFISOKEY_CMYK:
         case PdfIsoKeys.PDFISOKEY_RGB:
             CheckColor(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_ANNOTATION:
             CheckAnnotation(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_ACTION:
             CheckAction(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_FORM:
             CheckForm(writer, key, obj1);
             break;
         case PdfIsoKeys.PDFISOKEY_STRUCTELEM:
             if(CheckStructure(conformanceLevel))
                 CheckStructElem(writer, key, obj1);
             break;
         default:
             break;
     }
 }
开发者ID:,项目名称:,代码行数:53,代码来源:


示例13: Generate

 public void Generate(Document doc, DocumentType docType, string addSheet,PdfWriter writer)
 {
     GenerateDocument(doc, docType, addSheet,writer);
     /* Temporary moving this code to Method Statement as Continuation sheet needs to be printed on the
      * back of main sheet before the additional notes. After a proper solution we will try
      * to put it back or otherwise.
     if (overflowTable != null)
     {
         doc.NewPage();
         doc.Add(overflowTable);
     }
      * */
 }
开发者ID:ali-codehoppers,项目名称:unchsunchs,代码行数:13,代码来源:GenericGenerator.cs


示例14: Write

        protected internal override void Write(PdfWriter writer)
        {
            // Add a dictionary entry for /Count (the number of leaf 
            // nodes (page objects) that are descendants of this
            // node within the page tree.
            int count = 0;
            for (int x = 0; x < kids.Count; x++)
            {
                count++; // TODO: test if it is a leaf.
            }
            this[PdfName.Names.Count] = new PdfNumeric(count);

            base.Write(writer);
        }
开发者ID:nholik,项目名称:Fo.Net,代码行数:14,代码来源:PdfPageTree.cs


示例15: CheckImage

    protected override void CheckImage(PdfWriter writer, int key, Object obj1) {
        PdfImage pdfImage = (PdfImage) obj1;
        if (pdfImage != null && (pdfImage.Image is Jpeg2000)) {
            Jpeg2000 jpeg2000 = (Jpeg2000) pdfImage.Image;
            if (!jpeg2000.IsJp2()) {
                throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("only.jpx.baseline.set.of.features.shall.be.used"));
            }
            if (jpeg2000.GetNumOfComps() != 1 && jpeg2000.GetNumOfComps() != 3 && jpeg2000.GetNumOfComps() != 4) {
                throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("the.number.of.colour.channels.in.the.jpeg2000.data.shall.be.123"));
            }
            if (jpeg2000.Bpc < 1 || jpeg2000.Bpc > 38) {
                throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("the.bit-depth.of.the.jpeg2000.data.shall.have.a.value.in.the.range.1to38"));
            }
            if (jpeg2000.GetBpcBoxData() != null) {
                throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("all.colour.channels.in.the.jpeg2000.data.shall.have.the.same.bit-depth"));
            }
            List<Jpeg2000.ColorSpecBox> colorSpecBoxes = jpeg2000.GetColorSpecBoxes();
            if (colorSpecBoxes != null) {
                if (colorSpecBoxes.Count > 1) {
                    int approx0x01 = 0;
                    foreach (Jpeg2000.ColorSpecBox colorSpecBox in colorSpecBoxes) {
                        if (colorSpecBox.GetApprox() == 1)
                            approx0x01++;
                    }
                    if (approx0x01 != 1) {
                        throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("exactly.one.colour.space.specification.shall.have.the.value.0x01.in.the.approx.field"));
                    }
                }
                foreach (Jpeg2000.ColorSpecBox colorSpecBox in colorSpecBoxes) {
                    if (colorSpecBox.GetMeth() != 1 && colorSpecBox.GetMeth() != 2 && colorSpecBox.GetMeth() != 3) {
                        throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("the.value.of.the.meth.entry.in.colr.box.shall.be.123"));
                    }
                    if (colorSpecBox.GetEnumCs() == 19) {
                        throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("jpeg2000.enumerated.colour.space.19.(CIEJab).shall.not.be.used"));
                    }
                    byte[] colorProfileBytes = colorSpecBox.GetColorProfile();
                    if (colorProfileBytes != null) {
                        //ICC profile verification should follow here.
                    }
                }

            }
        }
    }
开发者ID:,项目名称:,代码行数:44,代码来源:


示例16: OnEndPage

 public override void OnEndPage(PdfWriter writer, Document document)
 {
     PdfPTable table = new PdfPTable(3);
     try
     {
         table.SetWidths(new int[] { 24, 24, 2 });
         table.TotalWidth = 527;
         table.LockedWidth = true;
         table.DefaultCell.FixedHeight = 20;
         table.DefaultCell.Border = Rectangle.BOTTOM_BORDER;
         table.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT;
         table.AddCell(string.Format("{0}", writer.PageNumber));
         table.WriteSelectedRows(0, -1, 34, 803, writer.DirectContent);
     }
     catch (DocumentException de)
     {
         throw de;
     }
 }
开发者ID:aaams,项目名称:infinite-story-download,代码行数:19,代码来源:HeaderFooter.cs


示例17: GenerateDocument

 protected override void GenerateDocument(Document doc, DocumentType docType, string addSheet, PdfWriter writer)
 {
     DepartmentOrderDocTableAdapters.DocumentContentTableAdapter ta = new DepartmentOrderDocTableAdapters.DocumentContentTableAdapter();
     IEnumerator iEnum = ta.GetDocumentContentById(docType.DocId, docType.CoId, docType.DeptId).GetEnumerator();
     if (iEnum.MoveNext())
     {
         DepartmentOrderDoc.DocumentContentEntityRow docContent = (DepartmentOrderDoc.DocumentContentEntityRow)iEnum.Current;
         if (docContent.file_contents != null && docContent.file_contents.Length > 0)
         {
             PdfContentByte pdfContentByte = writer.DirectContent;
             PdfReader reader = new PdfReader(docContent.file_contents);
             for (int page = 1; page <= reader.NumberOfPages; page++)
             {
                 doc.NewPage();
                 PdfImportedPage importedPage = writer.GetImportedPage(reader, page);
                 pdfContentByte.AddTemplate(importedPage, 0, 0);
             }
         }
     }
 }
开发者ID:ali-codehoppers,项目名称:unchsunchs,代码行数:20,代码来源:SignageGenerator.cs


示例18: CheckFont

 protected override void CheckFont(PdfWriter writer, int key, Object obj1) {
     BaseFont bf = (BaseFont) obj1;
     if (bf.FontType == BaseFont.FONT_TYPE_DOCUMENT) {
         PdfStream prs = null;
         PdfDictionary fontDictionary = ((DocumentFont) bf).FontDictionary;
         PdfDictionary fontDescriptor = fontDictionary.GetAsDict(PdfName.FONTDESCRIPTOR);
         if (fontDescriptor != null) {
             prs = fontDescriptor.GetAsStream(PdfName.FONTFILE);
             if (prs == null) {
                 prs = fontDescriptor.GetAsStream(PdfName.FONTFILE2);
             }
             if (prs == null) {
                 prs = fontDescriptor.GetAsStream(PdfName.FONTFILE3);
             }
         }
         if (prs == null) {
             throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont) obj1).PostscriptFontName));
         }
     } else {
         if (!bf.IsEmbedded())
             throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont) obj1).PostscriptFontName));
     }
 }
开发者ID:,项目名称:,代码行数:23,代码来源:


示例19: OnEndPage

 // we override the onEndPage method
 public override void OnEndPage(PdfWriter writer, Document document)
 {
     int pageN = writer.PageNumber;
     String text = "Page " + pageN + " of ";
     float len = bf.GetWidthPoint(text, 8);
     cb.BeginText();
     cb.SetFontAndSize(bf, 8);
     cb.SetTextMatrix(760, 25);
     cb.ShowText(text);
     cb.EndText();
     cb.AddTemplate(template, 760 + len, 25);
     cb.BeginText();
     cb.SetFontAndSize(bf, 8);
     cb.SetTextMatrix(760, 820);
     if (pageN % 2 == 1)
     {
         cb.ShowText("Report");
     }
     else
     {
         cb.ShowText(act);
     }
     cb.EndText();
 }
开发者ID:paulallies,项目名称:tsdt,代码行数:25,代码来源:PDFPager.cs


示例20: DrawLine

 private static void DrawLine(PdfWriter writer, float x1, float y1, float x2, float y2, Color color)
 {
     PdfContentByte contentByte = writer.DirectContent;
     contentByte.SetColorStroke(color);
     contentByte.MoveTo(x1, y1);
     contentByte.LineTo(x2, y2);
     contentByte.Stroke();
 }
开发者ID:devangsinha,项目名称:Hospital-Management-System,代码行数:8,代码来源:Receptionist_PrintAppointmentInvoiceBL.cs



注:本文中的PdfWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Peer类代码示例发布时间:2022-05-24
下一篇:
C# PdfObject类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap