internal int PageCount(string file) { AsposePdf.Facades.PdfFileInfo fileInfo = new AsposePdf.Facades.PdfFileInfo(file); return fileInfo.NumberOfPages; }
internal bool IsEncrypted(String file) { AsposePdf.Facades.PdfFileInfo fileInfo = new AsposePdf.Facades.PdfFileInfo(file); return fileInfo.IsEncrypted; }
internal bool HasOpenPassword(Stream file) { AsposePdf.Facades.PdfFileInfo fileInfo = new AsposePdf.Facades.PdfFileInfo(file); return fileInfo.HasOpenPassword; }
internal static void ExportPdfFile(string filename) { try { var path = $"original\\{filename}"; var author = "Ευάγγελος Λιάτσας"; var docid = Guid.NewGuid(); var title = filename + " - Δοκιμή PDF διαχείριση"; var document = new Aspose.Pdf.Document(path); // Check for password protection var info = new Aspose.Pdf.Facades.PdfFileInfo(document); // Determine if the source PDF is encrypted if (info.IsEncrypted) { throw new Exception("The PDF file is password protected..."); } var pdfSign = new Aspose.Pdf.Facades.PdfFileSignature(document); if (pdfSign.ContainsSignature()) { var signees = pdfSign.GetSignNames(); foreach (var signee in signees) { Console.WriteLine($"Is digitally signed by {signee} ..."); } } else { // add footer to each sheet var footerText = string.Empty; if (author != null) { footerText = String.Format("Διανομή μέσω 'ΙΡΙΔΑ' με UID: {0} στις {1}", docid, DateTime.Now.ToString("dd/MM/yy HH:mm")); } // Create footer Aspose.Pdf.TextStamp textStamp = new Aspose.Pdf.TextStamp(footerText); // Set properties of the stamp textStamp.BottomMargin = 10; textStamp.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center; textStamp.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Bottom; // Add footer on all pages foreach (Aspose.Pdf.Page page in document.Pages) { page.AddStamp(textStamp); } Console.WriteLine("added footer ..."); } //set file metadata document.Info.Title = title; if (author != null) { document.Info.Author = author; } var final = new MemoryStream(); document.Save(final); using (FileStream file = new FileStream($"revised\\export_{filename}", FileMode.Create, System.IO.FileAccess.Write)) final.WriteTo(file); } catch (Exception exc) { Console.WriteLine(exc); } }