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


C# PdfFileSpecification.PutAll方法代碼示例

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


在下文中一共展示了PdfFileSpecification.PutAll方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Close

        public override void Close(PdfWriter writer) {
            base.Close(writer);
            bool ok = false;

            IXmpMeta xmpMeta = null;
            if (writer.XmpWriter == null) {
               if (writer is PdfAStamperImp) {
                xmpMeta = ((PdfAStamperImp) writer).GetXmpMeta();
                PdfReader pdfReader = ((PdfAStamperImp) writer).GetPdfReader();
                PdfArray pdfArray = pdfReader.Catalog.GetAsArray(PdfName.AF);
                    if (pdfArray != null) {
                        for (int i = 0; i < pdfArray.Size; i++) {
                            PdfFileSpecification pdfFileSpecification = new PdfFileSpecification();
                            pdfFileSpecification.PutAll((PdfDictionary) pdfArray.GetDirectObject(i));
                            attachments.Add(pdfFileSpecification);
                        }
                    }
                }
            } else {
                xmpMeta = writer.XmpWriter.XmpMeta;
            }

            if (xmpMeta == null) {
                writer.CreateXmpMetadata();
                xmpMeta = writer.XmpWriter.XmpMeta;
            }

            try {
                String docFileName = xmpMeta.GetPropertyString(PdfAXmpWriter.zugferdSchemaNS,
                    PdfAXmpWriter.zugferdDocumentFileName);
                foreach (PdfFileSpecification attachment in attachments) {
                    if ((attachment.GetAsString(PdfName.UF) != null && docFileName.Equals(attachment.GetAsString(PdfName.UF).ToString()))
                            || (attachment.GetAsString(PdfName.F) != null && docFileName.Equals(attachment.GetAsString(PdfName.F).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:newlysoft,項目名稱:itextsharp,代碼行數:55,代碼來源:ZugferdChecker.cs


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