Hello!
Is there any possibility to rotate the signature vertically?
//create a PDF
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
//Rotate page
page.Rotation = PdfPageRotateAngle.RotateAngle90;
PdfCertificate digi = new PdfCertificate(@"test.pfx", "123");
PdfSignature signature = new PdfSignature(doc, doc.Pages[0], digi, "demo_1");
signature.SignTextAlignment = SignTextAlignment.Center;
signature.Bounds = new RectangleF(new PointF(200, 200), new SizeF(100, 100));
signature.DistinguishedName = "DN:";
signature.NameLabel = "Digital Signed By:";
signature.Name = "Ankush";
signature.Date = DateTime.Now;
signature.Certificated = false;
signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.ForbidChanges;
doc.FileInfo.IncrementalUpdate = false;
MemoryStream stream = new MemoryStream();
doc.SaveToStream(stream, Spire.Pdf.FileFormat.PDF);
//load saved stream pdf
PdfDocument loaddoc = new PdfDocument();
loaddoc.LoadFromStream(stream);
//create a new pdf
PdfDocument newPdf = new PdfDocument();
PdfPageBase loadpage = loaddoc.Pages[0];
PdfPageBase newPage = newPdf.Pages.Add(new SizeF(loadpage.Size.Height, loadpage.Size.Width), new PdfMargins(0));
loadpage.CreateTemplate().Draw(newPage, new PointF(0, 0));
//draw test string
PdfBrush brush = PdfBrushes.Black;
PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("Arial", 8f, FontStyle.Italic), true);
newPage.Canvas.DrawString("this is a test!", font1, brush, new Rectangle(new Point(50, 50), new Size(50, 50)));
newPdf.SaveToFile(@"output.pdf", FileFormat.PDF);
......
signature.Name = "Ankush";
signature.SignNameFont = new PdfFont(PdfFontFamily.Courier, 25);
......
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"test.pdf");
PdfCertificate cert = new PdfCertificate(@"test.pfx", "123");
PdfSignature signature = new PdfSignature(doc, doc.Pages[0], cert, "Signature1");
signature.Bounds = new RectangleF(50, 600, 160, 50);
signature.NameLabel = "Digitally signed by";
signature.Name = "Test User";
signature.DateLabel = "CEO";
signature.Date = DateTime.Now;
Image img = Image.FromFile(@"logo.png");
PdfImage image = PdfImage.FromImage(img);
signature.SignImageSource = image;
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail;
signature.SignImageLayout = SignImageLayout.Stretch;
signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.ForbidChanges;
doc.SaveToFile("result.pdf");
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"sample.pdf");
PdfCertificate cert = new PdfCertificate(@"test.pfx", "123");
PdfSignature signature = new PdfSignature(doc, doc.Pages[0], cert, "Signature1");
signature.Bounds = new RectangleF(50, 600, 160, 50);
signature.NameLabel = "Digitally signed by";
signature.Name = "Test User";
signature.DateLabel = "CEO";
signature.Date = DateTime.Now;
//set the size of image
Bitmap bitmap = new Bitmap((int)signature.Bounds.Width / 2, (int)signature.Bounds.Height);
Image img = Image.FromFile(@"text.png");
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap))
{
g.Clear(Color.White);
g.DrawImage(img, new Rectangle(0, 0, (int)signature.Bounds.Width / 2, (int)signature.Bounds.Height), new RectangleF(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
}
PdfImage image = PdfImage.FromImage(bitmap);
signature.SignImageSource = image;
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail;
signature.SignImageLayout = SignImageLayout.None;
signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.ForbidChanges;
doc.SaveToFile("result.pdf");
ElimelechSafern wrote:[FunctionName("Sign")]
......sample code ......
For some reason my doc isn't returned with the signature can anyone help?