本文整理汇总了C#中Document.AddLanguage方法的典型用法代码示例。如果您正苦于以下问题:C# Document.AddLanguage方法的具体用法?C# Document.AddLanguage怎么用?C# Document.AddLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document
的用法示例。
在下文中一共展示了Document.AddLanguage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePdfTest
virtual public void CreatePdfTest() {
String fileName = "xmp_metadata.pdf";
// step 1
Document document = new Document();
// step 2
PdfWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT_FOLDER + fileName, FileMode.Create),
PdfAConformanceLevel.PDF_A_2B);
writer.SetTagged();
writer.CreateXmpMetadata();
XmpWriter xmp = writer.XmpWriter;
DublinCoreProperties.AddSubject(xmp.XmpMeta, "Hello World");
DublinCoreProperties.AddSubject(xmp.XmpMeta, "XMP & Metadata");
DublinCoreProperties.AddSubject(xmp.XmpMeta, "Metadata");
PdfProperties.SetKeywords(xmp.XmpMeta, "Hello World, XMP & Metadata, Metadata");
PdfProperties.SetVersion(xmp.XmpMeta, "1.4");
// step 3
document.Open();
document.AddLanguage("en_US");
// step 4
Font font = FontFactory.GetFont("../../resources/text/pdfa/FreeMonoBold.ttf", BaseFont.WINANSI,
BaseFont.EMBEDDED, 12);
document.Add(new Paragraph("Hello World", font));
FileStream iccStream = new FileStream("../../resources/text/pdfa/sRGB Color Space Profile.icm",
FileMode.Open);
ICC_Profile icc = ICC_Profile.GetInstance(iccStream);
iccStream.Close();
writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
// step 5
document.Close();
CompareResults(fileName, fileName);
}
示例2: FontCheckTest1
public void FontCheckTest1() {
bool exceptionThrown = false;
try {
Document document = new Document();
PdfAWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT + "pdfa2FontCheckTest1.pdf", FileMode.Create), PdfAConformanceLevel.PDF_A_2A);
writer.CreateXmpMetadata();
writer.SetTagged();
document.Open();
document.AddLanguage("en-US");
Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, false /*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);
document.Close();
}
catch (DocumentException) {
exceptionThrown = true;
}
catch (PdfAConformanceException) {
exceptionThrown = true;
}
if (!exceptionThrown)
Assert.Fail("PdfAConformance exception should be thrown");
}
示例3: AnnotationCheckTest11
public void AnnotationCheckTest11() {
Document document = new Document();
PdfAWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT + "annotationCheckTest11.pdf", FileMode.Create), PdfAConformanceLevel.PDF_A_2A);
writer.CreateXmpMetadata();
writer.SetTagged();
document.Open();
document.AddLanguage("en-US");
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);
PdfAnnotation annot = new PdfAnnotation(writer, new Rectangle(100, 100, 200, 200));
annot.Put(PdfName.SUBTYPE, PdfName.STAMP);
annot.Put(PdfName.F, new PdfNumber(PdfAnnotation.FLAGS_PRINT));
annot.Put(PdfName.CONTENTS, new PdfString("Hello World"));
PdfDictionary ap = new PdfDictionary();
PdfStream s = new PdfStream(Encoding.Default.GetBytes("Hello World"));
ap.Put(PdfName.N, writer.AddToBody(s).IndirectReference);
annot.Put(PdfName.AP, ap);
PdfContentByte canvas = writer.DirectContent;
canvas.AddAnnotation(annot);
document.Close();
}
示例4: PdfNamedDestinationsOverflow
public void PdfNamedDestinationsOverflow() {
Document document = new Document();
PdfAWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT + "pdfNamedDestinationsOverflow.pdf", FileMode.Create), PdfAConformanceLevel.PDF_A_1A);
writer.CreateXmpMetadata();
writer.SetTagged();
document.Open();
document.AddLanguage("en-US");
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);
PdfDocument pdf = writer.PdfDocument;
for (int i = 0; i < 8200; i++) {
PdfDestination dest = new PdfDestination(PdfDestination.FITV);
pdf.LocalDestination("action" + i, dest);
}
document.Close();
}
示例5: DeprecatedLogicTest
virtual public void DeprecatedLogicTest() {
String fileName = "xmp_metadata_deprecated.pdf";
// step 1
Document document = new Document();
// step 2
PdfWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT_FOLDER + fileName, FileMode.Create),
PdfAConformanceLevel.PDF_A_2B);
MemoryStream os = new MemoryStream();
XmpWriter xmp = new PdfAXmpWriter(os, PdfAConformanceLevel.PDF_A_2B, writer);
XmpSchema dc = new DublinCoreSchema();
XmpArray subject = new XmpArray(XmpArray.UNORDERED);
subject.Add("Hello World");
subject.Add("XMP & Metadata");
subject.Add("Metadata");
dc.SetProperty(DublinCoreSchema.SUBJECT, subject);
xmp.AddRdfDescription(dc.Xmlns, dc.ToString());
PdfSchema pdf = new PdfSchema();
pdf.AddKeywords("Hello World, XMP & Metadata, Metadata");
pdf.AddVersion("1.4");
xmp.AddRdfDescription(pdf);
xmp.Close();
writer.XmpMetadata = os.ToArray();
// step 3
document.Open();
document.AddLanguage("en_US");
// step 4
Font font = FontFactory.GetFont("../../resources/text/pdfa/FreeMonoBold.ttf", BaseFont.WINANSI,
BaseFont.EMBEDDED, 12);
document.Add(new Paragraph("Hello World", font));
FileStream iccStream = new FileStream("../../resources/text/pdfa/sRGB Color Space Profile.icm",
FileMode.Open);
ICC_Profile icc = ICC_Profile.GetInstance(iccStream);
iccStream.Close();
writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
// step 5
document.Close();
CompareResults("xmp_metadata_deprecated.pdf", fileName);
}