If the private key corresponding to the public key used for encryption is available on the
computer where the the encrypted file is opened, the security settings are shown like below:
Observation: A file encrypted with the public key can be opened only by the corresponding
private key of that certificate. If you want to encrypt a file for a person, you will need the public
key of the certificate issued for that person. If the file is encrypted with your certificate only
you can open that file. If the private key of the encryption certificate is not present a warning
message will be displayed like below:
Page 31 - .NET Digital Signature Library User Manual (version 2.0)
Security settings for a digitally sign and encrypted document
Decryption certificate (private key) is not present
How to view pdf thumbnails in - Draw thumbnail images for PDF in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support Thumbnail Generation with Various Options for Quick PDF Navigation
create pdf thumbnail; generate pdf thumbnails
How to view pdf thumbnails in - VB.NET PDF Thumbnail Create SDK: Draw thumbnail images for PDF in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support Thumbnail Generation with Various Options for Quick PDF Navigation
generate thumbnail from pdf; how to view pdf thumbnails in
PDF Signature Code Samples
Digitally Sign All Pages From a PDF File with a Certificate Stored on PFX File
using SignLib.Certificates;
using SignLib.Pdf;
PdfSignature ps = new PdfSignature("serial number");
//load the pdf file
ps.LoadPdfDocument("d:\\source.pdf");
//load the certificate
ps.DigitalSignatureCertificate = 
DigitalCertificate.LoadCertificate("d:\\cert.pfx""123456");
//put the signature to all pages
ps.SignatureAppearsOnAllPages = true;
//set the signature position
ps.SignaturePosition = SignaturePosition.TopLeft;
//digitally sign and save the PDF file
File.WriteAllBytes("d:\\dest.pdf", ps.ApplyDigitalSignature());
Set a Custom Signature Rectangle and Sign Using a Smart Card Certificate
using SignLib.Certificates;
using SignLib.Pdf;
PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument("d:\\source.pdf");
//load the certificate from Microsoft Store
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(false""
"Select Certificate""");
ps.SignaturePage = 1;
//set the signature position
System.Drawing.Point pageRectangle = ps.DocumentProperties.DocumentPageSize(1);
//put the signature on the middle of the page
ps.SignatureAdvancedPosition = new System.Drawing.Rectangle(pageRectangle.X / 2, 
pageRectangle.Y / 2, 100, 50);
File.WriteAllBytes("d:\\dest.pdf", ps.ApplyDigitalSignature());
Digitally Sign a PDF Located on the Web Only if it is not Already Signed
using SignLib.Certificates;
using SignLib.Pdf;
PdfSignature PDFSign = new PdfSignature("serial number");
//load the pdf file from web
PDFSign.LoadPdfDocument(new Uri("http://www.signfiles.com/test.pdf"));
//sign the document only if it is not signed
if (PDFSign.DocumentProperties.DigitalSignatures.Count == 0)
{
PDFSign.DigitalSignatureCertificate = 
DigitalCertificate.LoadCertificate("d:\\cert.pfx""123456");
File.WriteAllBytes("c:\\dest.pdf", PDFSign.ApplyDigitalSignature());
}
Page 32 - .NET Digital Signature Library User Manual (version 2.0)
C# HTML5 PDF Viewer SDK to view PDF document online in C#.NET
Ability to show PDF page thumbnails for quick navigation. Easy to search PDF text in whole PDF document. C# HTML5 PDF Viewer: View PDF Online.
pdf no thumbnail; program to create thumbnail from pdf
VB.NET PDF- View PDF Online with VB.NET HTML5 PDF Viewer
Ability to show PDF page thumbnails for quick navigation. Easy to search PDF text in whole PDF document. VB.NET HTML5 PDF Viewer: View PDF Online.
pdf file thumbnail preview; disable pdf thumbnails
Digitally Sign a PDF file with a PFX Certificate Created on the Fly
using SignLib.Certificates;
using SignLib.Pdf;
string certificatePassword = "tempP@ssword";
//create the digital certificate used to digitally sign the PDF document
X509CertificateGenerator cert = new X509CertificateGenerator("serial number");
//set the validity of the certificate (2 years from now)
cert.ValidFrom = DateTime.Now;
cert.ValidTo = DateTime.Now.AddYears(2);
//set the signing algorithm and the key size
cert.KeySize = KeySize.KeySize2048Bit;
cert.SignatureAlgorithm = SignatureAlgorithm.SHA1WithRSA;
//set the certificate subject
cert.Subject = "CN=Your User, E=useremail@email.com, O=Organzation";
//add some simple extensions to the client certificate
cert.Extensions.AddKeyUsage(CertificateKeyUsage.DigitalSignature);
cert.Extensions.AddKeyUsage(CertificateKeyUsage.DataEncipherment);
//add some enhanced extensions to the client certificate marked as critical
cert.Extensions.AddEnhancedKeyUsage(CertificateEnhancedKeyUsage.DocumentSigning); 
cert.Extensions.AddEnhancedKeyUsage(CertificateEnhancedKeyUsage.SecureEmail);
//create the certificate
byte[] digitalCertificate = cert.GenerateCertificate(certificatePassword);
//create the PDF signature
PdfSignature ps = new PdfSignature("serial number");
//Load the PDF file
ps.LoadPdfDocument("d:\\source.pdf");
//Load the new certificate
ps.DigitalSignatureCertificate = 
DigitalCertificate.LoadCertificate(digitalCertificate, certificatePassword);
//Signing reason & location
ps.SigningReason = "I approve this document";
ps.SigningLocation = "Europe branch";
//digitally sign the PDF file
File.WriteAllBytes("d:\\dest.pdf", ps.ApplyDigitalSignature());
Page 33 - .NET Digital Signature Library User Manual (version 2.0)
VB.NET PDF - View PDF with WPF PDF Viewer for VB.NET
Easy to search PDF text in whole PDF document in VB.NET WPF program. PDF thumbnails for navigation in .NET project. VB.NET WPF PDF Viewer: View PDF Document.
pdf thumbnail viewer; thumbnail view in for pdf files
C# WPF PDF Viewer SDK to view PDF document in C#.NET
Users can view any page by using view page button. Easy to search PDF text in whole PDF document. PDF thumbnails for navigation in .NET WPF Console application.
no pdf thumbnails in; pdf thumbnail generator
Set a Custom Text and Font for the Digital Signature Rectangle
using SignLib.Certificates;
using SignLib.Pdf;
PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument("c:\\source.pdf");
ps.DigitalSignatureCertificate = 
DigitalCertificate.LoadCertificate("d:\\cert.pfx""123456");
ps.SignaturePage = 1;
ps.SignaturePosition = SignaturePosition.BottomLeft;
//set the font file
ps.FontFile = "c:\\windows\\fonts\\verdana.ttf";
//set the font size
ps.FontSize = 6;
//customize the text that appears on the signature rectangle
ps.SignatureText = "Signed by: " + 
ps.DigitalSignatureCertificate.GetNameInfo(X509NameType.SimpleName, false) +
"\nSigning time: " + DateTime.Now.ToShortDateString() +
"\nSigning reason: " + ps.SigningReason +
"\nLocation: " + ps.SigningLocation;
File.WriteAllBytes("c:\\dest.pdf", ps.ApplyDigitalSignature());
Add an Image on the Signature Rectangle and Save the File as PDF/A
using SignLib.Certificates;
using SignLib.Pdf;
PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument("d:\\source.pdf");
ps.DigitalSignatureCertificate = 
DigitalCertificate.LoadCertificate("d:\\cert.pfx""123456");
ps.SignaturePage = ps.DocumentProperties.NumberOfPages;
ps.SignaturePosition = SignaturePosition.BottomLeft;
ps.SignatureText = "Signed by the author";
//path to the signature image
ps.SignatureImage = File.ReadAllBytes("d:\\graphic.jpg");
ps.SignatureImageType = SignatureImageType.ImageAsBackground;
//the font must be embedded in orde to save the file as PDF/A
ps.FontFile = "c:\\windows\\fonts\\verdana.ttf";
ps.SaveAsPdfA = true;
File.WriteAllBytes("d:\\dest.pdf", ps.ApplyDigitalSignature());
Page 34 - .NET Digital Signature Library User Manual (version 2.0)
C# PDF Convert to Jpeg SDK: Convert PDF to JPEG images in C#.net
Support of converting from any single one PDF page and multiple pages. Thumbnails can be created from PDF pages. Support for customizing image size.
create thumbnail from pdf c#; how to show pdf thumbnails in
VB.NET PDF File Compress Library: Compress reduce PDF size in vb.
Reduce image resources: Since images are usually or large size, images size reducing can help to reduce PDF file size effectively. Embedded page thumbnails.
pdf preview thumbnail; enable pdf thumbnails in
Set an Invisible Signature and Certify the PDF File
using SignLib.Certificates;
using SignLib.Pdf;
PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument("d:\\source.pdf");
ps.DigitalSignatureCertificate = 
DigitalCertificate.LoadCertificate("d:\\cert.pfx""123456");
//certify the signature
ps.CertifySignature = CertifyMethod.NoChangesAllowed;
//set an invisible signature
ps.VisibleSignature = false;
File.WriteAllBytes("d:\\dest.pdf", ps.ApplyDigitalSignature());
Time Stamp a PDF File
using SignLib.Certificates;
using SignLib.Pdf;
PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument("d:\\source.pdf");
ps.DigitalSignatureCertificate = 
DigitalCertificate.LoadCertificate("d:\\cert.pfx""123456");
//Set the TSA Server URL
ps.TimeStamping.ServerUrl = new Uri("http://ca.signfiles.com/TSAServer.aspx");
File.WriteAllBytes("d:\\dest.pdf", ps.ApplyDigitalSignature());
Time Stamp a PDF file Using TSA Server Authentication
using SignLib.Certificates;
using SignLib.Pdf;
PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument("d:\\source.pdf");
ps.DigitalSignatureCertificate = 
DigitalCertificate.LoadCertificate("d:\\cert.pfx""123456");
//Set the TSA Server URL
ps.TimeStamping.ServerUrl = new Uri("http://ca.signfiles.com/TSAServer.aspx");
//set username and password
ps.TimeStamping.UserName = "username";
ps.TimeStamping.Password = "P@ssw0rD";
File.WriteAllBytes("d:\\dest.pdf", ps.ApplyDigitalSignature());
Page 35 - .NET Digital Signature Library User Manual (version 2.0)
C# PDF File Compress Library: Compress reduce PDF size in C#.net
by large enterprises and organizations to distribute and view documents. size, images size reducing can help to reduce PDF file size Embedded page thumbnails.
how to make a thumbnail of a pdf; print pdf thumbnails
C# PDF Convert to Images SDK: Convert PDF to png, gif images in C#
Converter control easy to create thumbnails from PDF pages. Selection for compressing to multiple image formats. Cut and paste any areas in PDF pages to images.
pdf thumbnail fix; show pdf thumbnail in html
Digitally Sign and Time Stamp a Folder with PDF files
using SignLib.Certificates;
using SignLib.Pdf;  
PdfSignature ps = new PdfSignature("serial number");
ps.DigitalSignatureCertificate = 
DigitalCertificate.LoadCertificate("d:\\cert.pfx""123456");
ps.TimeStamping.ServerUrl = new Uri("http://ca.signfiles.com/TSAServer.aspx");
System.IO.DirectoryInfo di;
System.IO.FileInfo[] rgFiles;
//get the pdf files from the folder
di = new System.IO.DirectoryInfo("d:\\source_dir");
rgFiles = di.GetFiles("*.pdf");
foreach (FileInfo fi in rgFiles)
{
//for readonly files
fi.Attributes = FileAttributes.Normal;
//load the PDF document
ps.LoadPdfDocument(di.FullName + "\\" + fi.Name);
//digitally sign and save the PDF file
File.WriteAllBytes("d:\\output_dir\\" + fi.Name, 
ps.ApplyDigitalSignature());
}
Digitally Sign a PDF file in a ASP.NET Application (IIS)
using SignLib.Certificates;
using SignLib.Pdf;  
protected void Page_Load(object sender, EventArgs e)
{
PdfSignature ps = new PdfSignature("serial number");
//set the signing certificate
//the PFX certificate must use MachineKeySet
ps.DigitalSignatureCertificate = new 
System.Security.Cryptography.X509Certificates.X509Certificate2(Server.MapPath("cer
t.pfx"), "123456"
System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.MachineKeySet);
ps.LoadPdfDocument(Server.MapPath("source.pdf"));
System.IO.File.WriteAllBytes(Server.MapPath("dest.pdf"), 
ps.ApplyDigitalSignature());
}
Page 36 - .NET Digital Signature Library User Manual (version 2.0)
Automatically Sign a Folder Using a Smart Card Certificate / USB Token
using SignLib.Certificates;
using SignLib.Pdf;  
PdfSignature ps = new PdfSignature(serialNumber);
ps.SignaturePosition = SignaturePosition.TopLeft;
ps.SignaturePage = 1;
//automaticall load the digital signature certificate using email criteria
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(false
DigitalCertificateSearchCriteria.EmailE, "user@test.com"false);
//bypass the smart card PIN
DigitalCertificate.SmartCardPin = "123456";
ps.TimeStamping.ServerUrl = new Uri("http://ca.signfiles.com/TSAServer.aspx");
System.IO.DirectoryInfo di;
System.IO.FileInfo[] rgFiles;
//get the pdf files from the folder
di = new System.IO.DirectoryInfo("d:\\source_dir");
rgFiles = di.GetFiles("*.pdf");
foreach (FileInfo fi in rgFiles)
{
//for readonly files
fi.Attributes = FileAttributes.Normal;
//load the PDF document
ps.LoadPdfDocument(di.FullName + "\\" + fi.Name);
//digitally sign and save the PDF file
File.WriteAllBytes("d:\\output_dir\\" + fi.Name, 
ps.ApplyDigitalSignature());
}
Page 37 - .NET Digital Signature Library User Manual (version 2.0)
Verifying a Digital Signature
In some cases is needed to verify the digital signatures attached to a PDF document.
To verify the digital signatures added to PDF document, use the following code:
using SignLib.Certificates;
using SignLib.Pdf;  
void ExtractCertificateInformation(X509Certificate2 cert)
{
Console.WriteLine("Certificate subject:" + cert.Subject);
Console.WriteLine("Certificate issued by:" + cert.GetNameInfo(X509NameType.SimpleName, 
true));
Console.WriteLine("Certificate will expire on: " + cert.NotAfter.ToString());
Console.WriteLine("Certificate is time valid: " + 
DigitalCertificate.VerifyDigitalCertificate(cert, VerificationType.LocalTime).ToString());
}
void VerifyPDFSignature(string signedDocument)
{
PdfSignature ps = new PdfSignature(serialNumber);
ps.LoadPdfDocument(signedDocument);
Console.WriteLine("Number of signatures: " + 
ps.DocumentProperties.DigitalSignatures.Count.ToString());
//verify every digital signature form the PDF document
foreach (PdfSignatureInfo csi in ps.DocumentProperties.DigitalSignatures)
{
Console.WriteLine("Signature name: " + csi.SignatureName);
Console.WriteLine("Hash Algorithm: " + csi.HashAlgorithm.ToString());
Console.WriteLine("Signature Certificate Information");
ExtractCertificateInformation(csi.SignatureCertificate);
Console.WriteLine("Signature Is Valid: " + csi.SignatureIsValid.ToString());
Console.WriteLine("Signature Time: " + csi.SignatureTime.ToLocalTime().ToString());
Console.WriteLine("Is Timestamped: " + csi.SignatureIsTimestamped);
if (csi.SignatureIsTimestamped == true)
{
Console.WriteLine("Hash Algorithm: " + csi.TimestampInfo.HashAlgorithm.FriendlyName);
Console.WriteLine("Is TimestampAltered: " + 
csi.TimestampInfo.IsTimestampAltered.ToString());
Console.WriteLine("TimestampSerial Number: " + csi.TimestampInfo.SerialNumber);
Console.WriteLine("TSA Certificate: " + csi.TimestampInfo.TsaCertificate.Subject);
}//if
Console.WriteLine(Environment.NewLine);
//foreach
//method
Page 38 - .NET Digital Signature Library User Manual (version 2.0)
Merge Multiple PDF Files into a Single PDF File
If you need to merge multiple PDF files into a single one, use the following code:
using SignLib.Pdf;
List<byte[]> sourceFiles = new List<byte[]>();
sourceFiles.Add(File.ReadAllBytes("d:\\1.pdf"));
sourceFiles.Add(File.ReadAllBytes("d:\\2.pdf"));
sourceFiles.Add(File.ReadAllBytes("d:\\3.pdf"));
sourceFiles.Add(File.ReadAllBytes("d:\\4.pdf"));
File.WriteAllBytes("d:\\merge.pdf"PdfMerge.MergePdfFiles(sourceFiles));
Insert Texts and Images in a PDF file
using SignLib.Pdf;
PdfInsertObject PdfInsertImage = new PdfInsertObject();
/***************************
Insert images on PDF document
***************************/
PdfInsertImage.LoadPdfDocument("c:\\source.pdf");
//adds an image on a specific rectangle location on the page 1. The image will be 
placed over the PDF content of the page.
PdfInsertImage.AddImage(File.ReadAllBytes("c:\\watermark.png"), new 
System.Drawing.Rectangle(10, 10, 100, 100), 1, ImagePosition.ImageOverContent);
//adds an image that will cover all the page 2. The image will be placed under the
PDF content (backgorund) of the page.
PdfInsertImage.AddImage(File.ReadAllBytes("c:\\watermark.png"), 2, 
ImagePosition.ImageUnderContent);
//adds an image that will start on a specific starting position on the page 3. The
image will not be resized. The image will be placed over the PDF content of the 
page.
PdfInsertImage.AddImage(File.ReadAllBytes("c:\\watermark.png"), new 
System.Drawing.Point(200, 200), 3, ImagePosition.ImageOverContent);
//adds an image on the top right corner of the document.
PdfInsertImage.AddImage(File.ReadAllBytes("c:\\signature_image.jpg"), new 
System.Drawing.Rectangle(PdfInsertImage.DocumentProperties.DocumentPageSize(4).X -
100, PdfInsertImage.DocumentProperties.DocumentPageSize(4).Y - 100, 100, 100), 4, 
ImagePosition.ImageOverContent);
//adds an image on the top left corner of the document.
PdfInsertImage.AddImage(File.ReadAllBytes("c:\\signature_image.jpg"), new 
System.Drawing.Rectangle(0, 
PdfInsertImage.DocumentProperties.DocumentPageSize(5).Y - 100, 100, 100), 5, 
ImagePosition.ImageOverContent);
Page 39 - .NET Digital Signature Library User Manual (version 2.0)
//adds an image on all document pages over the text.          
PdfInsertImage.AddImage(File.ReadAllBytes("c:\\certificate_graphic.png"), new 
System.Drawing.Point(100, 100), 0, ImagePosition.ImageOverContent);
//adds an image on all document pages under the text in the middle.
PdfInsertImage.AddImage(File.ReadAllBytes("c\\watermark.png"), new 
System.Drawing.Rectangle(PdfInsertImage.DocumentProperties.DocumentPageSize(3).X /
2, PdfInsertImage.DocumentProperties.DocumentPageSize(3).Y / 2, 100, 100), 0, 
ImagePosition.ImageUnderContent);
/***************************
Insert texts on PDF document
*****************************/
CustomText custText = new CustomText();
custText.Align = TextAlign.Left;
custText.FontFile = "c:\\arial.ttf";
custText.FontSize = 8;
custText.PageNumber = 1;
custText.StartingPointPosition = new System.Drawing.Point(100, 100);
custText.Text = "The first text inserted";
custText.TextColor = iTextSharp.text.Color.BLUE;
PdfInsertImage.AddText(custText); //add the first text
CustomText custText2 = new CustomText();
custText2.Align = TextAlign.Left;
custText2.FontFile = "c:\\arial.ttf";
custText2.FontSize = 6;
custText2.PageNumber = 1;
custText2.StartingPointPosition = new System.Drawing.Point(80, 150);
custText2.TextDirection = TextDirection.RightToLeft;
custText2.Text = "יאאלמ לוהינ ,הפוק לוהי";
custText2.TextColor = iTextSharp.text.Color.BLACK;
PdfInsertImage.AddText(custText2); //add the second text
//insert objects and save the PDF file
File.WriteAllBytes("c:\\destination.pdf", PdfInsertImage.InsertObjects()); 
Page 40 - .NET Digital Signature Library User Manual (version 2.0)
Documents you may be interested
Documents you may be interested