/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream s1, Stream s2) { PDFFixedDocument document = new PDFFixedDocument(); document.DisplayMode = PDFDisplayMode.UseAttachments; PDFStandardFont helvetica = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16); PDFBrush blackBrush = new PDFBrush(); PDFPage page = document.Pages.Add(); page.Canvas.DrawString("This document contains 2 file attachments:", helvetica, blackBrush, 50, 50); page.Canvas.DrawString("1. fileattachments.cs.html", helvetica, blackBrush, 50, 70); page.Canvas.DrawString("2. fileattachments.vb.html", helvetica, blackBrush, 50, 90); byte[] fileData1 = new byte[s1.Length]; s1.Read(fileData1, 0, fileData1.Length); PDFDocumentFileAttachment fileAttachment1 = new PDFDocumentFileAttachment(); fileAttachment1.Payload = fileData1; fileAttachment1.FileName = "fileattachments.cs.html"; fileAttachment1.Description = "C# Source Code for FileAttachments sample"; document.FileAttachments.Add(fileAttachment1); byte[] fileData2 = new byte[s2.Length]; s2.Read(fileData2, 0, fileData2.Length); PDFDocumentFileAttachment fileAttachment2 = new PDFDocumentFileAttachment(); fileAttachment2.Payload = fileData1; fileAttachment2.FileName = "fileattachments.vb.html"; fileAttachment2.Description = "VB.NET Source Code for FileAttachments sample"; document.FileAttachments.Add(fileAttachment2); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "fileattachments.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run() { PDFFixedDocument document = new PDFFixedDocument(); PDFStandardFont titleFont = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 16); PDFStandardFont barcodeFont = new PDFStandardFont(PDFStandardFontFace.Helvetica, 12); PDFPage page = document.Pages.Add(); DrawGenericBarcodes(page, titleFont, barcodeFont); page = document.Pages.Add(); DrawPharmaBarcodes(page, titleFont, barcodeFont); page = document.Pages.Add(); DrawEanUpcBarcodes(page, titleFont, barcodeFont); page = document.Pages.Add(); DrawPostAndTransportantionBarcodes(page, titleFont, barcodeFont); page = document.Pages.Add(); Draw2DBarcodes(page, titleFont, barcodeFont); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "barcodes.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream file1Input, Stream file2Input) { PDFFixedDocument document = new PDFFixedDocument(); // The documents are merged by creating an empty PDF document and appending the file to it. // The outlines from the source file are also included in the merged file. document.AppendFile(file1Input); int count = document.Pages.Count; document.AppendFile(file2Input); // Create outlines that point to each merged file. PDFOutlineItem file1Outline = CreateOutline("First file", document.Pages[0]); document.Outline.Add(file1Outline); PDFOutlineItem file2Outline = CreateOutline("Second file", document.Pages[count]); document.Outline.Add(file2Outline); // Optionally we can add a new page at the beginning of the merged document. PDFPage page = new PDFPage(); document.Pages.Insert(0, page); PDFOutlineItem blankPageOutline = CreateOutline("Blank page", page); document.Outline.Insert(0, blankPageOutline); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "documentappend.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { PDFFixedDocument document = new PDFFixedDocument(input); PDFContentRedactor crText = new PDFContentRedactor(document.Pages[0]); // Redact a rectangular area of 200*100 points and leave the redacted area uncovered. crText.RedactArea(new PDFDisplayRectangle(50, 50, 200, 100)); // Redact a rectangular area of 200*100 points and mark the redacted area with red. crText.RedactArea(new PDFDisplayRectangle(50, 350, 200, 100), PDFRgbColor.Red); PDFContentRedactor crImages = new PDFContentRedactor(document.Pages[2]); // Initialize the bulk redaction. crImages.BeginRedaction(); // Prepare for redaction a rectangular area of 500*100 points and leave the redacted area uncovered. crImages.RedactArea(new PDFDisplayRectangle(50, 50, 500, 100)); // Prepare for redaction a rectangular area of 200*100 points and mark the redacted area with red. crImages.RedactArea(new PDFDisplayRectangle(50, 350, 500, 100), PDFRgbColor.Red); // When images are redacted, the cleared pixels are set to 0. Depending on image colorspace the redacted area can appear black or colored. // Finish the redaction crImages.ApplyRedaction(); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "redaction.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { PDFRc4SecurityHandler rc4_40 = new PDFRc4SecurityHandler(); PDFFixedDocument document1 = EncryptRC4(40, rc4_40); PDFRc4SecurityHandler rc4_128 = new PDFRc4SecurityHandler(); PDFFixedDocument document2 = EncryptRC4(128, rc4_128); PDFAesSecurityHandler aes128 = new PDFAesSecurityHandler(); PDFFixedDocument document3 = EncryptAES(128, aes128); PDFAesSecurityHandler aes256 = new PDFAesSecurityHandler(); PDFFixedDocument document4 = EncryptAES(256, aes256); PDFAesSecurityHandler aes256e = new PDFAesSecurityHandler(); aes256e.UseEnhancedPasswordValidation = true; PDFFixedDocument document5 = EncryptAES(256, aes256e); PDFFixedDocument document6 = Decrypt(input); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document1, "encryption.rc4.40bit.pdf", rc4_40), new SampleOutputInfo(document2, "encryption.rc4.128bit.pdf", rc4_128), new SampleOutputInfo(document3, "encryption.aes.128bit.pdf", aes128), new SampleOutputInfo(document4, "encryption.aes.256bit.pdf", aes256), new SampleOutputInfo(document5, "encryption.aes.256bit.enhanced.pdf", aes256e), new SampleOutputInfo(document6, "encryption.decrypted.pdf"), }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { PDFFile file = new PDFFile(input); PDFPageContent[] content = file.ExtractPageContent(0, file.PageCount - 1); file = null; PDFFixedDocument document = new PDFFixedDocument(); PDFPage page1 = document.Pages.Add(); // Draw the same page content 4 times on the new page, the content is scaled to half and flipped. page1.Canvas.DrawFormXObject(content[0], 0, 0, page1.Width / 2, page1.Height / 2); page1.Canvas.DrawFormXObject(content[0], page1.Width / 2, 0, page1.Width / 2, page1.Height / 2, 0, PDFFlipDirection.VerticalFlip); page1.Canvas.DrawFormXObject(content[0], 0, page1.Height / 2, page1.Width / 2, page1.Height / 2, 0, PDFFlipDirection.HorizontalFlip); page1.Canvas.DrawFormXObject(content[0], page1.Width / 2, page1.Height / 2, page1.Width / 2, page1.Height / 2, 0, PDFFlipDirection.VerticalFlip | PDFFlipDirection.HorizontalFlip); PDFPage page2 = document.Pages.Add(); // Draw 3 pages on the new page. page2.Canvas.DrawFormXObject(content[0], 0, 0, page2.Width / 2, page2.Height / 2); page2.Canvas.DrawFormXObject(content[1], page2.Width / 2, 0, page2.Width / 2, page2.Height / 2); page2.Canvas.DrawFormXObject(content[2], 0, page2.Height, page2.Height / 2, page2.Width, 90); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "pageimposition.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream verdanaFontStream, Stream verdanaBoldFontStream, Stream logoImageStream) { PDFAnsiTrueTypeFont verdana = new PDFAnsiTrueTypeFont(verdanaFontStream, 10, true); PDFAnsiTrueTypeFont verdanaBold = new PDFAnsiTrueTypeFont(verdanaBoldFontStream, 10, true); PDFPngImage logoImage = new PDFPngImage(logoImageStream); PDFFlowDocument document = new PDFFlowDocument(); PDFFlowContent header = BuildHeader(verdana, logoImage); document.AddContent(header); PDFFlowContent sellerSection = BuildSellerSection(verdana, verdanaBold); document.AddContent(sellerSection); PDFFlowContent invoiceInfoSection = BuildInvoiceInfoSection(verdana, verdanaBold); document.AddContent(invoiceInfoSection); PDFFlowContent buyerSection = BuildBuyerSection(verdana, verdanaBold); document.AddContent(buyerSection); PDFFlowContent invoiceItemsSection = BuildInvoiceItemsSection(verdana, verdanaBold); document.AddContent(invoiceItemsSection); PDFFlowContent endSection = BuildEndSection(verdana); document.AddContent(endSection); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "invoice.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream verdanaFontStream, Stream verdanaBoldFontStream) { HeadersAndFooters hf = new HeadersAndFooters(); PDFFlowDocument document = hf.CreateDocument(verdanaFontStream, verdanaBoldFontStream); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "headersandfooters.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { PDFFixedDocument document = new PDFFixedDocument(); PDFPage page = document.Pages.Add(); PDFSvgDrawing svg = new PDFSvgDrawing(input); page.Canvas.DrawFormXObject(svg, 20, 20, page.Width - 40, page.Width - 40); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "svgtopdf.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { // Load the input file. PDFFixedDocument document = new PDFFixedDocument(input); PDFConvertToGrayTransform grayTransform = new PDFConvertToGrayTransform(); PDFPageTransformer pageTransformer = new PDFPageTransformer(document.Pages[3]); pageTransformer.ApplyTransform(grayTransform); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "grayscaleconversion.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream formStream, SignatureTimestampNeeded onTimeStamp) { PDFFixedDocument document = new PDFFixedDocument(formStream); PDFSignatureField signField = document.Form.Fields["signhere"] as PDFSignatureField; signField.Signature = new PDFDocumentTimeStamp(); signField.Signature.TimestampDigestAlgorithm = PDFDigitalSignatureDigestAlgorithm.Sha256; signField.Signature.OnSignatureTimestampNeeded += onTimeStamp; SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "documenttimestamp.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { PDFFixedDocument document = new PDFFixedDocument(); PDFTiffImage tiff = new PDFTiffImage(input); for (int i = 0; i < tiff.FrameCount; i++) { tiff.ActiveFrame = i; PDFPage page = document.Pages.Add(); page.Canvas.DrawImage(tiff, 0, 0, page.Width, page.Height); } SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "tifftopdf.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream iccInput, Stream ttfInput) { PDFFixedDocument pdfa1bDocument = CreatePDFA1bDocument(iccInput, ttfInput); PDFFixedDocument pdfa2uDocument = CreatePDFA2uDocument(iccInput, ttfInput); PDFFixedDocument pdfa3uDocument = CreatePDFA3uDocument(iccInput, ttfInput); // The document is formatted as PDF/A using the PDFAFormatter class: // PDFAFormatter.Save(document, outputStream, PDFAFormat.PDFA1b); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(pdfa1bDocument, "pdfa1b.pdf"), new SampleOutputInfo(pdfa2uDocument, "pdfa2u.pdf"), new SampleOutputInfo(pdfa3uDocument, "pdfa3u.pdf"), }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { // Load the input file. PDFFixedDocument document = new PDFFixedDocument(input); PDFReplaceImageTransform replaceImageTransform = new PDFReplaceImageTransform(); replaceImageTransform.ReplaceImage += new EventHandler <PDFReplaceImageEventArgs>(HandleReplaceImage); PDFPageTransformer pageTransformer = new PDFPageTransformer(document.Pages[2]); pageTransformer.ApplyTransform(replaceImageTransform); replaceImageTransform.ReplaceImage -= new EventHandler <PDFReplaceImageEventArgs>(HandleReplaceImage); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "removereplaceimages.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream verdanaFontStream) { PDFAnsiTrueTypeFont verdana = new PDFAnsiTrueTypeFont(verdanaFontStream, 36, true); PDFFlowDocument document = new PDFFlowDocument(); PDFFlowContent superscriptSection = BuildSuperscript(verdana); document.AddContent(superscriptSection); PDFFlowContent subscriptSection = BuildSubscript(verdana); document.AddContent(subscriptSection); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "superscriptsubscript.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run() { PDFFixedDocument document = new PDFFixedDocument(); PDFStandardFont helveticaBold = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 16); PDFPage page = document.Pages.Add(); DrawTextLines(page, helveticaBold); page = document.Pages.Add(); DrawTextWrap(page, helveticaBold); page = document.Pages.Add(); DrawTextRenderingModes(page, helveticaBold); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "text.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream verdanaFontStream, Stream verdanaBoldFontStream, Stream data) { PDFAnsiTrueTypeFont verdana = new PDFAnsiTrueTypeFont(verdanaFontStream, 1, true); PDFAnsiTrueTypeFont verdanaBold = new PDFAnsiTrueTypeFont(verdanaBoldFontStream, 1, true); PDFFlowDocument document = new PDFFlowDocument(); PDFFlowContent header = BuildHeader(verdanaBold); document.AddContent(header); PDFFlowContent attendantsSection = BuildCountriesList(verdana, verdanaBold, data); document.AddContent(attendantsSection); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "tablegroups.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream formStream, X509Certificate2 certificate) { PDFFixedDocument document = new PDFFixedDocument(formStream); PDFSignatureField signField = document.Form.Fields["signhere"] as PDFSignatureField; PDFCmsDigitalSignature signature = new PDFCmsDigitalSignature(); signature.SignatureDigestAlgorithm = PDFDigitalSignatureDigestAlgorithm.Sha256; signature.Certificate = certificate; signature.ContactInfo = "*****@*****.**"; signature.Location = "Cluj Napoca"; signature.Name = "O2 Solutions Support"; signature.Reason = "Simple signature"; signField.Signature = signature; SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "simplesignature.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { // The input file is split by extracting pages from source file and inserting them in new empty PDF documents. PDFFile file = new PDFFile(input); SampleOutputInfo[] output = new SampleOutputInfo[file.PageCount]; for (int i = 0; i < file.PageCount; i++) { PDFFixedDocument document = new PDFFixedDocument(); PDFPage page = file.ExtractPage(i); document.Pages.Add(page); output[i] = new SampleOutputInfo(document, string.Format("documentsplit.{0}.pdf", i + 1)); } return(output); }
/// <summary> /// Main method for running the sample. /// </summary> /// <param name="stream"></param> public static SampleOutputInfo[] Run(Stream stream) { PDFFixedDocument document = new PDFFixedDocument(stream); (document.Form.Fields["firstname"] as PDFTextBoxField).Text = "John"; (document.Form.Fields["lastname"] as PDFTextBoxField).Value = "Doe"; (document.Form.Fields["sex"].Widgets[0] as PDFRadioButtonWidget).Checked = true; (document.Form.Fields["firstcar"] as PDFDropDownListField).SelectedIndex = 0; (document.Form.Fields["secondcar"] as PDFListBoxField).SelectedIndex = 1; (document.Form.Fields["agree"] as PDFCheckBoxField).Checked = true; document.Form.FlattenFields(); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "formfill.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> /// <param name="imageStream"></param> /// <param name="cmykImageStream"></param> /// <param name="softMaskStream"></param> /// <param name="stencilMaskStream"></param> public static SampleOutputInfo[] Run(Stream imageStream, Stream cmykImageStream, Stream softMaskStream, Stream stencilMaskStream) { PDFFixedDocument document = new PDFFixedDocument(); PDFStandardFont helveticaBoldTitle = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 16); PDFStandardFont helveticaSection = new PDFStandardFont(PDFStandardFontFace.Helvetica, 10); PDFPage page = document.Pages.Add(); DrawImages(page, imageStream, helveticaBoldTitle, helveticaSection); page = document.Pages.Add(); DrawImageMasks(page, imageStream, softMaskStream, stencilMaskStream, helveticaBoldTitle, helveticaSection); page = document.Pages.Add(); DrawCmykTiff(page, cmykImageStream, helveticaBoldTitle); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "images.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> /// <param name="iccStream"></param> public static SampleOutputInfo[] Run(Stream iccStream) { PDFFixedDocument document = new PDFFixedDocument(); PDFStandardFont helveticaBoldTitle = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 16); PDFStandardFont helveticaSection = new PDFStandardFont(PDFStandardFontFace.Helvetica, 10); PDFPage page = document.Pages.Add(); DrawLines(page, helveticaBoldTitle, helveticaSection); page = document.Pages.Add(); DrawRectangles(page, helveticaBoldTitle, helveticaSection); page = document.Pages.Add(); DrawRoundRectangles(page, helveticaBoldTitle, helveticaSection); page = document.Pages.Add(); DrawEllipses(page, helveticaBoldTitle, helveticaSection); page = document.Pages.Add(); DrawArcsAndPies(page, helveticaBoldTitle, helveticaSection); page = document.Pages.Add(); DrawBezierCurves(page, helveticaBoldTitle, helveticaSection); page = document.Pages.Add(); DrawAffineTransformations(page, helveticaBoldTitle, helveticaSection); page = document.Pages.Add(); DrawColorsAndColorSpaces(page, helveticaBoldTitle, helveticaSection, iccStream); page = document.Pages.Add(); DrawShadings(page, helveticaBoldTitle, helveticaSection); page = document.Pages.Add(); DrawPatterns(page, helveticaBoldTitle, helveticaSection); page = document.Pages.Add(); DrawFormXObjects(page, helveticaBoldTitle, helveticaSection); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "vectorgraphics.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { // Load the input file. PDFFixedDocument document = new PDFFixedDocument(input); ExtractTextAndHighlight(document); ExtractTextAndHighlightGlyphs(document); ExtractImagesAndHighlight(document); // Compress the page graphic content. for (int i = 0; i < document.Pages.Count; i++) { document.Pages[i].Canvas.CompressAndClose(); } SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "contentextraction.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { // Load the input file. PDFFixedDocument document = new PDFFixedDocument(input); DrawWatermarkUnderPageContent(document.Pages[0]); DrawWatermarkOverPageContent(document.Pages[1]); DrawWatermarkWithTransparency(document.Pages[2]); // Compress the page graphic content. for (int i = 0; i < document.Pages.Count; i++) { document.Pages[i].Canvas.CompressAndClose(); } SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "watermarks.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream ttfStream) { PDFFixedDocument document = new PDFFixedDocument(); PDFPage page = document.Pages.Add(); DrawStandardFonts(page); page = document.Pages.Add(); DrawStandardCjkFonts(page); page = document.Pages.Add(); DrawTrueTypeFonts(page, ttfStream); page = document.Pages.Add(); DisableTextCopy(page, ttfStream); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "fonts.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { // Load the input file. PDFFixedDocument document = new PDFFixedDocument(input); PDFBatesNumberAppearance bna = new PDFBatesNumberAppearance(); bna.Location = new PDFPoint(25, 5); bna.Brush = new PDFBrush(PDFRgbColor.DarkRed); PDFBatesNumberProvider bnp = new PDFBatesNumberProvider(); bnp.Prefix = "O2S"; bnp.Suffix = "PDF4NET"; bnp.StartNumber = 1; PDFBatesNumber.WriteBatesNumber(document, bnp, bna); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "batesnumbers.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { PDFFixedDocument document = new PDFFixedDocument(input); PDFContentExtractor ce = new PDFContentExtractor(document.Pages[0]); // Simple search. PDFTextSearchResultCollection searchResults = ce.SearchText("at"); HighlightSearchResults(document.Pages[0], searchResults, PDFRgbColor.Red); // Whole words search. searchResults = ce.SearchText("at", PDFTextSearchOptions.WholeWordSearch); HighlightSearchResults(document.Pages[0], searchResults, PDFRgbColor.Green); // Regular expression search, find all words that start with uppercase. searchResults = ce.SearchText("[A-Z][a-z]*", PDFTextSearchOptions.RegExSearch); HighlightSearchResults(document.Pages[0], searchResults, PDFRgbColor.Blue); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "searchtext.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream flashStream, Stream u3dStream) { // Create a PDF document with 10 pages. PDFFixedDocument document = new PDFFixedDocument(); PDFStandardFont helvetica = new PDFStandardFont(PDFStandardFontFace.Helvetica, 12); CreateTextAnnotations(document, helvetica); CreateSquareCircleAnnotations(document, helvetica); CreateFileAttachmentAnnotations(document, helvetica); CreateInkAnnotations(document, helvetica); CreateLineAnnotations(document, helvetica); CreatePolygonAnnotations(document, helvetica); CreatePolylineAnnotations(document, helvetica); CreateRubberStampAnnotations(document, helvetica); CreateTextMarkupAnnotations(document, helvetica); CreateRichMediaAnnotations(document, helvetica, flashStream); Create3DAnnotations(document, helvetica, u3dStream); CreateRedactionAnnotations(document, helvetica, u3dStream); // Compress the page graphic content. for (int i = 0; i < document.Pages.Count; i++) { document.Pages[i].Canvas.CompressAndClose(); } SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "annotations.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run() { PDFFixedDocument document = new PDFFixedDocument(); document.Pages.Add(); // Display the document in full screen mode. document.DisplayMode = PDFDisplayMode.FullScreen; // Fill the document information. document.DocumentInformation = new PDFDocumentInformation(); document.DocumentInformation.Author = "O2 Solutions"; document.DocumentInformation.CreationDate = DateTime.Now; document.DocumentInformation.ModifyDate = DateTime.Now; document.DocumentInformation.Creator = "O2S.Components.PDF4NET DocumentProperties sample"; document.DocumentInformation.Producer = "O2S.Components.PDF4NET"; document.DocumentInformation.Title = "O2S.Components.PDF4NET DocumentProperties sample"; document.DocumentInformation.Subject = "O2S.Components.PDF4NET sample code"; document.DocumentInformation.Keywords = "pdf4net,pdf,sample"; // Set custom metadata in the XMP metadata. document.XmpMetadata = new PDFXmpMetadata(); // This custom metadata will appear as a child of 'xmpmeta' root node. document.XmpMetadata.Metadata = "<custom>Custom metadata</custom>"; // Set the viewer preferences. document.ViewerPreferences = new PDFViewerPreferences(); document.ViewerPreferences.CenterWindow = true; document.ViewerPreferences.DisplayDocumentTitle = true; document.ViewerPreferences.HideMenubar = true; document.ViewerPreferences.HideToolbar = true; document.ViewerPreferences.HideWindowUI = true; document.ViewerPreferences.PrintScaling = PDFPrintScaling.None; // Set the PDF version. document.PDFVersion = PDFVersion.Version15; SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "documentproperties.pdf") }; return(output); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { PDFFile file = new PDFFile(input); PDFFixedDocument document = new PDFFixedDocument(); PDFPage page = document.Pages.Add(); PDFPageOptionalContent oc1 = file.ExtractPageOptionalContentGroup(4, "1"); page.Canvas.DrawFormXObject(oc1, 0, 0, page.Width / 2, page.Height / 2); PDFPageOptionalContent oc2 = file.ExtractPageOptionalContentGroup(4, "2"); page.Canvas.DrawFormXObject(oc2, page.Width / 2, 0, page.Width / 2, page.Height / 2); PDFPageOptionalContent oc3 = file.ExtractPageOptionalContentGroup(4, "3"); page.Canvas.DrawFormXObject(oc3, 0, page.Height / 2, page.Width / 2, page.Height / 2); PDFPageOptionalContent oc4 = file.ExtractPageOptionalContentGroup(4, "4"); page.Canvas.DrawFormXObject(oc4, page.Width / 2, page.Height / 2, page.Width / 2, page.Height / 2); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "optionalcontentextraction.pdf") }; return(output); }