private void button1_Click(object sender, EventArgs e) { //Create a pdf document. PdfNewDocument doc = new PdfNewDocument(); // Create one page PdfPageBase page = doc.Pages.Add(); //Draw the page DrawPage(page); String pfxPath = @"..\..\..\..\..\..\Data\Demo.pfx"; PdfCertificate cert = new PdfCertificate(pfxPath, "e-iceblue"); PdfSignature signature = new PdfSignature(doc, page, cert, "demo"); signature.ContactInfo = "Harry Hu"; signature.Certificated = true; signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill; //Save pdf file. doc.Save("DigitalSignature.pdf"); doc.Close(); //Launching the Pdf file. PDFDocumentViewer("DigitalSignature.pdf"); }
private void button1_Click(object sender, EventArgs e) { //pdf file String input = @"..\..\..\..\..\..\Data\Sample5.pdf"; //open pdf document PdfDocument doc = new PdfDocument(); doc.LoadFromFile(input); PdfNewDocument newDoc = new PdfNewDocument(); newDoc.Conformance = PdfConformanceLevel.Pdf_A1B; foreach (PdfPageBase page in doc.Pages) { SizeF size = page.Size; PdfPageBase p = newDoc.Pages.Add(size, new Spire.Pdf.Graphics.PdfMargins(0)); page.CreateTemplate().Draw(p, 0, 0); } string output = "ToPDFA.pdf"; newDoc.Save(output); newDoc.Close(); //Launching the result file. PDFDocumentViewer(output); }
private void button1_Click(object sender, EventArgs e) { //Create a pdf document. PdfNewDocument doc = new PdfNewDocument(); // Create one page PdfPageBase page = doc.Pages.Add(); //Draw the page DrawPage(page); String pfxPath = @"..\..\..\..\..\..\Data\Demo.pfx"; PdfCertificate cert = new PdfCertificate(pfxPath, "e-iceblue"); PdfSignature signature = new PdfSignature(doc, page, cert, "demo"); signature.ContactInfo = "Harry Hu"; signature.Certificated = true; signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill; //Save pdf file. doc.Save("DigitalSignature.pdf"); doc.Close(); //Launching the Pdf file. PDFDocumentViewer("DigitalSignature.pdf"); }
private void button1_Click(object sender, EventArgs e) { //Pdf file String input = @"..\..\..\..\..\..\Data\SamplePDFA.pdf"; //Open pdf document PdfDocument doc = new PdfDocument(); doc.LoadFromFile(input); //Create a new pdf and draw content on new file PdfNewDocument newDoc = new PdfNewDocument(); newDoc.CompressionLevel = PdfCompressionLevel.None; foreach (PdfPageBase page in doc.Pages) { SizeF size = page.Size; PdfPageBase p = newDoc.Pages.Add(size, new Spire.Pdf.Graphics.PdfMargins(0)); page.CreateTemplate().Draw(p, 0, 0); } string output = "PDFAToPdf-result.pdf"; newDoc.Save(output); newDoc.Close(); //Launch the Pdf file PDFDocumentViewer(output); }
private void button1_Click(object sender, EventArgs e) { //Pdf file String input = @"..\..\..\..\..\..\Data\SampleB_2.pdf"; //Open pdf document PdfDocument doc = new PdfDocument(); doc.LoadFromFile(input); PdfNewDocument newDoc = new PdfNewDocument(); //Set Pdf_A1B newDoc.Conformance = PdfConformanceLevel.Pdf_A1B; foreach (PdfPageBase page in doc.Pages) { SizeF size = page.Size; PdfPageBase p = newDoc.Pages.Add(size, new Spire.Pdf.Graphics.PdfMargins(0)); page.CreateTemplate().Draw(p, 0, 0); } //Load files and add in attachments byte[] data = File.ReadAllBytes(@"..\..\..\..\..\..\Data\SampleB_1.png"); PdfAttachment attach1 = new PdfAttachment("attachment1.png", data); byte[] data2 = File.ReadAllBytes(@"..\..\..\..\..\..\Data\SampleB_1.pdf"); PdfAttachment attach2 = new PdfAttachment("attachment2.pdf", data2); newDoc.Attachments.Add(attach1); newDoc.Attachments.Add(attach2); string output = "ToPDFAWithAttachments-result.pdf"; newDoc.Save(output); newDoc.Close(); //Launch the reuslt file PDFDocumentViewer(output); }