public static void LoadPdfUsingPlugin() { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Write("Hello world!"); doc.Save(ArtifactsDir + "PDF2Word.LoadPdfUsingPlugin.pdf"); // Use the Pdf2Word plugin to open load a PDF document as an Aspose.Words document. Document pdfDoc = new Document(); Aspose.Words.Pdf2Word.PdfDocumentReaderPlugin pdf2Word = new Aspose.Words.Pdf2Word.PdfDocumentReaderPlugin(); using (FileStream stream = new FileStream(ArtifactsDir + "PDF2Word.LoadPdfUsingPlugin.pdf", FileMode.Open)) { pdf2Word.Read(stream, new LoadOptions(), pdfDoc); } builder = new DocumentBuilder(pdfDoc); builder.MoveToDocumentEnd(); builder.Writeln(" We are editing a PDF document that was loaded into Aspose.Words!"); Assert.AreEqual("Hello world! We are editing a PDF document that was loaded into Aspose.Words!", pdfDoc.GetText().Trim()); }
public static void LoadEncryptedPdfUsingPlugin() { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("Hello world! This is an encrypted PDF document."); // Configure a SaveOptions object to encrypt this PDF document while saving it to the local file system. PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("MyPassword", string.Empty, PdfEncryptionAlgorithm.RC4_128); Assert.AreEqual(PdfPermissions.DisallowAll, encryptionDetails.Permissions); PdfSaveOptions saveOptions = new PdfSaveOptions(); saveOptions.EncryptionDetails = encryptionDetails; doc.Save(ArtifactsDir + "PDF2Word.LoadEncryptedPdfUsingPlugin.pdf", saveOptions); Document pdfDoc = new Document(); // To load a password encrypted document, we need to pass a LoadOptions object // with the correct password stored in its "Password" property. LoadOptions loadOptions = new LoadOptions(); loadOptions.Password = "******"; Aspose.Words.Pdf2Word.PdfDocumentReaderPlugin pdf2Word = new Aspose.Words.Pdf2Word.PdfDocumentReaderPlugin(); using (FileStream stream = new FileStream(ArtifactsDir + "PDF2Word.LoadEncryptedPdfUsingPlugin.pdf", FileMode.Open)) { // Pass the LoadOptions object into the Pdf2Word plugin's "Read" method // the same way we would pass it into a document's "Load" method. pdf2Word.Read(stream, new LoadOptions("MyPassword"), pdfDoc); } Assert.AreEqual("Hello world! This is an encrypted PDF document.", pdfDoc.GetText().Trim()); }
internal void Inclide() { Aspose.Words.Pdf2Word.PdfDocumentReaderPlugin pdf2Word = new Aspose.Words.Pdf2Word.PdfDocumentReaderPlugin(); }