当前位置: 首页>>代码示例>>C#>>正文


C# PdfWriter类代码示例

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


PdfWriter类属于命名空间,在下文中一共展示了PdfWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,代码来源:


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