public PdfGoToRemote(PdfFileSpec fileSpec, PdfObjectId objectId) : base(objectId) { this.fileSpec = fileSpec; this[PdfName.Names.Type] = PdfName.Names.Action; this[PdfName.Names.S] = PdfName.Names.GoToR; this[PdfName.Names.F] = fileSpec.GetReference(); this[PdfName.Names.D] = DefaultDestination; }
/// <summary> /// Adds a single /// <see cref="iText.Kernel.Pdf.Filespec.PdfFileSpec"/> /// object, which specifies XML file conforming to PLS. /// For more info see /// <see cref="GetPronunciationLexiconsList()"/> /// . /// <p>This value has meaning only for the PDF documents of version <b>2.0 and higher</b>.</p> /// </summary> /// <param name="pronunciationLexiconFileSpec"> /// a /// <see cref="iText.Kernel.Pdf.Filespec.PdfFileSpec"/> /// object, which specifies XML file conforming to PLS. /// </param> public virtual void AddPronunciationLexicon(PdfFileSpec pronunciationLexiconFileSpec) { PdfArray pronunciationLexicons = GetPdfObject().GetAsArray(PdfName.PronunciationLexicon); if (pronunciationLexicons == null) { pronunciationLexicons = new PdfArray(); VersionConforming.ValidatePdfVersionForDictEntry(GetDocument(), PdfVersion.PDF_2_0, PdfName.PronunciationLexicon , PdfName.StructTreeRoot); GetPdfObject().Put(PdfName.PronunciationLexicon, pronunciationLexicons); } pronunciationLexicons.Add(pronunciationLexiconFileSpec.GetPdfObject()); SetModified(); }
/// <summary> /// Constructs a new /// <see cref="PdfMediaClipData"/> /// wrapper around a newly created dictionary. /// </summary> /// <param name="file">the name of the file to create a media clip for</param> /// <param name="fs">a file specification that specifies the actual media data</param> /// <param name="mimeType">an ASCII string identifying the type of data</param> public PdfMediaClipData(String file, PdfFileSpec fs, String mimeType) : this(new PdfDictionary()) { PdfDictionary dic = new PdfDictionary(); MarkObjectAsIndirect(dic); dic.Put(PdfName.TF, TEMPACCESS); GetPdfObject().Put(PdfName.Type, PdfName.MediaClip); GetPdfObject().Put(PdfName.S, PdfName.MCD); GetPdfObject().Put(PdfName.N, new PdfString(MessageFormatUtil.Format("Media clip for {0}", file))); GetPdfObject().Put(PdfName.CT, new PdfString(mimeType)); GetPdfObject().Put(PdfName.P, dic); GetPdfObject().Put(PdfName.D, fs.GetPdfObject()); }
public virtual void CreatePdf(String dest) { PdfADocument pdf = new PdfADocument(new PdfWriter(dest), PdfAConformanceLevel.PDF_A_3A, new PdfOutputIntent ("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", new FileStream(INTENT, FileMode.Open, FileAccess.Read ))); Document document = new Document(pdf, PageSize.A4.Rotate()); document.SetMargins(20, 20, 20, 20); //Setting some required parameters pdf.SetTagged(); pdf.GetCatalog().SetLang(new PdfString("en-US")); pdf.GetCatalog().SetViewerPreferences(new PdfViewerPreferences().SetDisplayDocTitle(true)); PdfDocumentInfo info = pdf.GetDocumentInfo(); info.SetTitle("iText7 PDF/A-3 example"); //Add attachment PdfDictionary parameters = new PdfDictionary(); parameters.Put(PdfName.ModDate, new PdfDate().GetPdfObject()); PdfFileSpec fileSpec = PdfFileSpec.CreateEmbeddedFileSpec(pdf, File.ReadAllBytes(System.IO.Path.Combine(DATA )), "united_states.csv", "united_states.csv", new PdfName("text/csv"), parameters, PdfName.Data); fileSpec.Put(new PdfName("AFRelationship"), new PdfName("Data")); pdf.AddFileAttachment("united_states.csv", fileSpec); PdfArray array = new PdfArray(); array.Add(fileSpec.GetPdfObject().GetIndirectReference()); pdf.GetCatalog().Put(new PdfName("AF"), array); //Embed fonts PdfFont font = PdfFontFactory.CreateFont(FONT, true); PdfFont bold = PdfFontFactory.CreateFont(BOLD_FONT, true); // Create content Table table = new Table(UnitValue.CreatePercentArray(new float[] { 4, 1, 3, 4, 3, 3, 3, 3, 1 })) .UseAllAvailableWidth(); using (StreamReader sr = File.OpenText(DATA)) { String line = sr.ReadLine(); Process(table, line, bold, true); while ((line = sr.ReadLine()) != null) { Process(table, line, font, false); } } document.Add(table); //Close document document.Close(); }
public static iText.Kernel.Pdf.Action.PdfAction CreateLaunch(PdfFileSpec fileSpec, PdfWin win, bool newWindow ) { iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName. Launch).Put(PdfName.NewWindow, new PdfBoolean(newWindow)); if (fileSpec != null) { action.Put(PdfName.F, fileSpec.GetPdfObject()); } if (win != null) { action.Put(PdfName.Win, win.GetPdfObject()); } return(action); }
/// <summary> /// Creates the PDF file. /// </summary> /// <param name="xml">a byte array with XML data</param> /// <param name="html">the HTML file as a byte array</param> /// <param name="baseUri">the base URI</param> /// <param name="dest">the path to the resulting PDF</param> /// <param name="intent">a path to the output intent</param> public void CreatePdf(byte[] xml, byte[] html, String baseUri, String dest, String intent) { PdfWriter writer = new PdfWriter(dest); PdfADocument pdf = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", new FileStream(intent, FileMode.Open, FileAccess.Read))); pdf.SetTagged(); pdf.AddFileAttachment("Movie info", PdfFileSpec.CreateEmbeddedFileSpec(pdf, xml, "Movie info", "movies.xml", PdfName.ApplicationXml, new PdfDictionary(), PdfName.Data)); ConverterProperties properties = new ConverterProperties(); properties.SetBaseUri(baseUri); HtmlConverter.ConvertToPdf(new MemoryStream(html), pdf, properties); }
/// <summary> /// <p> /// Adds file associated with PDF XObject and identifies the relationship between them. /// </summary> /// <remarks> /// <p> /// Adds file associated with PDF XObject and identifies the relationship between them. /// </p> /// <p> /// Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. /// The method adds file to array value of the AF key in the XObject dictionary. /// </p> /// <p> /// For associated files their associated file specification dictionaries shall include the AFRelationship key /// </p> /// </remarks> /// <param name="fs">file specification dictionary of associated file</param> public virtual void AddAssociatedFile(PdfFileSpec fs) { if (null == ((PdfDictionary)fs.GetPdfObject()).Get(PdfName.AFRelationship)) { ILog logger = LogManager.GetLogger(typeof(iText.Kernel.Pdf.Xobject.PdfXObject)); logger.Error(iText.IO.LogMessageConstant.ASSOCIATED_FILE_SPEC_SHALL_INCLUDE_AFRELATIONSHIP); } PdfArray afArray = GetPdfObject().GetAsArray(PdfName.AF); if (afArray == null) { afArray = new PdfArray(); GetPdfObject().Put(PdfName.AF, afArray); } afArray.Add(fs.GetPdfObject()); }
private void ManipulatePdf(String dest) { PdfFont font = PdfFontFactory.CreateFont(FONT, PdfEncodings.IDENTITY_H); PdfFont bold = PdfFontFactory.CreateFont(BOLD, PdfEncodings.IDENTITY_H); Stream fileStream = new FileStream("../../../resources/data/sRGB_CS_profile.icm", FileMode.Open, FileAccess.Read); PdfADocument pdfDoc = new PdfADocument(new PdfWriter(dest), PdfAConformanceLevel.PDF_A_3B, new PdfOutputIntent("Custom", "", null, "sRGB IEC61966-2.1", fileStream)); Document document = new Document(pdfDoc, PageSize.A4.Rotate()); PdfDictionary parameters = new PdfDictionary(); parameters.Put(PdfName.ModDate, new PdfDate().GetPdfObject()); // Embeds file to the document PdfFileSpec fileSpec = PdfFileSpec.CreateEmbeddedFileSpec(pdfDoc, File.ReadAllBytes(DATA), "united_states.csv", "united_states.csv", new PdfName("text/csv"), parameters, PdfName.Data); pdfDoc.AddAssociatedFile("united_states.csv", fileSpec); Table table = new Table(UnitValue.CreatePercentArray( new float[] { 4, 1, 3, 4, 3, 3, 3, 3, 1 })).UseAllAvailableWidth(); using (StreamReader streamReader = new StreamReader(DATA)) { // Reads content of csv file String line = streamReader.ReadLine(); Process(table, line, bold, 10, true); while ((line = streamReader.ReadLine()) != null) { Process(table, line, font, 10, false); } streamReader.Close(); } document.Add(table); document.Close(); }
/// <summary> /// A /// <see cref="System.Collections.IList{E}"/> /// containing one or more /// <see cref="iText.Kernel.Pdf.Filespec.PdfFileSpec"/> /// objects, where each specified file /// is a pronunciation lexicon, which is an XML file conforming to the Pronunciation Lexicon Specification (PLS) Version 1.0. /// These pronunciation lexicons may be used as pronunciation hints when the document’s content is presented via /// text-to-speech. Where two or more pronunciation lexicons apply to the same text, the first match – as defined by /// the order of entries in the array and the order of entries inside the pronunciation lexicon file – should be used. /// <p> /// See ISO 32000-2 14.9.6, "Pronunciation hints". /// </summary> /// <returns> /// A /// <see cref="System.Collections.IList{E}"/> /// containing one or more /// <see cref="iText.Kernel.Pdf.Filespec.PdfFileSpec"/> /// . /// </returns> public virtual IList <PdfFileSpec> GetPronunciationLexiconsList() { PdfArray pronunciationLexicons = GetPdfObject().GetAsArray(PdfName.PronunciationLexicon); if (pronunciationLexicons == null) { return(JavaCollectionsUtil.EmptyList <PdfFileSpec>()); } else { IList <PdfFileSpec> lexiconsList = new List <PdfFileSpec>(pronunciationLexicons.Size()); for (int i = 0; i < pronunciationLexicons.Size(); ++i) { lexiconsList.Add(PdfFileSpec.WrapFileSpecObject(pronunciationLexicons.Get(i))); } return(lexiconsList); } }
public virtual void FileSpecCheckTest03() { NUnit.Framework.Assert.That(() => { PdfWriter writer = new PdfWriter(new MemoryStream()); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1" , @is); PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); PdfStream stream = new PdfStream(); pdfDocument.GetCatalog().Put(new PdfName("testStream"), stream); PdfFileSpec spec = PdfFileSpec.CreateEmbeddedFileSpec(pdfDocument, sourceFolder + "sample.wav", "sample.wav" , "sample", null, null, true); stream.Put(new PdfName("fileData"), spec.GetPdfObject()); pdfDocument.AddNewPage(); pdfDocument.Close(); } , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.FileSpecificationDictionaryShallNotContainTheEFKey)); ; }
/// <summary>Creates a GoToE action, or embedded file action (section 12.6.4.4 of ISO 32000-1).</summary> /// <param name="fileSpec">The root document of the target relative to the root document of the source</param> /// <param name="destination">the destination in the target to jump to</param> /// <param name="newWindow"> /// if true, the destination document should be opened in a new window; /// if false, the destination document should replace the current document in the same window /// </param> /// <param name="targetDictionary"> /// A target dictionary specifying path information to the target document. /// Each target dictionary specifies one element in the full path to the target and /// may have nested target dictionaries specifying additional elements /// </param> /// <returns>created action</returns> public static iText.Kernel.Pdf.Action.PdfAction CreateGoToE(PdfFileSpec fileSpec, PdfDestination destination , bool newWindow, PdfTarget targetDictionary) { iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName. GoToE).Put(PdfName.NewWindow, PdfBoolean.ValueOf(newWindow)); if (fileSpec != null) { action.Put(PdfName.F, fileSpec.GetPdfObject()); } if (destination != null) { action.Put(PdfName.D, destination.GetPdfObject()); } if (targetDictionary != null) { action.Put(PdfName.T, targetDictionary.GetPdfObject()); } return(action); }
public virtual void FileSpecCheckTest02() { NUnit.Framework.Assert.That(() => { PdfWriter writer = new PdfWriter(new MemoryStream()); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1" , @is); PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); PdfStream stream = new PdfStream(); pdfDocument.GetCatalog().Put(new PdfName("testStream"), stream); PdfFileSpec spec = PdfFileSpec.CreateEmbeddedFileSpec(pdfDocument, sourceFolder + "sample.wav", "sample.wav" , "sample", null, null); stream.Put(PdfName.F, spec.GetPdfObject()); pdfDocument.AddNewPage(); pdfDocument.Close(); } , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.STREAM_OBJECT_DICTIONARY_SHALL_NOT_CONTAIN_THE_F_FFILTER_OR_FDECODEPARAMS_KEYS)) ; }
/// <summary> /// <p> /// Adds file associated with structure tree root and identifies the relationship between them. /// </summary> /// <remarks> /// <p> /// Adds file associated with structure tree root and identifies the relationship between them. /// </p> /// <p> /// Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. /// The method adds file to array value of the AF key in the structure tree root dictionary. /// If description is provided, it also will add file description to catalog Names tree. /// </p> /// <p> /// For associated files their associated file specification dictionaries shall include the AFRelationship key /// </p> /// </remarks> /// <param name="description">the file description</param> /// <param name="fs">file specification dictionary of associated file</param> public virtual void AddAssociatedFile(String description, PdfFileSpec fs) { if (null == ((PdfDictionary)fs.GetPdfObject()).Get(PdfName.AFRelationship)) { ILog logger = LogManager.GetLogger(typeof(iText.Kernel.Pdf.Tagging.PdfStructTreeRoot)); logger.Error(iText.IO.LogMessageConstant.ASSOCIATED_FILE_SPEC_SHALL_INCLUDE_AFRELATIONSHIP); } if (null != description) { GetDocument().GetCatalog().GetNameTree(PdfName.EmbeddedFiles).AddEntry(description, fs.GetPdfObject()); } PdfArray afArray = GetPdfObject().GetAsArray(PdfName.AF); if (afArray == null) { afArray = new PdfArray(); GetPdfObject().Put(PdfName.AF, afArray); } afArray.Add(fs.GetPdfObject()); }
protected void ManipulatePdf(String dest) { PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest)); String embeddedFileName = "test.txt"; String embeddedFileDescription = "some_test"; byte[] embeddedFileContentBytes = Encoding.UTF8.GetBytes("Some test"); // the 5th argument is the mime-type of the embedded file; // the 6th argument is the PdfDictionary containing embedded file's parameters; // the 7th argument is the AFRelationship key value. PdfFileSpec spec = PdfFileSpec.CreateEmbeddedFileSpec(pdfDoc, embeddedFileContentBytes, embeddedFileDescription, embeddedFileName, null, null, null); // This method adds file attachment at document level. pdfDoc.AddFileAttachment("embedded_file", spec); pdfDoc.Close(); }
public virtual void FileSpecCheckTest03() { String outPdf = destinationFolder + "pdfA3b_fileSpecCheckTest03.pdf"; String cmpPdf = cmpFolder + "cmp_pdfA3b_fileSpecCheckTest03.pdf"; PdfWriter writer = new PdfWriter(outPdf); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1" , @is); PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, outputIntent); PdfPage page = pdfDocument.AddNewPage(); PdfFont font = PdfFontFactory.CreateFont(sourceFolder + "FreeSans.ttf", "WinAnsi", true); PdfCanvas canvas = new PdfCanvas(page); canvas.SaveState().BeginText().MoveText(36, 700).SetFontAndSize(font, 36).ShowText("Hello World!").EndText ().RestoreState(); byte[] somePdf = new byte[25]; pdfDocument.AddAssociatedFile("some pdf file", PdfFileSpec.CreateEmbeddedFileSpec(pdfDocument, somePdf, "some pdf file" , "foo.pdf", PdfName.ApplicationPdf, null, PdfName.Data)); pdfDocument.Close(); CompareResult(outPdf, cmpPdf); }
protected void ManipulatePdf(String dest) { PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest)); foreach (String text in ATTACHMENTS) { String embeddedFileName = String.Format("{0}.txt", text); String embeddedFileDescription = String.Format("Some test: {0}", text); byte[] embeddedFileContentBytes = Encoding.UTF8.GetBytes(embeddedFileDescription); // the 5th argument is the mime-type of the embedded file; // the 6th argument is the PdfDictionary containing embedded file's parameters; // the 7th argument is the AFRelationship key value. PdfFileSpec spec = PdfFileSpec.CreateEmbeddedFileSpec(pdfDoc, embeddedFileContentBytes, embeddedFileDescription, embeddedFileName, null, null, null); // This method adds file attachment at document level. pdfDoc.AddFileAttachment(String.Format("embedded_file{0}", text), spec); } pdfDoc.Close(); }
public virtual void FileSpecCheckTest03() { PdfWriter writer = new PdfWriter(new MemoryStream()); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1" , @is); PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); PdfPage page = pdfDocument.AddNewPage(); PdfFont font = PdfFontFactory.CreateFont(sourceFolder + "FreeSans.ttf", "WinAnsi", true); PdfCanvas canvas = new PdfCanvas(page); canvas.SaveState().BeginText().MoveText(36, 700).SetFontAndSize(font, 36).ShowText("Hello World!").EndText ().RestoreState(); MemoryStream txt = new MemoryStream(); StreamWriter @out = new StreamWriter(txt); @out.Write("<foo><foo2>Hello world</foo2></foo>"); @out.Dispose(); pdfDocument.AddFileAttachment("foo file", PdfFileSpec.CreateEmbeddedFileSpec(pdfDocument, txt.ToArray(), "foo file" , "foo.xml", PdfName.ApplicationXml, null, PdfName.Source)); pdfDocument.Close(); }
public virtual void EmbeddedFileAddedInAppendModeTest() { //Create input document MemoryStream boasEmpty = new MemoryStream(); PdfWriter emptyDocWriter = new PdfWriter(boasEmpty); PdfDocument emptyDoc = new PdfDocument(emptyDocWriter); emptyDoc.AddNewPage(); PdfDictionary emptyNamesDic = new PdfDictionary(); emptyNamesDic.MakeIndirect(emptyDoc); emptyDoc.GetCatalog().GetPdfObject().Put(PdfName.Names, emptyNamesDic); emptyDoc.Close(); //Create input document MemoryStream boasAttached = new MemoryStream(); PdfWriter attachDocWriter = new PdfWriter(boasAttached); PdfDocument attachDoc = new PdfDocument(attachDocWriter); attachDoc.AddNewPage(); attachDoc.Close(); //Attach file in append mode PdfReader appendReader = new PdfReader(new MemoryStream(boasEmpty.ToArray())); MemoryStream boasAppend = new MemoryStream(); PdfWriter appendWriter = new PdfWriter(boasAppend); PdfDocument appendDoc = new PdfDocument(appendReader, appendWriter, new StampingProperties().UseAppendMode ()); appendDoc.AddFileAttachment("Test File", PdfFileSpec.CreateEmbeddedFileSpec(appendDoc, boasAttached.ToArray (), "Append Embedded File test", "Test file", null)); appendDoc.Close(); //Check final result PdfReader finalReader = new PdfReader(new MemoryStream(boasAppend.ToArray())); PdfDocument finalDoc = new PdfDocument(finalReader); PdfNameTree embeddedFilesNameTree = finalDoc.GetCatalog().GetNameTree(PdfName.EmbeddedFiles); IDictionary <String, PdfObject> embeddedFilesMap = embeddedFilesNameTree.GetNames(); NUnit.Framework.Assert.IsTrue(embeddedFilesMap.Count > 0); NUnit.Framework.Assert.IsTrue(embeddedFilesMap.ContainsKey("Test File")); }
private void CreateWrapper(String encryptedName, String wrapperName, String cryptoFilter) { String inPath = sourceFolder + "cmp_" + encryptedName; String cmpPath = sourceFolder + "cmp_" + wrapperName; String outPath = destinationFolder + wrapperName; String diff = "diff_" + wrapperName + "_"; PdfDocument document = new PdfDocument(new PdfWriter(outPath, new WriterProperties().SetPdfVersion(PdfVersion .PDF_2_0))); PdfFileSpec fs = PdfEncryptedPayloadFileSpecFactory.Create(document, inPath, new PdfEncryptedPayload(cryptoFilter )); document.SetEncryptedPayload(fs); PdfFont font = PdfFontFactory.CreateFont(); PdfCanvas canvas = new PdfCanvas(document.AddNewPage()); canvas.SaveState().BeginText().MoveText(36, 750).SetFontAndSize(font, 30).ShowText("Hi! I'm wrapper document." ).EndText().RestoreState(); canvas.Release(); document.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPath, cmpPath, destinationFolder, diff )); }
public virtual void FileSpecNonConformingTest01() { // According to spec, only pdfa-1 or pdfa-2 compliant pdf document are allowed to be added to the // conforming pdfa-2 document. We only check they mime type, to define embedded file type, but we don't check // the bytes of the file. That's why this test creates invalid pdfa document. String outPdf = destinationFolder + "pdfA2b_fileSpecNonConformingTest01.pdf"; String cmpPdf = cmpFolder + "cmp_pdfA2b_fileSpecNonConformingTest01.pdf"; PdfWriter writer = new PdfWriter(outPdf); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1" , @is); PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); PdfPage page = pdfDocument.AddNewPage(); PdfFont font = PdfFontFactory.CreateFont(sourceFolder + "FreeSans.ttf", "WinAnsi", true); PdfCanvas canvas = new PdfCanvas(page); canvas.SaveState().BeginText().MoveText(36, 700).SetFontAndSize(font, 36).ShowText("Hello World!").EndText ().RestoreState(); byte[] somePdf = new byte[25]; pdfDocument.AddAssociatedFile("some pdf file", PdfFileSpec.CreateEmbeddedFileSpec(pdfDocument, somePdf, "some pdf file" , "foo.pdf", PdfName.ApplicationPdf, null, new PdfName("Data"))); pdfDocument.Close(); CompareResult(outPdf, cmpPdf); }
public virtual void FileSpecCheckTest01() { NUnit.Framework.Assert.That(() => { PdfWriter writer = new PdfWriter(new MemoryStream()); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1" , @is); PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); PdfDictionary fileNames = new PdfDictionary(); pdfDocument.GetCatalog().Put(PdfName.Names, fileNames); PdfDictionary embeddedFiles = new PdfDictionary(); fileNames.Put(PdfName.EmbeddedFiles, embeddedFiles); PdfArray names = new PdfArray(); fileNames.Put(PdfName.Names, names); names.Add(new PdfString("some/file/path")); PdfFileSpec spec = PdfFileSpec.CreateEmbeddedFileSpec(pdfDocument, sourceFolder + "sample.wav", "sample.wav" , "sample", null, null); names.Add(spec.GetPdfObject()); pdfDocument.AddNewPage(); pdfDocument.Close(); } , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.A_NAME_DICTIONARY_SHALL_NOT_CONTAIN_THE_EMBEDDED_FILES_KEY)) ; }
public static iText.Kernel.Pdf.Action.PdfAction CreateLaunch(PdfFileSpec fileSpec, bool newWindow) { return(CreateLaunch(fileSpec, null, newWindow)); }
/// <summary>Gets file specification identifying the schema file, which defines this namespace.</summary> /// <returns> /// a /// <see cref="iText.Kernel.Pdf.Filespec.PdfFileSpec"/> /// identifying the schema file. /// </returns> public virtual PdfFileSpec GetSchema() { PdfObject schemaObject = GetPdfObject().Get(PdfName.Schema); return(PdfFileSpec.WrapFileSpecObject(schemaObject)); }
/// <summary>Sets file specification identifying the schema file, which defines this namespace.</summary> /// <param name="fileSpec"> /// a /// <see cref="iText.Kernel.Pdf.Filespec.PdfFileSpec"/> /// identifying the schema file. /// </param> /// <returns> /// this /// <see cref="PdfNamespace"/> /// instance. /// </returns> public virtual iText.Kernel.Pdf.Tagging.PdfNamespace SetSchema(PdfFileSpec fileSpec) { return(Put(PdfName.Schema, fileSpec.GetPdfObject())); }
public PdfEncryptedPayloadDocument(PdfStream pdfObject, PdfFileSpec fileSpec, String name) : base(pdfObject) { this.fileSpec = fileSpec; this.name = name; }
/// <summary>Creates a Thread action (section 12.6.4.6 of ISO 32000-1).</summary> /// <remarks> /// Creates a Thread action (section 12.6.4.6 of ISO 32000-1). /// A thread action jumps to a specified bead on an article thread (see 12.4.3, "Articles"), /// in either the current document or a different one. Table 205 shows the action dictionary /// entries specific to this type of action. /// </remarks> /// <param name="fileSpec">the file containing the thread. If this entry is absent, the thread is in the current file /// </param> /// <returns>created action</returns> public static iText.Kernel.Pdf.Action.PdfAction CreateThread(PdfFileSpec fileSpec) { return(CreateThread(fileSpec, null, null)); }
/// <summary>Creates a Launch action (section 12.6.4.5 of ISO 32000-1).</summary> /// <param name="fileSpec">the application that shall be launched or the document that shall beopened or printed /// </param> /// <param name="newWindow">a flag specifying whether to open the destination document in a new window</param> /// <returns>created action</returns> public static iText.Kernel.Pdf.Action.PdfAction CreateLaunch(PdfFileSpec fileSpec, bool newWindow) { return(CreateLaunch(fileSpec).Put(PdfName.NewWindow, new PdfBoolean(newWindow))); }
/// <summary>Creates a GoToR action, or remote action (section 12.6.4.3 of ISO 32000-1).</summary> /// <param name="fileSpec">the file in which the destination shall be located</param> /// <param name="destination">the destination in the remote document to jump to</param> /// <param name="newWindow">a flag specifying whether to open the destination document in a new window</param> /// <returns>created action</returns> public static iText.Kernel.Pdf.Action.PdfAction CreateGoToR(PdfFileSpec fileSpec, PdfDestination destination , bool newWindow) { return(CreateGoToR(fileSpec, destination).Put(PdfName.NewWindow, PdfBoolean.ValueOf(newWindow))); }
public PdfFileAttachmentAnnotation(Rectangle rect, PdfFileSpec file) : this(rect) { Put(PdfName.FS, file.GetPdfObject()); }
public static iText.Kernel.Pdf.Action.PdfAction CreateGoToR(PdfFileSpec fileSpec, PdfDestination destination ) { return(new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.GoToR).Put(PdfName.F, fileSpec.GetPdfObject ()).Put(PdfName.D, destination.GetPdfObject())); }
/// <summary> /// <p> /// Adds file associated with structure tree root and identifies the relationship between them. /// </summary> /// <remarks> /// <p> /// Adds file associated with structure tree root and identifies the relationship between them. /// </p> /// <p> /// Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. /// The method adds file to array value of the AF key in the structure tree root dictionary. /// </p> /// <p> /// For associated files their associated file specification dictionaries shall include the AFRelationship key /// </p> /// </remarks> /// <param name="fs">file specification dictionary of associated file</param> public virtual void AddAssociatedFile(PdfFileSpec fs) { AddAssociatedFile(null, fs); }