private string CreateDocumentBasedOnPageCount(ScannedDocument barCodeText) { Aspose.Pdf.Document pdfDocument1 = new Aspose.Pdf.Document(barCodeText.FullPath); Aspose.Pdf.Document pdfDocument2 = new Aspose.Pdf.Document(); string returnDocumentName = string.Empty; for (int i = 1; i <= barCodeText.PageCount; i++) { pdfDocument2.Pages.Add(pdfDocument1.Pages[i]); } returnDocumentName = ConfigurationValues.PathToWorkingFolder + Utility.GetFileNameFromDateTimeString() + ".pdf"; pdfDocument2.Save(returnDocumentName); pdfDocument1.Dispose(); Aspose.Pdf.Document pdfDocument3 = new Aspose.Pdf.Document(barCodeText.FullPath); for (int i = 1; i <= barCodeText.PageCount; i++) { pdfDocument3.Pages.Delete(1); } File.Delete(barCodeText.FullPath); pdfDocument3.Save(barCodeText.FullPath); pdfDocument3.Dispose(); return returnDocumentName; }
public static void Run() { //ExStart: AddAndSearchHiddenText // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); //Create document with hidden text Aspose.Pdf.Document doc = new Aspose.Pdf.Document(); Page page = doc.Pages.Add(); TextFragment frag1 = new TextFragment("This is common text."); TextFragment frag2 = new TextFragment("This is invisible text."); //Set text property - invisible frag2.TextState.Invisible = true; page.Paragraphs.Add(frag1); page.Paragraphs.Add(frag2); doc.Save(dataDir + "39400_out.pdf"); doc.Dispose(); //Search text in the document doc = new Aspose.Pdf.Document(dataDir + "39400_out.pdf"); TextFragmentAbsorber absorber = new TextFragmentAbsorber(); absorber.Visit(doc.Pages[1]); foreach (TextFragment fragment in absorber.TextFragments) { //Do something with fragments Console.WriteLine("Text '{0}' on pos {1} invisibility: {2} ", fragment.Text, fragment.Position.ToString(), fragment.TextState.Invisible); } doc.Dispose(); //ExEnd: AddAndSearchHiddenText }
private void LoadImageOnPdfFile_3() { //create filename of pdf_file_tosave var pdf_file_tosave = @"d:\1.pdf"; //new pdf doc var pdfDoc = new Aspose.Pdf.Document(); //editing pdfDoc.SetTitle("hello!"); var pdfPage = pdfDoc.Pages.Add(); //var te1 = new Aspose.Pdf.Text.TextSegment(); pdfPage.AddImage(@"F:\MyDesktop\en-HandWritting\e.jpg", new Aspose.Pdf.Rectangle(0, 0, 500, 500)); //save try { pdfDoc.Save(pdf_file_tosave, Aspose.Pdf.SaveFormat.Pdf); MessageBox.Show("Save Successfully!"); pdfDoc.Dispose(); Process.Start(pdf_file_tosave); } catch { MessageBox.Show("Faild to Save!"); } }
private void CreatePdfFile_1() { //create filename of pdf_file_tosave var pdf_file_tosave = @"d:\1.pdf"; //new pdf doc var pdfDoc = new Aspose.Pdf.Document(); //editing pdfDoc.SetTitle("hello!"); var pdfPage = pdfDoc.Pages.Add(); //save try { pdfDoc.Save(pdf_file_tosave, Aspose.Pdf.SaveFormat.Pdf); MessageBox.Show("Save Successfully!"); pdfDoc.Dispose(); Process.Start(pdf_file_tosave); } catch { MessageBox.Show("Faild to Save!"); } }
private void CreateTableOnPdfFile_4() { //create filename of pdf_file_tosave var pdf_file_tosave = @"d:\1.pdf"; //new pdf doc var pdfDoc = new Aspose.Pdf.Document(); //editing pdfDoc.SetTitle("hello!"); var pdfPage = pdfDoc.Pages.Add(); var 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.LightGray); // Set the border for table cells table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.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)"); } // Add table object to first page of input document pdfPage.Paragraphs.Add(table); //Aspose.Pdf.Layer layer1 = new Aspose.Pdf.Layer("layer1","layer1"); //pdfPage.Layers.Add(layer1); //why is pdfPage.layers null? //save try { pdfDoc.Save(pdf_file_tosave, Aspose.Pdf.SaveFormat.Pdf); MessageBox.Show("Save Successfully!"); pdfDoc.Dispose(); Process.Start(pdf_file_tosave); } catch { MessageBox.Show("Faild to Save!"); } }