本文整理汇总了C#中PdfAConformanceLevel类的典型用法代码示例。如果您正苦于以下问题:C# PdfAConformanceLevel类的具体用法?C# PdfAConformanceLevel怎么用?C# PdfAConformanceLevel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PdfAConformanceLevel类属于命名空间,在下文中一共展示了PdfAConformanceLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PdfAStamperImp
/**
* Creates new PdfStamperImp.
* @param reader reads the PDF
* @param os the output destination
* @param pdfVersion the new pdf version or '\0' to keep the same version as the original document
* @param append
* @param conformanceLevel PDF/A conformance level of a new PDF document
* @throws DocumentException on error
* @throws IOException
*/
internal PdfAStamperImp(PdfReader reader, Stream os, char pdfVersion, bool append, PdfAConformanceLevel conformanceLevel)
: base(reader, os, pdfVersion, append)
{
((IPdfAConformance)pdfIsoConformance).SetConformanceLevel(conformanceLevel);
PdfAWriter.SetPdfVersion(this, conformanceLevel);
ReadPdfAInfo();
}
示例2: SetConformanceLevel
/**
* @see PdfAConformance#setConformanceLevel(com.itextpdf.text.pdf.PdfAConformanceLevel)
*/
virtual public void SetConformanceLevel(PdfAConformanceLevel conformanceLevel) {
this.conformanceLevel = conformanceLevel;
switch(this.conformanceLevel) {
case PdfAConformanceLevel.PDF_A_1A:
case PdfAConformanceLevel.PDF_A_1B:
pdfAChecker = new PdfA1Checker(conformanceLevel);
break;
case PdfAConformanceLevel.PDF_A_2A:
case PdfAConformanceLevel.PDF_A_2B:
case PdfAConformanceLevel.PDF_A_2U:
pdfAChecker = new PdfA2Checker(conformanceLevel);
break;
case PdfAConformanceLevel.PDF_A_3A:
case PdfAConformanceLevel.PDF_A_3B:
case PdfAConformanceLevel.PDF_A_3U:
pdfAChecker = new PdfA3Checker(conformanceLevel);
break;
case PdfAConformanceLevel.ZUGFeRD:
case PdfAConformanceLevel.ZUGFeRDComfort:
case PdfAConformanceLevel.ZUGFeRDBasic:
case PdfAConformanceLevel.ZUGFeRDExtended:
pdfAChecker = new ZugferdChecker(conformanceLevel);
break;
default:
pdfAChecker = new PdfA1Checker(conformanceLevel);
break;
}
}
示例3: CreatePdfA
public void CreatePdfA(PdfAConformanceLevel level) {
Document doc = new Document();
MemoryStream stream = new MemoryStream();
PdfAWriter writer = PdfAWriter.GetInstance(doc, stream, level);
doc.Open();
ICC_Profile icc = ICC_Profile.GetInstance(File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read));
writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
writer.CreateXmpMetadata();
Font font = FontFactory.GetFont("FreeSans", BaseFont.IDENTITY_H, true, 12);
doc.Add(new Phrase("Hello, " + level + " world!", font));
doc.Add(new Phrase(Guid.NewGuid().ToString(), font));
doc.Close();
}
示例4: PdfObjectCheck
// This method is used in the PdfA2CheckerTest and PdfA3CheckerTest, too
public static void PdfObjectCheck(string output, PdfAConformanceLevel level, bool exceptionExpected)
{
FileStream fos = new FileStream(output, FileMode.Create);
Document document = new Document();
PdfAWriter writer = PdfAWriter.GetInstance(document, fos, level);
writer.CreateXmpMetadata();
document.Open();
Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12);
document.Add(new Paragraph("Hello World", font));
FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read);
ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream);
iccProfileFileStream.Close();
writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
PdfArray array = new PdfArray();
for (int i = 0; i < 8192; i++)
{
array.Add(new PdfNull());
}
writer.ExtraCatalog.Put(new PdfName("TestArray"), array);
bool exceptionThrown = false;
try
{
document.Close();
}
catch (PdfAConformanceException e)
{
if (e.GetObject().Equals(array))
exceptionThrown = true;
}
if (exceptionThrown != exceptionExpected) {
String error = exceptionExpected ? "" : " not";
error = String.Format("PdfAConformanceException should{0} be thrown.", error);
Assert.Fail(error);
}
}
示例5: PdfACopy
/**
* Constructor
*
* @param document document
* @param os outputstream
*/
public PdfACopy(Document document, Stream os, PdfAConformanceLevel conformanceLevel) : base(document, os) {
((IPdfAConformance) pdfIsoConformance).SetConformanceLevel(conformanceLevel);
PdfAWriter.SetPdfVersion(this, conformanceLevel);
}
示例6: PdfAStamper
/**
* Starts the process of adding extra content to an existing PDF document keeping the document PDF/A conformant.
* @param reader the original document. It cannot be reused
* @param os the output stream
* @param pdfVersion the new pdf version or '\0' to keep the same version as the original document
* @param append if <CODE>true</CODE> appends the document changes as a new revision. This is only useful for multiple signatures as nothing is gained in speed or memory
* @param conformanceLevel PDF/A conformance level of a new PDF document
* @throws DocumentException on error
* @throws IOException or error
*/
public PdfAStamper(PdfReader reader, Stream os, char pdfVersion, bool append, PdfAConformanceLevel conformanceLevel)
{
stamper = new PdfAStamperImp(reader, os, pdfVersion, append, conformanceLevel);
}
示例7: AddRdfDescription
/**
* Adds information about the PDF/A conformance level to the XMP metadata.
*
* @param conformanceLevel
* @throws IOException
*/
private void AddRdfDescription(PdfAConformanceLevel conformanceLevel)
{
switch (conformanceLevel) {
case PdfAConformanceLevel.PDF_A_1A:
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "1");
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A");
break;
case PdfAConformanceLevel.PDF_A_1B:
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "1");
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B");
break;
case PdfAConformanceLevel.PDF_A_2A:
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2");
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A");
break;
case PdfAConformanceLevel.PDF_A_2B:
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2");
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B");
break;
case PdfAConformanceLevel.PDF_A_2U:
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2");
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "U");
break;
case PdfAConformanceLevel.PDF_A_3A:
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3");
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A");
break;
case PdfAConformanceLevel.PDF_A_3B:
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3");
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B");
break;
case PdfAConformanceLevel.PDF_A_3U:
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3");
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "U");
break;
case PdfAConformanceLevel.ZUGFeRD:
case PdfAConformanceLevel.ZUGFeRDBasic:
case PdfAConformanceLevel.ZUGFeRDComfort:
case PdfAConformanceLevel.ZUGFeRDExtended:
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3");
xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B");
IXmpMeta taggedExtensionMetaComfort = XmpMetaFactory.ParseFromString(getZugfredExtension(conformanceLevel));
XmpUtils.AppendProperties(taggedExtensionMetaComfort, xmpMeta, true, false);
break;
default:
break;
}
if (writer.IsTagged()) {
IXmpMeta taggedExtensionMeta = XmpMetaFactory.ParseFromString(pdfUaExtension);
XmpUtils.AppendProperties(taggedExtensionMeta, xmpMeta, true, false);
}
}
示例8: CheckStructure
public static bool CheckStructure(PdfAConformanceLevel conformanceLevel) {
return conformanceLevel == PdfAConformanceLevel.PDF_A_1A
|| conformanceLevel == PdfAConformanceLevel.PDF_A_2A
|| conformanceLevel == PdfAConformanceLevel.PDF_A_3A;
}
示例9: ZugferdChecker
protected internal ZugferdChecker(PdfAConformanceLevel conformanceLevel) : base(conformanceLevel) {
}
示例10: PdfATtfUnicodeWriter
/**
* @see TtfUnicodeWriter#TtfUnicodeWriter(PdfWriter)
*/
public PdfATtfUnicodeWriter(PdfWriter writer, PdfAConformanceLevel pdfAConformanceLevel)
: base(writer) {
this.pdfAConformanceLevel = pdfAConformanceLevel;
}
示例11: PdfAChecker
internal PdfAChecker(PdfAConformanceLevel conformanceLevel) {
keysForCheck = InitKeysForCheck();
this.conformanceLevel = conformanceLevel;
}
示例12: CreateSignature
/**
* Applies a digital signature to a document, possibly as a new revision, making
* possible multiple signatures. The returned PdfStamper
* can be used normally as the signature is only applied when closing.
* <p>
* A possible use for adding a signature without invalidating an existing one is:
* <p>
* <pre>
* KeyStore ks = KeyStore.getInstance("pkcs12");
* ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
* String alias = (String)ks.aliases().nextElement();
* PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
* Certificate[] chain = ks.getCertificateChain(alias);
* PdfReader reader = new PdfReader("original.pdf");
* FileOutputStream fout = new FileOutputStream("signed.pdf");
* PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', new
* File("/temp"), true);
* PdfSignatureAppearance sap = stp.getSignatureAppearance();
* sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
* sap.setReason("I'm the author");
* sap.setLocation("Lisbon");
* // comment next line to have an invisible signature
* sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
* stp.close();
* </pre>
* @param reader the original document
* @param os the output stream or <CODE>null</CODE> to keep the document in the temporary file
* @param pdfVersion the new pdf version or '\0' to keep the same version as the original
* document
* @param tempFile location of the temporary file. If it's a directory a temporary file will be created there.
* If it's a file it will be used directly. The file will be deleted on exit unless <CODE>os</CODE> is null.
* In that case the document can be retrieved directly from the temporary file. If it's <CODE>null</CODE>
* no temporary file will be created and memory will be used
* @param append if <CODE>true</CODE> the signature and all the other content will be added as a
* new revision thus not invalidating existing signatures
* @param conformanceLevel PDF/A conformance level of a new PDF document
* @return a <CODE>PdfAStamper</CODE>
* @throws DocumentException on error
* @throws IOException on error
*/
public static PdfAStamper CreateSignature(PdfReader reader, Stream os, char pdfVersion, String tempFile, bool append, PdfAConformanceLevel conformanceLevel)
{
PdfAStamper stp;
if (tempFile == null) {
ByteBuffer bout = new ByteBuffer();
stp = new PdfAStamper(reader, bout, pdfVersion, append, conformanceLevel);
stp.sigApp = new PdfSignatureAppearance(stp.stamper);
stp.sigApp.Sigout = bout;
} else {
if (Directory.Exists(tempFile)) {
tempFile = Path.Combine(tempFile, Path.GetTempFileName());
tempFile += ".pdf";
}
FileStream fout = new FileStream(tempFile, FileMode.Create);
stp = new PdfAStamper(reader, fout, pdfVersion, append, conformanceLevel);
stp.sigApp = new PdfSignatureAppearance(stp.stamper);
stp.sigApp.SetTempFile(tempFile);
}
stp.sigApp.Originalout = os;
stp.sigApp.SetStamper(stp);
stp.hasSignature = true;
PdfDictionary catalog = reader.Catalog;
PdfDictionary acroForm = (PdfDictionary) PdfReader.GetPdfObject(catalog.Get(PdfName.ACROFORM), catalog);
if (acroForm != null) {
acroForm.Remove(PdfName.NEEDAPPEARANCES);
stp.stamper.MarkUsed(acroForm);
}
return stp;
}
示例13: PdfAXmpWriter
/**
* Creates and XMP writer that adds info about the PDF/A conformance level.
*
* @param os
* @param info
* @param conformanceLevel
* @throws IOException
*/
public PdfAXmpWriter(Stream os, IDictionary<String, String> info, PdfAConformanceLevel conformanceLevel, PdfWriter writer)
: base(os, info)
{
this.writer = writer;
try {
AddRdfDescription(conformanceLevel);
}
catch (XmpException xmpExc) {
throw new IOException(xmpExc.Message);
}
}
示例14: getZugfredExtension
private String getZugfredExtension(PdfAConformanceLevel conformanceLevel)
{
switch (conformanceLevel) {
case PdfAConformanceLevel.ZUGFeRD:
case PdfAConformanceLevel.ZUGFeRDBasic:
return String.Format(zugferdExtension, "BASIC");
case PdfAConformanceLevel.ZUGFeRDComfort:
return String.Format(zugferdExtension, "COMFORT");
case PdfAConformanceLevel.ZUGFeRDExtended:
return String.Format(zugferdExtension, "EXTENDED");
default:
return null;
}
}
示例15: PdfASmartCopy
/**
* Constructor
*
* @param document document
* @param os outputstream
* @param conformanceLevel
*/
public PdfASmartCopy(Document document, Stream os, PdfAConformanceLevel conformanceLevel) : base(document, os, conformanceLevel) {
this.streamMap = new Dictionary<PdfSmartCopy.ByteStore, PdfIndirectReference>();
}