public static void Run() { // ExStart:SetExpiryDate // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Instantiate Document object Aspose.Pdf.Document doc = new Aspose.Pdf.Document(); // Add page to pages collection of PDF file doc.Pages.Add(); // Add text fragment to paragraphs collection of page object doc.Pages[1].Paragraphs.Add(new TextFragment("Hello World...")); // Create JavaScript object to set PDF expiry date JavascriptAction javaScript = new JavascriptAction( "var year=2017;" + "var month=5;" + "today = new Date(); today = new Date(today.getFullYear(), today.getMonth());" + "expiry = new Date(year, month);" + "if (today.getTime() > expiry.getTime())" + "app.alert('The file is expired. You need a new one.');"); // Set JavaScript as PDF open action doc.OpenAction = javaScript; dataDir = dataDir + "SetExpiryDate_out.pdf"; // Save PDF Document doc.Save(dataDir); // ExEnd:SetExpiryDate Console.WriteLine("\nPDF expiry date setup successfully.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:PreserveRights // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Forms(); // Read the source PDF form with FileAccess of Read and Write. // We need ReadWrite permission because after modification, // we need to save the updated contents in same document/file. FileStream fs = new FileStream(dataDir + "input.pdf", FileMode.Open, FileAccess.ReadWrite); // Instantiate Document instance Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(fs); // Get values from all fields foreach (Field formField in pdfDocument.Form) { // If the fullname of field contains A1, perform the operation if (formField.FullName.Contains("A1")) { // Cast form field as TextBox TextBoxField textBoxField = formField as TextBoxField; // Modify field value textBoxField.Value = "Testing"; } } // Save the updated document in save FileStream pdfDocument.Save(); // Close the File Stream object fs.Close(); // ExEnd:PreserveRights }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // Open document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir+ @"input.pdf"); // Create ImagePlacementAbsorber object to perform image placement search ImagePlacementAbsorber abs = new ImagePlacementAbsorber(); // Accept the absorber for all the pages doc.Pages.Accept(abs); //Loop through all ImagePlacements, get image and ImagePlacement Properties foreach (ImagePlacement imagePlacement in abs.ImagePlacements) { //Get the image using ImagePlacement object XImage image = imagePlacement.Image; //Display image placement properties for all placements Console.Out.WriteLine("image width:" + imagePlacement.Rectangle.Width); Console.Out.WriteLine("image height:" + imagePlacement.Rectangle.Height); Console.Out.WriteLine("image LLX:" + imagePlacement.Rectangle.LLX); Console.Out.WriteLine("image LLY:" + imagePlacement.Rectangle.LLY); Console.Out.WriteLine("image horizontal resolution:" + imagePlacement.Resolution.X); Console.Out.WriteLine("image vertical resolution:" + imagePlacement.Resolution.Y); } }
internal void Add(string file, string password) { var document = new AsposePdf.Document(file); dynamic permissions = document.Permissions; document.Encrypt(password, OptionApi.GetEncrypted("PDFDefaultOwnerPassword", "?|2^&(*$:@!!*"),(AsposePdf.Permissions) permissions, AsposePdf.CryptoAlgorithm.RC4x40); document.Save(file); }
public static void Run() { // ExStart:ExtractFilesFromPortfolio // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_TechnicalArticles(); // Load source PDF Portfolio Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(dataDir + "PDFPortfolio.pdf"); // Get collection of embedded files EmbeddedFileCollection embeddedFiles = pdfDocument.EmbeddedFiles; // Itterate through individual file of Portfolio foreach (FileSpecification fileSpecification in embeddedFiles) { // Get the attachment and write to file or stream byte[] fileContent = new byte[fileSpecification.Contents.Length]; fileSpecification.Contents.Read(fileContent, 0, fileContent.Length); string filename = Path.GetFileName(fileSpecification.Name); // Save the extracted file to some location FileStream fileStream = new FileStream(dataDir + "_out" + filename, FileMode.Create); fileStream.Write(fileContent, 0, fileContent.Length); // Close the stream object fileStream.Close(); } // ExEnd:ExtractFilesFromPortfolio }
public static void Run() { // ExStart:GetFieldsFromRegion // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Forms(); // Open pdf file Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "GetFieldsFromRegion.pdf"); // Create rectangle object to get fields in that area Aspose.Pdf.Rectangle rectangle = new Aspose.Pdf.Rectangle(35, 30, 500, 500); // Get the PDF form Aspose.Pdf.Forms.Form form = doc.Form; // Get fields in the rectangular area Aspose.Pdf.Forms.Field[] fields = form.GetFieldsInRect(rectangle); // Display Field names and values foreach (Field field in fields) { // Display image placement properties for all placements Console.Out.WriteLine("Field Name: " + field.FullName + "-" + "Field Value: " + field.Value); } // ExEnd:GetFieldsFromRegion }
private byte[] MergeFile(IList <byte[]> files) { var mergedDocument = new Document(); var streams = new List <MemoryStream>(); foreach (var fileInfo in files) { var stream = new MemoryStream(fileInfo); var document = new Document(stream); for (var page = 1; page <= document.Pages.Count; page++) { mergedDocument.Pages.Add(document.Pages[page]); } streams.Add(stream); } //// Save merged document. using (MemoryStream output = new MemoryStream()) { mergedDocument.Save(output, SaveFormat.Pdf); foreach (var stream in streams) { stream.Close(); stream.Dispose(); } return(output.ToArray()); } }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // Open document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + @"input.pdf"); // Create ImagePlacementAbsorber object to perform image placement search ImagePlacementAbsorber abs = new ImagePlacementAbsorber(); // Accept the absorber for all the pages doc.Pages.Accept(abs); //Loop through all ImagePlacements, get image and ImagePlacement Properties foreach (ImagePlacement imagePlacement in abs.ImagePlacements) { //Get the image using ImagePlacement object XImage image = imagePlacement.Image; //Display image placement properties for all placements Console.Out.WriteLine("image width:" + imagePlacement.Rectangle.Width); Console.Out.WriteLine("image height:" + imagePlacement.Rectangle.Height); Console.Out.WriteLine("image LLX:" + imagePlacement.Rectangle.LLX); Console.Out.WriteLine("image LLY:" + imagePlacement.Rectangle.LLY); Console.Out.WriteLine("image horizontal resolution:" + imagePlacement.Resolution.X); Console.Out.WriteLine("image vertical resolution:" + imagePlacement.Resolution.Y); } }
public static void Run() { // ExStart:EmbedFontWhileDocCreation // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Instantiate Pdf object by calling its empty constructor Aspose.Pdf.Document doc = new Aspose.Pdf.Document(); // Create a section in the Pdf object Aspose.Pdf.Page page = doc.Pages.Add(); Aspose.Pdf.Text.TextFragment fragment = new Aspose.Pdf.Text.TextFragment(""); Aspose.Pdf.Text.TextSegment segment = new Aspose.Pdf.Text.TextSegment(" This is a sample text using Custom font."); Aspose.Pdf.Text.TextState ts = new Aspose.Pdf.Text.TextState(); ts.Font = FontRepository.FindFont("Arial"); ts.Font.IsEmbedded = true; segment.TextState = ts; fragment.Segments.Add(segment); page.Paragraphs.Add(fragment); dataDir = dataDir + "EmbedFontWhileDocCreation_out.pdf"; // Save PDF Document doc.Save(dataDir); // ExEnd:EmbedFontWhileDocCreation Console.WriteLine("\nFont embedded successfully in a PDF file.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:EmbedFontWhileDocCreation // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Instantiate Pdf object by calling its empty constructor Aspose.Pdf.Document doc = new Aspose.Pdf.Document(); // Create a section in the Pdf object Aspose.Pdf.Page page = doc.Pages.Add(); Aspose.Pdf.Text.TextFragment fragment = new Aspose.Pdf.Text.TextFragment(""); Aspose.Pdf.Text.TextSegment segment = new Aspose.Pdf.Text.TextSegment(" This is a sample text using Custom font."); Aspose.Pdf.Text.TextState ts = new Aspose.Pdf.Text.TextState(); ts.Font = FontRepository.FindFont("Arial"); ts.Font.IsEmbedded = true; segment.TextState = ts; fragment.Segments.Add(segment); page.Paragraphs.Add(fragment); dataDir = dataDir + "EmbedFontWhileDocCreation_out_.pdf"; // Save PDF Document doc.Save(dataDir); // ExEnd:EmbedFontWhileDocCreation Console.WriteLine("\nFont embedded successfully in a PDF file.\nFile saved at " + dataDir); }
private void GenerateTicket() { var pdf = new Aspose.Pdf.Document(); //Add a page to the document var pdfTicketPage = pdf.Pages.Add(); var strBody = Session["TicketBody"].ToString(); var fragment = new Aspose.Pdf.Text.TextFragment(strBody.ToString()); pdfTicketPage.Paragraphs.Add(fragment); DirectoryInfo dir = new DirectoryInfo(@"D:\Images\"); FileInfo fileInfo = dir.GetFiles("*.jpg").FirstOrDefault(); FileStream stream = new FileStream(fileInfo.FullName, FileMode.Open); System.Drawing.Image img = new System.Drawing.Bitmap(stream); var image = new Aspose.Pdf.Image { ImageStream = stream }; image.FixHeight = 125; image.FixWidth = 300; image.Margin = new MarginInfo(5, 5, 5, 5); pdfTicketPage.Paragraphs.Add(image); pdf.Save(@"D:\Images\Ticket.pdf"); sendEmail(); }
private void RemoveFooter(Aspose.Pdf.Document pdfDoc) { try { for (int i = 1; i <= pdfDoc.Pages.Count; i++) { Page page = pdfDoc.Pages[i]; Aspose.Pdf.Rectangle rect = new Aspose.Pdf.Rectangle(0, 75, page.Rect.Width, 1); RedactionAnnotation annot = new RedactionAnnotation(page, rect); annot.FillColor = Aspose.Pdf.Color.White; annot.BorderColor = Aspose.Pdf.Color.Yellow; annot.Color = Aspose.Pdf.Color.White; annot.TextAlignment = Aspose.Pdf.HorizontalAlignment.Center; page.Annotations.Add(annot); annot.Redact(); TextAbsorber textAbsorber = new TextAbsorber(); pdfDoc.Pages[i].Accept(textAbsorber); } } catch (Exception ex) { throw ex; } }
public static void Run() { // ExStart:AddTable // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Tables(); // Load source PDF document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "AddTable.pdf"); // Initializes a new instance of the Table Aspose.Pdf.Table table = new Aspose.Pdf.Table(); // Set the table border color as LightGray table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray)); // Set the border for table cells table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray)); // Create a loop to add 10 rows for (int row_count = 1; row_count < 10; row_count++) { // Add row to table Aspose.Pdf.Row row = table.Rows.Add(); // Add table cells row.Cells.Add("Column (" + row_count + ", 1)"); row.Cells.Add("Column (" + row_count + ", 2)"); row.Cells.Add("Column (" + row_count + ", 3)"); } // Add table object to first page of input document doc.Pages[1].Paragraphs.Add(table); dataDir = dataDir + "document_with_table_out.pdf"; // Save updated document containing table object doc.Save(dataDir); // ExEnd:AddTable Console.WriteLine("\nText added successfully to an existing pdf file.\nFile saved at " + dataDir); }
/// <summary> /// Written by Fredio /// </summary> /// <param name="path"></param> /// <param name="phrase"></param> /// <returns></returns> public System.IO.MemoryStream SearcText(string path, string phrase) { InjectAsposeLicemse(); Aspose.Pdf.Document document = new Aspose.Pdf.Document(path); string searchTextValue = string.Format("(?i){0}", phrase); TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(searchTextValue, new TextSearchOptions(true)); //TextSearchOptions textSearchOptions = new TextSearchOptions(true); //textFragmentAbsorber.TextSearchOptions = textSearchOptions; document.Pages.Accept(textFragmentAbsorber); TextFragmentCollection textFragmentCollection1 = textFragmentAbsorber.TextFragments; if (textFragmentCollection1.Count > 0) { foreach (TextFragment textFragment in textFragmentCollection1) { Aspose.Pdf.Annotations.HighlightAnnotation freeText = new Aspose.Pdf.Annotations.HighlightAnnotation(textFragment.Page, new Aspose.Pdf.Rectangle(textFragment.Position.XIndent, textFragment.Position.YIndent, textFragment.Position.XIndent + textFragment.Rectangle.Width, textFragment.Position.YIndent + textFragment.Rectangle.Height)); freeText.Opacity = 0.5; //freeText.Color = Aspose.Pdf.Color.FromRgb(0.6, 0.8, 0.98); freeText.Color = Aspose.Pdf.Color.Yellow; textFragment.Page.Annotations.Add(freeText); } } System.IO.MemoryStream ms = new System.IO.MemoryStream(); document.Save(ms); return(ms); }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); //Open pdf file Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "input.pdf"); //Create rectangle object to get fields in that area Aspose.Pdf.Rectangle rectangle = new Aspose.Pdf.Rectangle(35, 30, 500, 500); //Get the PDF form Aspose.Pdf.InteractiveFeatures.Forms.Form form = doc.Form; //get fields in the rectangular area Aspose.Pdf.InteractiveFeatures.Forms.Field[] fields = form.GetFieldsInRect(rectangle); //Display Field names and values foreach (Field field in fields) { //Display image placement properties for all placements Console.Out.WriteLine("Field Name: " + field.FullName + "-" + "Field Value: " + field.Value); } }
public string Converter(string path, string extension) { string reuturnString = string.Empty; // Save the document to a MemoryStream object. MemoryStream stream = new MemoryStream(); switch (extension) { case ".pdf": Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(path); pdfDoc.Save(HttpContext.Current.Server.MapPath("Input/input.html"), Aspose.Pdf.SaveFormat.Html); break; case ".doc": case ".docx": case ".txt": case ".rtf": { //// Load in the document Aspose.Words.Document doc = new Aspose.Words.Document(path); doc.Save(HttpContext.Current.Server.MapPath("Input/input.html"), Aspose.Words.SaveFormat.Html); break; } } reuturnString = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("Input/input.html")); return(reuturnString); }
public bool AddDigitalSignature(Pages PageObj, List <ImageSignParameters> ImgParamObj) { var pdfDocument = new Aspose.Pdf.Document(PageObj.FilePath); foreach (ImageSignParameters obj in ImgParamObj) { //add image signature parameters to database _documentRepository.AddSignatureToDB(obj); Stream stream = new MemoryStream(obj.ImageStream); ImageStamp imageStamp = new ImageStamp(stream); imageStamp.Background = true; // imageStamp.VerticalAlignment = VerticalAlignment.Top; imageStamp.XIndent = obj.XIndent; imageStamp.YIndent = obj.YIndent; imageStamp.Height = obj.Height; imageStamp.Width = obj.Width; imageStamp.Opacity = obj.Opacity; pdfDocument.Pages[obj.PageNumber].AddStamp(imageStamp); } pdfDocument.Save(string.Format("D:\\ElectronicSignaturesService\\BusinessLogic\\Files\\Sign1{0}.pdf", DateTime.Now.Ticks)); return(true); }
public static void Run() { // ExStart:PreserveRights // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Forms(); // Read the source PDF form with FileAccess of Read and Write. // We need ReadWrite permission because after modification, // We need to save the updated contents in same document/file. FileStream fs = new FileStream(dataDir + "input.pdf", FileMode.Open, FileAccess.ReadWrite); // Instantiate Document instance Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(fs); // Get values from all fields foreach (Field formField in pdfDocument.Form) { // If the fullname of field contains A1, perform the operation if (formField.FullName.Contains("A1")) { // Cast form field as TextBox TextBoxField textBoxField = formField as TextBoxField; // Modify field value textBoxField.Value = "Testing"; } } // Save the updated document in save FileStream pdfDocument.Save(); // Close the File Stream object fs.Close(); // ExEnd:PreserveRights }
public static void Run() { // ExStart:SearchAndGetImages // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Images(); // Open document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "SearchAndGetImages.pdf"); // Create ImagePlacementAbsorber object to perform image placement search ImagePlacementAbsorber abs = new ImagePlacementAbsorber(); // Accept the absorber for all the pages doc.Pages.Accept(abs); // Loop through all ImagePlacements, get image and ImagePlacement Properties foreach (ImagePlacement imagePlacement in abs.ImagePlacements) { // Get the image using ImagePlacement object XImage image = imagePlacement.Image; // Display image placement properties for all placements Console.Out.WriteLine("image width:" + imagePlacement.Rectangle.Width); Console.Out.WriteLine("image height:" + imagePlacement.Rectangle.Height); Console.Out.WriteLine("image LLX:" + imagePlacement.Rectangle.LLX); Console.Out.WriteLine("image LLY:" + imagePlacement.Rectangle.LLY); Console.Out.WriteLine("image horizontal resolution:" + imagePlacement.Resolution.X); Console.Out.WriteLine("image vertical resolution:" + imagePlacement.Resolution.Y); } // ExEnd:SearchAndGetImages }
/// <summary> /// 將 PDF 加上 浮水印 /// </summary> /// <param name="pdfStream"></param> /// <param name="arg"></param> /// <returns></returns> public static MemoryStream AddWatermark(MemoryStream pdfStream, WatermarkArg arg) { var pdfDocument = new Aspose.Pdf.Document(pdfStream); if (!string.IsNullOrWhiteSpace(arg.Watermark)) { var text = new FormattedText(arg.Watermark); foreach (var page in pdfDocument.Pages) { switch (arg.WMStyle) { case WatermarkStyle.FitPage: AddWatermarkFitPage(page, arg); break; case WatermarkStyle.RepeatHorizontal: AddWatermarkRepeatHorizontal(page, arg); break; default: break; } } } var newPdfStream = new MemoryStream(); pdfDocument.Save(newPdfStream); return(newPdfStream); }
private void ParsePDF(ref FileObject fo, string filePath) { Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(filePath); PdfFileInfo pi = new PdfFileInfo(pdfDocument); PdfExtractor pe = new PdfExtractor(pdfDocument); ImagePlacementAbsorber abs = new ImagePlacementAbsorber(); fo.pageCount = pi.NumberOfPages; fo.embeddedDocsCount = pdfDocument.EmbeddedFiles.Count; pdfDocument.Pages.Accept(abs); fo.imageCount = abs.ImagePlacements.Count; fo.hasPassword = pi.HasOpenPassword; pe.ExtractText(Encoding.ASCII); string tmpFolderToExtract = tmpFolder + "\\" + Guid.NewGuid(); Directory.CreateDirectory(tmpFolderToExtract); string tmpTextFile = tmpFolderToExtract + "\\" + "tmpTextexport.txt"; pe.GetText(tmpTextFile); fo.wordCount = GetWordCount(tmpTextFile); fo.characterCount = GetCharCount(tmpTextFile); if (File.Exists(tmpTextFile)) { File.Delete(tmpTextFile); } if (Directory.Exists(tmpFolderToExtract)) { Directory.Delete(tmpFolderToExtract); } }
public static void Run() { // ExStart:SearchAndGetImages // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Images(); // Open document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir+ "SearchAndGetImages.pdf"); // Create ImagePlacementAbsorber object to perform image placement search ImagePlacementAbsorber abs = new ImagePlacementAbsorber(); // Accept the absorber for all the pages doc.Pages.Accept(abs); // Loop through all ImagePlacements, get image and ImagePlacement Properties foreach (ImagePlacement imagePlacement in abs.ImagePlacements) { // Get the image using ImagePlacement object XImage image = imagePlacement.Image; // Display image placement properties for all placements Console.Out.WriteLine("image width:" + imagePlacement.Rectangle.Width); Console.Out.WriteLine("image height:" + imagePlacement.Rectangle.Height); Console.Out.WriteLine("image LLX:" + imagePlacement.Rectangle.LLX); Console.Out.WriteLine("image LLY:" + imagePlacement.Rectangle.LLY); Console.Out.WriteLine("image horizontal resolution:" + imagePlacement.Resolution.X); Console.Out.WriteLine("image vertical resolution:" + imagePlacement.Resolution.Y); } // ExEnd:SearchAndGetImages }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // Load source PDF document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "input.pdf"); // Initializes a new instance of the Table Aspose.Pdf.Table table = new Aspose.Pdf.Table(); // Set the table border color as LightGray table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray)); // set the border for table cells table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray)); // create a loop to add 10 rows for (int row_count = 1; row_count < 10; row_count++) { // add row to table Aspose.Pdf.Row row = table.Rows.Add(); // add table cells row.Cells.Add("Column (" + row_count + ", 1)"); row.Cells.Add("Column (" + row_count + ", 2)"); row.Cells.Add("Column (" + row_count + ", 3)"); } // Add table object to first page of input document doc.Pages[1].Paragraphs.Add(table); // Save updated document containing table object doc.Save(dataDir + "document_with_table.pdf"); }
private static void CreateTemplate(SkuPdfModel model) { var pdfDocument = new Document(); using var imageStore = new ImageStore(); var page = pdfDocument.Pages.Add(); // Header Table var headerTable = CreateHeaderTable(model, imageStore); page.Paragraphs.Add(headerTable); // Characteristic Table var characteristicTable = CreateCharacteristicTable(model); page.Paragraphs.Add(characteristicTable); // Classification Table var classificationTable = CreateClassificationTable(model); page.Paragraphs.Add(classificationTable); // Classification Table var supplierOffersTable = CreateSupplierOffersTable(model); page.Paragraphs.Add(supplierOffersTable); using var resultStream = File.Open("D:\\WorkAsposeFiles\\template.pdf", FileMode.Create); pdfDocument.Save(resultStream, SaveFormat.Pdf); }
public static string TestRead() { var path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "TestReadGAC.pdf"); Document pdfDocument = new Aspose.Pdf.Document(path); // instantiate TextFragment Absorber object Aspose.Pdf.Text.TextFragmentAbsorber TextFragmentAbsorberAddress = new Aspose.Pdf.Text.TextFragmentAbsorber(); // search text within page bound TextFragmentAbsorberAddress.TextSearchOptions.LimitToPageBounds = true; // specify the page region for TextSearch Options TextFragmentAbsorberAddress.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle(0, 0, 600, 800); // search text from first page of PDF file pdfDocument.Pages[1].Accept(TextFragmentAbsorberAddress); List <string> l = new List <string>(); foreach (Aspose.Pdf.Text.TextFragment tf in TextFragmentAbsorberAddress.TextFragments) { l.Add(tf.Text); } if (l.Count > 0) { return(l[0]); } else { return(string.Empty); } }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // Load the source PDF document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir+ "input.pdf"); ImagePlacementAbsorber abs = new ImagePlacementAbsorber(); // Load the contents of first page doc.Pages[1].Accept(abs); foreach (ImagePlacement imagePlacement in abs.ImagePlacements) { // Get image properties Console.Out.WriteLine("image width:" + imagePlacement.Rectangle.Width); Console.Out.WriteLine("image height:" + imagePlacement.Rectangle.Height); Console.Out.WriteLine("image LLX:" + imagePlacement.Rectangle.LLX); Console.Out.WriteLine("image LLY:" + imagePlacement.Rectangle.LLY); Console.Out.WriteLine("image horizontal resolution:" + imagePlacement.Resolution.X); Console.Out.WriteLine("image vertical resolution:" + imagePlacement.Resolution.Y); // Retrieve image with visible dimensions Bitmap scaledImage; using (MemoryStream imageStream = new MemoryStream()) { // Retrieve image from resources imagePlacement.Image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png); Bitmap resourceImage = (Bitmap)Bitmap.FromStream(imageStream); // Create bitmap with actual dimensions scaledImage = new Bitmap(resourceImage, (int)imagePlacement.Rectangle.Width, (int)imagePlacement.Rectangle.Height); } } }
private bool MergeFiles() { try { SortedDictionary <int, ZaradekFinishDoc> mergingFiles = new SortedDictionary <int, ZaradekFinishDoc>(mergableFiles); Aspose.Pdf.Document masterDoc = new Aspose.Pdf.Document(); bool isFirst = true; foreach (int filePosition in mergingFiles.Keys) { if (isFirst) { isFirst = false; masterDoc = new Aspose.Pdf.Document(mergingFiles[filePosition].filePDF); } else { Aspose.Pdf.Document addPDFDoc = new Aspose.Pdf.Document(mergingFiles[filePosition].filePDF); masterDoc.Pages.Add(addPDFDoc.Pages); } } masterDoc.Save(tempFile); } catch (Exception ex) { Log.AddLog("A PDF fájlok összefűzése közben hiba történt - " + ex.Message, true); return(false); } return(true); }
public static void Run() { // ExStart:AddTable // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Tables(); // Load source PDF document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir+ "AddTable.pdf"); // Initializes a new instance of the Table Aspose.Pdf.Table table = new Aspose.Pdf.Table(); // Set the table border color as LightGray table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray)); // Set the border for table cells table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray)); // Create a loop to add 10 rows for (int row_count = 1; row_count < 10; row_count++) { // Add row to table Aspose.Pdf.Row row = table.Rows.Add(); // Add table cells row.Cells.Add("Column (" + row_count + ", 1)"); row.Cells.Add("Column (" + row_count + ", 2)"); row.Cells.Add("Column (" + row_count + ", 3)"); } // Add table object to first page of input document doc.Pages[1].Paragraphs.Add(table); dataDir = dataDir + "document_with_table_out.pdf"; // Save updated document containing table object doc.Save(dataDir); // ExEnd:AddTable Console.WriteLine("\nText added successfully to an existing pdf file.\nFile saved at " + dataDir); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Images(); // Load the source PDF document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "ImagePlacement.pdf"); ImagePlacementAbsorber abs = new ImagePlacementAbsorber(); // Load the contents of first page doc.Pages[1].Accept(abs); foreach (ImagePlacement imagePlacement in abs.ImagePlacements) { // Get image properties Console.Out.WriteLine("image width:" + imagePlacement.Rectangle.Width); Console.Out.WriteLine("image height:" + imagePlacement.Rectangle.Height); Console.Out.WriteLine("image LLX:" + imagePlacement.Rectangle.LLX); Console.Out.WriteLine("image LLY:" + imagePlacement.Rectangle.LLY); Console.Out.WriteLine("image horizontal resolution:" + imagePlacement.Resolution.X); Console.Out.WriteLine("image vertical resolution:" + imagePlacement.Resolution.Y); // Retrieve image with visible dimensions Bitmap scaledImage; using (MemoryStream imageStream = new MemoryStream()) { // Retrieve image from resources imagePlacement.Image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png); Bitmap resourceImage = (Bitmap)Bitmap.FromStream(imageStream); // Create bitmap with actual dimensions scaledImage = new Bitmap(resourceImage, (int)imagePlacement.Rectangle.Width, (int)imagePlacement.Rectangle.Height); } } }
// // Debug methods // for testing functionality Aspose.PDF // public void PDocument_debug(string fileFullName, HDocument hDocument) { //throw new PException("file " + fileFullName + " is busy."); //debug_helloWorld(fileFullName); //debug_createImage(fileFullName); //debug_createText(fileFullName); //debug_createP(fileFullName); pdfDocument = new Document(); //PExample.Form1(pdfDocument); //PExample.Text1(pdfDocument); //PExample.Text2(pdfDocument); //PExample.Text3(pdfDocument); PExample.Text4(pdfDocument); //pdfPage = pdfDocument.Pages.Add(); //PExample.Graph1(pdfPage); //PExample.Graph2(pdfPage); //PExample.Graph3(pdfPage); //PExample.Graph4(pdfPage); pdfDocument.Save(fileFullName); }
public PDocument(string fileFullName, HDocument hDocument) { /* * //DEBUG * PDocument_debug(fileFullName, hDocument); * return; */ bodyNode = hDocument.BodyNode; pageTextState = PUtil.TextStateUtil.TextState_Default(); PUtil.TextStateUtil.TextState_ModifyFromHStyles((bodyNode as HNodeTag).Styles, pageTextState); pageMargin = new MarginInfo(4, 4, 4, 12); pageBackground = Aspose.Pdf.Color.FromRgb(1.00, 1.00, 1.00); pdfDocument = new Document(); pdfPage = null; pdfTextFragment = null; pdfImage = null; hyperlinkNode = null; pdfNewLine = null; inlineParagraphMargin = null; pdfFormField = null; pdfRadioButtonFields = new Dictionary <string, RadioButtonField>(); updateCurrentPage(); createBody(); pdfDocument.Save(fileFullName); }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // Load source PDF document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir+ "input.pdf"); // Initializes a new instance of the Table Aspose.Pdf.Table table = new Aspose.Pdf.Table(); // Set the table border color as LightGray table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray)); // set the border for table cells table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray)); // create a loop to add 10 rows for (int row_count = 1; row_count < 10; row_count++) { // add row to table Aspose.Pdf.Row row = table.Rows.Add(); // add table cells row.Cells.Add("Column (" + row_count + ", 1)"); row.Cells.Add("Column (" + row_count + ", 2)"); row.Cells.Add("Column (" + row_count + ", 3)"); } // Add table object to first page of input document doc.Pages[1].Paragraphs.Add(table); // Save updated document containing table object doc.Save(dataDir+ "document_with_table.pdf"); }
private void pdf_to_word(save_progress progress, System.Windows.Forms.Form dlg, string fileType) { Aspose.Pdf.Document document = null; int num = 0; if (fileType == ".pdf") { document = this.pdf_doc; num = 0; } else if ((fileType == ".ppt") || (fileType == ".pptx")) { document = this.ppt_to_pdf(progress, dlg, 0); num = 50; } else if ((fileType == ".xls") || (fileType == ".xlsx")) { document = this.xls_to_pdf(progress, dlg, 0); num = 50; } Aspose.Words.Document document2 = new Aspose.Words.Document(); Aspose.Pdf.Document document3 = new Aspose.Pdf.Document(); if (progress != null) { dlg.Invoke(progress, new object[] { num }); } document2.ChildNodes.Clear(); for (int i = 1; i <= document.Pages.Count; i++) { try { MemoryStream outputStream = new MemoryStream(); document3.Pages.Add(document.Pages[i]); document3.Save(outputStream, Aspose.Pdf.SaveFormat.Doc); document2.AppendDocument(new Aspose.Words.Document(outputStream), ImportFormatMode.KeepSourceFormatting); document3.Pages.Delete(); } catch (Exception) { break; } if (progress != null) { if (num == 50) { dlg.Invoke(progress, new object[] { ((i * 50) / document.Pages.Count) + 50 }); } else { dlg.Invoke(progress, new object[] { (i * 100) / this.pdf_doc.Pages.Count }); } } } document2.Save(this.global_config.target_dic + Path.GetFileNameWithoutExtension(this.file_path) + this.get_suffix()); if (progress != null) { dlg.Invoke(progress, new object[] { 100 }); } }
public static int GetFilePage(string filePath) { int count = 0; string extension = Path.GetExtension(filePath); string fileName = Path.GetFileName(filePath); string password = new ini_config("config.ini").read_ini("pwd", "App"); switch (extension.ToLower()) { case ".pdf": try { Aspose.Pdf.Document document = new Aspose.Pdf.Document(filePath, password); count = document.Pages.Count; } catch (Aspose.Pdf.Exceptions.InvalidPasswordException exception) { throw new Exception(exception.Message); } return(count); case ".doc": { Aspose.Words.Document document2 = new Aspose.Words.Document(filePath); return(document2.PageCount); } case ".docx": { Aspose.Words.Document document3 = new Aspose.Words.Document(filePath); return(document3.PageCount); } case ".xls": { Workbook workbook = new Workbook(filePath); return(workbook.Worksheets.Count); } case ".xlsx": { Workbook workbook2 = new Workbook(filePath); return(workbook2.Worksheets.Count); } case ".ppt": { Presentation presentation = new Presentation(filePath); return(presentation.Slides.Count); } case ".pptx": { Presentation presentation2 = new Presentation(filePath); return(presentation2.Slides.Count); } } return(1); }
public int Process(string sourcePath, string targetPath, int currentPage, string originalDocumentName) { var pdfDocument = new Aspose.Pdf.Document(sourcePath); var docFileName = targetPath.Split('\\'); pdfDocument.Save(targetPath.Replace(docFileName[docFileName.Length - 1], docFileName[docFileName.Length - 1].ToLower().Replace(".pdf", ".docx")), SaveFormat.DocX); return pdfDocument.Pages.Count; }
public static string TestReadDocInfo() { var path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "testAspose.pdf"); Document pdfDocument = new Aspose.Pdf.Document(path); var r1 = Util.JsonUtils.SerializeObject(pdfDocument.Info); return(r1); }
private void pdf_to_excel(save_progress progress, System.Windows.Forms.Form dlg, string fileType) { Aspose.Pdf.Document document = null; int num = 0; try { if (fileType == ".pdf") { document = this.pdf_doc; num = 0; } else if ((fileType == ".ppt") || (fileType == ".pptx")) { document = this.ppt_to_pdf(progress, dlg, 0); num = 50; } else if ((fileType == ".doc") || (fileType == ".docx")) { document = this.doc_to_pdf(progress, dlg, 0); num = 50; } Workbook workbook = new Workbook(); Aspose.Pdf.Document document2 = new Aspose.Pdf.Document(); if (progress != null) { dlg.Invoke(progress, new object[] { num }); } workbook.Worksheets.Clear(); for (int i = 1; i <= document.Pages.Count; i++) { MemoryStream outputStream = new MemoryStream(); document2.Pages.Add(document.Pages[i]); document2.Save(outputStream, Aspose.Pdf.SaveFormat.Excel); Workbook workbook2 = new Workbook(outputStream); workbook.Worksheets.Add(i.ToString()); workbook.Worksheets[i - 1].Copy(workbook2.Worksheets[0]); document2.Pages.Delete(); if (progress != null) { if (num == 50) { dlg.Invoke(progress, new object[] { ((i * 50) / document.Pages.Count) + 50 }); } else { dlg.Invoke(progress, new object[] { (i * 100) / this.pdf_doc.Pages.Count }); } } } workbook.Save(this.global_config.target_dic + Path.GetFileNameWithoutExtension(this.file_path) + ".xls"); } catch (Exception) { } }
//===================================================================================================== Generate documents protected Stream GetPreviewImagesPdfStream(Content content, IEnumerable <SNCR.Image> previewImages, RestrictionType?restrictionType = null) { CheckLicense(LicenseProvider.Pdf); try { var ms = new MemoryStream(); var pdf = new Pdf(); var document = new Aspose.Pdf.Document(pdf); var index = 1; foreach (var previewImage in previewImages.Where(previewImage => previewImage != null)) { using (var imgStream = GetRestrictedImage(previewImage, restrictionType: restrictionType)) { int newWidth; int newHeight; ComputeResizedDimensions((int)previewImage["Width"], (int)previewImage["Height"], PREVIEW_PDF_WIDTH, PREVIEW_PDF_HEIGHT, out newWidth, out newHeight); var imageStamp = new ImageStamp(imgStream) { TopMargin = 10, HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center, VerticalAlignment = Aspose.Pdf.VerticalAlignment.Top, Width = newWidth, Height = newHeight }; try { var page = index == 1 ? document.Pages[1] : document.Pages.Add(); page.AddStamp(imageStamp); } catch (IndexOutOfRangeException ex) { Logger.WriteException(new Exception("Error during pdf generation. Path: " + previewImage.Path, ex)); break; } } index++; } document.Save(ms); ms.Seek(0, SeekOrigin.Begin); return(ms); } catch (Exception ex) { Logger.WriteException(ex); } return(null); }
public IActionResult AsposePDF() { using (var stream = new MemoryStream()) { var pdf = new Aspose.Pdf.Document(stream); pdf.Save("", SaveFormat.Html); } return(View()); }
public void ToTxt(string absoluteFilePath, string outputPath) { var txtAbsorber = new TextAbsorber(); using (var pdfDocument = new Aspose.Pdf.Document(absoluteFilePath)) { pdfDocument.Pages.Accept(txtAbsorber); File.WriteAllText(outputPath, txtAbsorber.Text); } }
public void CreateIndex(Analyzer analayer) { FSDirectory fsDir = new SimpleFSDirectory(new DirectoryInfo(_indexerFolder)); IndexWriter indexWriter = new IndexWriter(fsDir, analayer, true, Lucene.Net.Index.IndexWriter.MaxFieldLength.UNLIMITED); Stopwatch stopWatch = Stopwatch.StartNew(); int analyzedCount = 0; string[] files = System.IO.Directory.GetFiles(_textFilesFolder, this._fileSearchPattern, SearchOption.AllDirectories); //统计需要索引的文件页数 int totalPages = GetTotalPages(files); WriteLog("Total pages statistics takes {0}ms", stopWatch.Elapsed.Milliseconds); stopWatch.Restart(); TextAbsorber textAbsorber = new TextAbsorber(); //开始索引 foreach (string pdfFile in files) { var fileInfo = new FileInfo(pdfFile); var fileName = fileInfo.Name; Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(pdfFile); WriteLog("Current file is {0}", pdfFile); //注意pdf页码从1开始 for (int i = 1;i<=pdfDocument.Pages.Count;i++) { Page page = pdfDocument.Pages[i]; page.Accept(textAbsorber); string pageContent = textAbsorber.Text; Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document(); doc.Add(new Field(LuceneConfig.Field_Path, pdfFile, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(LuceneConfig.Field_FileName, fileName, Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field(LuceneConfig.Field_PageNumber, i.ToString(), Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field(LuceneConfig.Field_ContentByPage, pageContent, Field.Store.NO, Field.Index.ANALYZED)); indexWriter.AddDocument(doc); analyzedCount++; RaiseProgressChanged(analyzedCount * 100 / totalPages); } } indexWriter.Optimize(); indexWriter.Dispose(); stopWatch.Stop(); Console.WriteLine("All completed. It takes {0}ms", stopWatch.Elapsed); }
public static void Run() { // ExStart:AddingDifferentHeaders // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_StampsWatermarks(); // Open source document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir+ "AddingDifferentHeaders.pdf"); // Create three stamps Aspose.Pdf.TextStamp stamp1 = new Aspose.Pdf.TextStamp("Header 1"); Aspose.Pdf.TextStamp stamp2 = new Aspose.Pdf.TextStamp("Header 2"); Aspose.Pdf.TextStamp stamp3 = new Aspose.Pdf.TextStamp("Header 3"); // Set stamp alignment (place stamp on page top, centered horiznotally) stamp1.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Top; stamp1.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center; // Specify the font style as Bold stamp1.TextState.FontStyle = FontStyles.Bold; // Set the text fore ground color information as red stamp1.TextState.ForegroundColor = Color.Red; // Specify the font size as 14 stamp1.TextState.FontSize = 14; // Now we need to set the vertical alignment of 2nd stamp object as Top stamp2.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Top; // Set Horizontal alignment information for stamp as Center aligned stamp2.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center; // Set the zooming factor for stamp object stamp2.Zoom = 10; // Set the formatting of 3rd stamp object // Specify the Vertical alignment information for stamp object as TOP stamp3.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Top; // Set the Horizontal alignment inforamtion for stamp object as Center aligned stamp3.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center; // Set the rotation angle for stamp object stamp3.RotateAngle = 35; // Set pink as background color for stamp stamp3.TextState.BackgroundColor = Color.Pink; // Change the font face information for stamp to Verdana stamp3.TextState.Font = FontRepository.FindFont("Verdana"); // First stamp is added on first page; doc.Pages[1].AddStamp(stamp1); // Second stamp is added on second page; doc.Pages[2].AddStamp(stamp2); // Third stamp is added on third page. doc.Pages[3].AddStamp(stamp3); dataDir = dataDir + "multiheader_out.pdf"; // Save the updated document doc.Save(dataDir); // ExEnd:AddingDifferentHeaders Console.WriteLine("\nDifferent headers added successfully.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:RemoveFilesFromPortfolio // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_TechnicalArticles(); // Load source PDF Portfolio Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(dataDir + "PDFPortfolio.pdf"); pdfDocument.Collection.Delete(); pdfDocument.Save(dataDir + "No_PortFolio_out.pdf"); // ExEnd:RemoveFilesFromPortfolio }
internal Reader(string file, string password = null) : base() { if (String.IsNullOrEmpty(password)) { _document = new AsposePdf.Document(file); } else { _document = new AsposePdf.Document(file, password); } }
public static void Run() { // ExStart:PDFToPPT // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // Load PDF document Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "input.pdf"); // Instantiate PptxSaveOptions instance Aspose.Pdf.PptxSaveOptions pptx_save = new Aspose.Pdf.PptxSaveOptions(); // Save the output in PPTX format doc.Save(dataDir + "PDFToPPT_out.pptx", pptx_save); // ExEnd:PDFToPPT }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // instantiate LoadOption object using XPS load option Aspose.Pdf.LoadOptions options = new XpsLoadOptions(); // create document object Aspose.Pdf.Document document = new Aspose.Pdf.Document(dataDir + "test.xps", options); // save the resultant PDF document document.Save(dataDir + "resultant.pdf"); }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // instantiate LoadOption object using PCL load option Aspose.Pdf.LoadOptions loadopt = new Aspose.Pdf.PclLoadOptions(); // create Document object Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "test.pcl", loadopt); // save the resultant PDF document doc.Save(dataDir + "test-converted.pdf"); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // instantiate LoadOption object using XPS load option Aspose.Pdf.LoadOptions options = new XpsLoadOptions(); // create document object Aspose.Pdf.Document document = new Aspose.Pdf.Document(dataDir + "test.xps", options); // save the resultant PDF document document.Save(dataDir + "resultant.pdf"); }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // Instantiate LoadOption object using EPUB load option EpubLoadOptions epubload = new EpubLoadOptions(); // Create Document object Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(dataDir + "Sample.epub", epubload); // Save the resultant PDF document pdf.Save(dataDir + "output.pdf"); }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // Instantiate LoadOption object using SVG load option Aspose.Pdf.LoadOptions loadopt = new Aspose.Pdf.SvgLoadOptions(); // Create Document object Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "example.svg", loadopt); // Save the resultant PDF document doc.Save(dataDir + "converted.pdf"); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // Instantiate LoadOption object using EPUB load option EpubLoadOptions epubload = new EpubLoadOptions(); // Create Document object Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(dataDir + "Sample.epub", epubload); // Save the resultant PDF document pdf.Save(dataDir + "EPUBToPDF_out.pdf"); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // instantiate LoadOption object using PCL load option Aspose.Pdf.LoadOptions loadopt = new Aspose.Pdf.PclLoadOptions(); // create Document object Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "test.pcl", loadopt); // save the resultant PDF document doc.Save(dataDir + "test-converted.pdf"); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // Instantiate LoadOption object using SVG load option Aspose.Pdf.LoadOptions loadopt = new Aspose.Pdf.SvgLoadOptions(); // Create Document object Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "example.svg", loadopt); // Save the resultant PDF document doc.Save(dataDir + "converted.pdf"); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // create Document object Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "PDFToTeX.pdf"); // instantiate LaTex save option LaTeXSaveOptions saveOptions = new LaTeXSaveOptions(); // specify the output directory string pathToOutputDirectory = dataDir; // set the output directory path for save option object saveOptions.OutDirectoryPath = pathToOutputDirectory; // save PDF file into LaTex format doc.Save(dataDir + "Output.tex", saveOptions); }
public static void Run() { try { // ExStart:TeXToPDF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // Instantiate Latex Load option object LatexLoadOptions Latexoptions = new LatexLoadOptions(); // Create Document object Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "samplefile.tex", Latexoptions); // Save the output in PDF file doc.Save(dataDir + "TeXToPDF_out.pdf"); // ExEnd:TeXToPDF } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // create Document object Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "input.pdf"); // instantiate LaTex save option LaTeXSaveOptions saveOptions = new LaTeXSaveOptions(); // specify the output directory string pathToOutputDirectory = dataDir; // set the output directory path for save option object saveOptions.OutDirectoryPath = pathToOutputDirectory; // save PDF file into LaTex format doc.Save(dataDir + "Output.tex", saveOptions); }
public static void Run() { // ExStart:ArabicTextFilling // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Forms(); // Load PDF form contents FileStream fs = new FileStream(dataDir + "FillFormField.pdf", FileMode.Open, FileAccess.ReadWrite); // Instantiate Document instance with stream holding form file Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(fs); // Get referecne of particuarl TextBoxField TextBoxField txtFld = pdfDocument.Form["textbox1"] as TextBoxField; // Fill form field with arabic text txtFld.Value = "يولد جميع الناس أحراراً متساوين في"; dataDir = dataDir + "ArabicTextFilling_out.pdf"; // Save updated document pdfDocument.Save(dataDir); // ExEnd:ArabicTextFilling Console.WriteLine("\nArabic text filled successfully in form field.\nFile saved at " + dataDir); }