/// <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.Graphics.DrawString("This document contains 2 file attachments:", helvetica, blackBrush, 50, 50); page.Graphics.DrawString("1. fileattachments.cs.html", helvetica, blackBrush, 50, 70); page.Graphics.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, "xfinium.pdf.sample.fileattachments.pdf") }; return output; }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run() { // Create a PDF document with 10 pages. PdfFixedDocument document = new PdfFixedDocument(); PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 216); PdfBrush blackBrush = new PdfBrush(); for (int i = 0; i < 10; i++) { PdfPage page = document.Pages.Add(); page.Graphics.DrawString((i + 1).ToString(), helvetica, blackBrush, 5, 5); } CreateNamedActions(document, helvetica); CreateGoToActions(document, helvetica); CreateRemoteGoToActions(document, helvetica); CreateLaunchActions(document, helvetica); CreateUriActions(document, helvetica); CreateJavaScriptActions(document, helvetica); CreateDocumentActions(document); // Compress the page graphic content. for (int i = 0; i < document.Pages.Count; i++) { document.Pages[i].Graphics.CompressAndClose(); } SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.actions.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.Graphics.DrawFormXObject(content[0], 0, 0, page1.Width / 2, page1.Height / 2); page1.Graphics.DrawFormXObject(content[0], page1.Width / 2, 0, page1.Width / 2, page1.Height / 2, 0, PdfFlipDirection.VerticalFlip); page1.Graphics.DrawFormXObject(content[0], 0, page1.Height / 2, page1.Width / 2, page1.Height / 2, 0, PdfFlipDirection.HorizontalFlip); page1.Graphics.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.Graphics.DrawFormXObject(content[0], 0, 0, page2.Width / 2, page2.Height / 2); page2.Graphics.DrawFormXObject(content[1], page2.Width / 2, 0, page2.Width / 2, page2.Height / 2); page2.Graphics.DrawFormXObject(content[2], 0, page2.Height, page2.Height / 2, page2.Width, 90); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.pageimposition.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, "xfinium.pdf.sample.encryption.rc4.40bit.pdf", rc4_40), new SampleOutputInfo(document2, "xfinium.pdf.sample.encryption.rc4.128bit.pdf", rc4_128), new SampleOutputInfo(document3, "xfinium.pdf.sample.encryption.aes.128bit.pdf", aes128), new SampleOutputInfo(document4, "xfinium.pdf.sample.encryption.aes.256bit.pdf", aes256), new SampleOutputInfo(document5, "xfinium.pdf.sample.encryption.aes.256bit.enhanced.pdf", aes256e), new SampleOutputInfo(document6, "xfinium.pdf.sample.encryption.decrypted.pdf"), }; return output; }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run() { PdfFixedDocument document = new PdfFixedDocument(); document.DisplayMode = PdfDisplayMode.UseOutlines; PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 216); PdfBrush blackBrush = new PdfBrush(); for (int i = 0; i < 10; i++) { PdfPage page = document.Pages.Add(); page.Graphics.DrawString((i + 1).ToString(), helvetica, blackBrush, 50, 50); } PdfOutlineItem root = new PdfOutlineItem(); root.Title = "Contents"; root.VisualStyle = PdfOutlineItemVisualStyle.Bold; root.Color = new PdfRgbColor(255, 0, 0); document.Outline.Add(root); for (int i = 0; i < document.Pages.Count; i++) { // Create a destination to target page. PdfPageDirectDestination pageDestination = new PdfPageDirectDestination(); pageDestination.Page = document.Pages[i]; pageDestination.Top = 0; pageDestination.Left = 0; // Inherit current zoom pageDestination.Zoom = 0; // Create a go to action to be executed when the outline is clicked, // the go to action goes to specified destination. PdfGoToAction gotoPage = new PdfGoToAction(); gotoPage.Destination = pageDestination; // Create the outline in the table of contents PdfOutlineItem outline = new PdfOutlineItem(); outline.Title = string.Format("Go to page {0}", i + 1); outline.VisualStyle = PdfOutlineItemVisualStyle.Italic; outline.Action = gotoPage; root.Items.Add(outline); } root.Expanded = true; // Create an outline that will launch a link in the browser. PdfUriAction uriAction = new PdfUriAction(); uriAction.URI = "http://www.xfiniumsoft.com/"; PdfOutlineItem webOutline = new PdfOutlineItem(); webOutline.Title = "http://www.xfiniumsoft.com/"; webOutline.Color = new PdfRgbColor(0, 0, 255); webOutline.Action = uriAction; document.Outline.Add(webOutline); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.outlines.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.Graphics.DrawFormXObject(svg, 20, 20, page.Width - 40, page.Width - 40); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.svgtopdf.pdf") }; return output; }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream iccInput, Stream ttfInput) { PdfFixedDocument document = new PdfFixedDocument(); // Setup the document by creating a PDF/A output intent, based on a RGB ICC profile, // and document information and metadata PdfIccColorSpace icc = new PdfIccColorSpace(); byte[] profilePayload = new byte[iccInput.Length]; iccInput.Read(profilePayload, 0, profilePayload.Length); icc.IccProfile = profilePayload; PdfOutputIntent oi = new PdfOutputIntent(); oi.Type = PdfOutputIntentType.PdfA1; oi.Info = "sRGB IEC61966-2.1"; oi.OutputConditionIdentifier = "Custom"; oi.DestinationOutputProfile = icc; document.OutputIntents = new PdfOutputIntentCollection(); document.OutputIntents.Add(oi); document.DocumentInformation = new PdfDocumentInformation(); document.DocumentInformation.Author = "XFINIUM Software"; document.DocumentInformation.Title = "XFINIUM.PDF PDF/A-1B Demo"; document.DocumentInformation.Creator = "XFINIUM.PDF PDF/A-1B Demo"; document.DocumentInformation.Producer = "XFINIUM.PDF"; document.DocumentInformation.Keywords = "pdf/a"; document.DocumentInformation.Subject = "PDF/A-1B Sample produced by XFINIUM.PDF"; document.XmpMetadata = new PdfXmpMetadata(); PdfPage page = document.Pages.Add(); page.Rotation = 90; // All fonts must be embedded in a PDF/A document. PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions(); sao.Font = new PdfAnsiTrueTypeFont(ttfInput, 24, true); sao.Brush = new PdfBrush(new PdfRgbColor(0, 0, 128)); PdfStringLayoutOptions slo = new PdfStringLayoutOptions(); slo.HorizontalAlign = PdfStringHorizontalAlign.Center; slo.VerticalAlign = PdfStringVerticalAlign.Bottom; slo.X = page.Width / 2; slo.Y = page.Height / 2 - 10; page.Graphics.DrawString("XFINIUM.PDF", sao, slo); slo.Y = page.Height / 2 + 10; slo.VerticalAlign = PdfStringVerticalAlign.Top; sao.Font.Size = 16; page.Graphics.DrawString("This is a sample PDF/A document that shows the PDF/A capabilities in XFINIUM.PDF library", sao, slo); // The document is formatted as PDF/A using the PdfAFormatter class: // PdfAFormatter.Save(document, outputStream, PdfAFormat.PdfA1b); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.pdfa.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, "xfinium.pdf.sample.removereplaceimages.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.Graphics.DrawImage(tiff, 0, 0, page.Width, page.Height); } SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.tifftopdf.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("xfinium.pdf.sample.documentsplit.{0}.pdf", i + 1)); } 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, "xfinium.pdf.sample.text.pdf") }; 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 PdfComboBoxField).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, "xfinium.pdf.sample.formfill.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, "xfinium.pdf.sample.fonts.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.Graphics.DrawFormXObject(oc1, 0, 0, page.Width / 2, page.Height / 2); PdfPageOptionalContent oc2 = file.ExtractPageOptionalContentGroup(4, "2"); page.Graphics.DrawFormXObject(oc2, page.Width / 2, 0, page.Width / 2, page.Height / 2); PdfPageOptionalContent oc3 = file.ExtractPageOptionalContentGroup(4, "3"); page.Graphics.DrawFormXObject(oc3, 0, page.Height / 2, page.Width / 2, page.Height / 2); PdfPageOptionalContent oc4 = file.ExtractPageOptionalContentGroup(4, "4"); page.Graphics.DrawFormXObject(oc4, page.Width / 2, page.Height / 2, page.Width / 2, page.Height / 2); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.optionalcontentextraction.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 = "XFINIUM"; bnp.Suffix = "PDF"; bnp.StartNumber = 1; PdfBatesNumber.WriteBatesNumber(document, bnp, bna); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.batesnumbers.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, "xfinium.pdf.sample.vectorgraphics.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, "xfinium.pdf.sample.searchtext.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].Graphics.CompressAndClose(); } SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.watermarks.pdf") }; return output; }
static void Main(string[] args) { string supportPath = ".\\..\\..\\..\\..\\..\\Support\\"; FileStream logoStream = new FileStream(supportPath + "logo.png", FileMode.Open, FileAccess.Read, FileShare.Read); FileStream verdanaStream = new FileStream(supportPath + "verdana.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); FileStream verdanaBoldStream = new FileStream(supportPath + "verdanab.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); SampleOutputInfo output = O2S.Components.PDF4NET.Samples.PDFUA.Run(verdanaStream, verdanaBoldStream, logoStream); logoStream.Dispose(); verdanaStream.Dispose(); verdanaBoldStream.Dispose(); FileStream outStream = File.OpenWrite(output.FileName); PDFUAFormatter.Save(output.Document as PDFFixedDocument, outStream, PDFUAFormat.PDFUA1); outStream.Flush(); outStream.Dispose(); Console.WriteLine("File(s) saved with success to current folder."); }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream formStream, X509Certificate2 certificate) { PDFFixedDocument document = new PDFFixedDocument(formStream); document.PDFVersion = PDFVersion.Version16; 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 = "Certifying signature"; signField.Signature = signature; // Certify the document with the signature included in the field. document.CertifyDocument(signField, PDFDigitalSignatureAllowedChanges.AllowFormFilling); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "certifyingsignature.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].Graphics.CompressAndClose(); } SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.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 = "Xfinium Software"; document.DocumentInformation.CreationDate = DateTime.Now; document.DocumentInformation.ModifyDate = DateTime.Now; document.DocumentInformation.Creator = "Xfinium.Pdf DocumentProperties sample"; document.DocumentInformation.Producer = "Xfinium.Pdf"; document.DocumentInformation.Title = "Xfinium.Pdf DocumentProperties sample"; document.DocumentInformation.Subject = "Xfinium.Pdf sample code"; document.DocumentInformation.Keywords = "xfinium.pdf,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, "xfinium.pdf.sample.documentproperties.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 PdfVisualRectangle(50, 50, 200, 100)); // Redact a rectangular area of 200*100 points and mark the redacted area with red. crText.RedactArea(new PdfVisualRectangle(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 PdfVisualRectangle(50, 50, 500, 100)); // Prepare for redaction a rectangular area of 200*100 points and mark the redacted area with red. crImages.RedactArea(new PdfVisualRectangle(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, "xfinium.pdf.sample.redaction.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, "xfinium.pdf.sample.barcodes.pdf") }; return output; }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run() { // Create the pdf document PdfFixedDocument document = new PdfFixedDocument(); // Create a new page in the document PdfPage page = document.Pages.Add(); PdfPen blackPen = new PdfPen(PdfRgbColor.Black, 1); PdfPen redPen = new PdfPen(PdfRgbColor.Red, 4); PdfPen greenPen = new PdfPen(PdfRgbColor.Green, 2); PdfBrush blackBrush = new PdfBrush(PdfRgbColor.Black); PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 16); // Draw viewport border. page.Graphics.DrawRectangle(blackPen, 50, 50, 500, 500); // Draw the line to be measured. page.Graphics.DrawLine(greenPen, 70, 70, 530, 530); // Draw point A (line start) in the viewport. page.Graphics.DrawLine(redPen, 60, 70, 80, 70); page.Graphics.DrawLine(redPen, 70, 60, 70, 80); // Draw point B (line end) in the viewport. page.Graphics.DrawLine(redPen, 520, 530, 540, 530); page.Graphics.DrawLine(redPen, 530, 520, 530, 540); page.Graphics.DrawString("A", helvetica, blackBrush, 85, 65); page.Graphics.DrawString("B", helvetica, blackBrush, 505, 525); page.Graphics.DrawString("Viewport", helvetica, blackBrush, 50, 560); helvetica.Size = 10; page.Graphics.DrawString( "Open the file with Adobe Acrobat and measure the distance from A to B using the Distance tool.", helvetica, blackBrush, 50, 580); page.Graphics.DrawString("The measured distance should be 9 mi 186 ft 1 1/4 in.", helvetica, blackBrush, 50, 590); // Create a viewport that matches the rectangle above. PdfViewport vp = new PdfViewport(); vp.Name = "Sample viewport"; PdfPoint ll = page.ConvertVisualPointToStandardPoint(new PdfPoint(50, 50)); PdfPoint ur = page.ConvertVisualPointToStandardPoint(new PdfPoint(550, 550)); vp.Bounds = new PdfStandardRectangle(ll, ur); // Add the viewport to the page page.Viewports = new PdfViewportCollection(); page.Viewports.Add(vp); // Create a rectilinear measure for the viewport (CAD drawing for example). PdfRectilinearMeasure rlm = new PdfRectilinearMeasure(); // Attach the measure to the viewport. vp.Measure = rlm; // Set the measure scale: 1 inch (72 points) in PDF corresponds to 1 mile rlm.ScaleRatio = "1 in = 1 mi"; // Create a number format that controls the display of units for X axis. PdfNumberFormat xNumberFormat = new PdfNumberFormat(); xNumberFormat.MeasureUnit = "mi"; xNumberFormat.ConversionFactor = 1/72.0; // Conversion from user space units to miles xNumberFormat.FractionDisplay = PdfFractionDisplay.Decimal; xNumberFormat.Precision = 100000; rlm.X = new PdfNumberFormatCollection(); rlm.X.Add(xNumberFormat); // Create a chain of number formats that control the display of units for distance. rlm.Distance = new PdfNumberFormatCollection(); PdfNumberFormat miNumberFormat = new PdfNumberFormat(); miNumberFormat.MeasureUnit = "mi"; miNumberFormat.ConversionFactor = 1; // Initial unit is miles; no conversion needed rlm.Distance.Add(miNumberFormat); PdfNumberFormat ftNumberFormat = new PdfNumberFormat(); ftNumberFormat.MeasureUnit = "ft"; ftNumberFormat.ConversionFactor = 5280; // Conversion from miles to feet rlm.Distance.Add(ftNumberFormat); PdfNumberFormat inNumberFormat = new PdfNumberFormat(); inNumberFormat.MeasureUnit = "in"; inNumberFormat.ConversionFactor = 12; // Conversion from feet to inches inNumberFormat.FractionDisplay = PdfFractionDisplay.Fraction; inNumberFormat.Denominator = 8; // Fractions of inches rounded to nearest 1/8 rlm.Distance.Add(inNumberFormat); // Create a number format that controls the display of units area. PdfNumberFormat areaNumberFormat = new PdfNumberFormat(); areaNumberFormat.MeasureUnit = "acres"; areaNumberFormat.ConversionFactor = 640; // Conversion from square miles to acres rlm.Area = new PdfNumberFormatCollection(); rlm.Area.Add(xNumberFormat); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.measurements.pdf") }; return output; }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run() { string xfiniumPdfText = "XFINIUM.PDF"; string paragraph1Block2Text = " library is a .NET/Xamarin library for cross-platform PDF development. Code written for "; string paragraph1Block4Text = " can be compiled on all supported platforms without changes. The library features a " + "wide range of capabilities, for both beginers and advanced PDF developers."; string paragraph2Block1Text = "The development style is based on fixed document model, where each page is created as needed " + "and content is placed at fixed position using a grid based layout.\r\n" + "This gives you access to all PDF features, whether you want to create a simple file " + "or you want to create a transparency knockout group at COS level, and lets you build more complex models on top of the library."; string paragraph3Block2Text = " has been developed entirely in C# and it is 100% managed code."; string paragraph4Block1Text = "With "; string paragraph4Block3Text = " you can port your PDF application logic to other platforms with zero effort which means faster time to market."; string paragraph5Block1Text = "Simple licensing per developer with royalty free distribution helps you keep your costs under control."; string paragraph6Block1Text = "SUPPORTED PLATFORMS"; string paragraph7Block1Text = ".NET 2.0 to .NET 4.5"; string paragraph8Block1Text = "Windows Forms"; string paragraph9Block1Text = "ASP.NET Webforms and MVC"; string paragraph10Block1Text = "Console applications"; string paragraph11Block1Text = "Windows services"; string paragraph12Block1Text = "Mono"; string paragraph13Block1Text = "WPF 4.0 & 4.5"; string paragraph14Block1Text = "Silverlight 4 & 5"; string paragraph15Block1Text = "WinRT (Windows Store applications)"; string paragraph16Block1Text = "Windows Phone 7 & 8"; string paragraph17Block1Text = "Xamarin.iOS"; string paragraph18Block1Text = "Xamarin.Android"; PdfStandardFont textFont = new PdfStandardFont(PdfStandardFontFace.Helvetica, 10); PdfFormattedTextBlock xfiniumPdfLinkBlock = new PdfFormattedTextBlock(xfiniumPdfText); xfiniumPdfLinkBlock.Font = new PdfStandardFont(PdfStandardFontFace.HelveticaBold, 10); xfiniumPdfLinkBlock.Font.Underline = true; xfiniumPdfLinkBlock.TextColor = new PdfBrush(PdfRgbColor.Blue); xfiniumPdfLinkBlock.Action = new PdfUriAction("http://xfiniumpdf.com/"); PdfFormattedParagraph paragraph1 = new PdfFormattedParagraph(); paragraph1.LineSpacingMode = PdfFormattedParagraphLineSpacing.Multiple; paragraph1.LineSpacing = 1.2; paragraph1.SpacingAfter = 3; paragraph1.FirstLineIndent = 10; paragraph1.HorizontalAlign = PdfStringHorizontalAlign.Justified; paragraph1.Blocks.Add(xfiniumPdfLinkBlock); paragraph1.Blocks.Add(new PdfFormattedTextBlock(paragraph1Block2Text, textFont)); paragraph1.Blocks.Add(xfiniumPdfLinkBlock); paragraph1.Blocks.Add(new PdfFormattedTextBlock(paragraph1Block4Text, textFont)); PdfFormattedParagraph paragraph2 = new PdfFormattedParagraph(); paragraph2.SpacingAfter = 3; paragraph2.FirstLineIndent = 10; paragraph2.HorizontalAlign = PdfStringHorizontalAlign.Justified; paragraph2.LineSpacingMode = PdfFormattedParagraphLineSpacing.Multiple; paragraph2.LineSpacing = 1.2; paragraph2.Blocks.Add(new PdfFormattedTextBlock(paragraph2Block1Text, textFont)); PdfFormattedParagraph paragraph3 = new PdfFormattedParagraph(); paragraph3.LineSpacingMode = PdfFormattedParagraphLineSpacing.Multiple; paragraph3.LineSpacing = 1.2; paragraph3.SpacingAfter = 3; paragraph3.FirstLineIndent = 10; paragraph3.HorizontalAlign = PdfStringHorizontalAlign.Justified; paragraph3.Blocks.Add(xfiniumPdfLinkBlock); paragraph3.Blocks.Add(new PdfFormattedTextBlock(paragraph3Block2Text, textFont)); PdfFormattedParagraph paragraph4 = new PdfFormattedParagraph(); paragraph4.LineSpacingMode = PdfFormattedParagraphLineSpacing.Multiple; paragraph4.LineSpacing = 1.2; paragraph4.SpacingAfter = 3; paragraph4.FirstLineIndent = 10; paragraph4.HorizontalAlign = PdfStringHorizontalAlign.Justified; paragraph4.Blocks.Add(new PdfFormattedTextBlock(paragraph4Block1Text, textFont)); paragraph4.Blocks.Add(xfiniumPdfLinkBlock); paragraph4.Blocks.Add(new PdfFormattedTextBlock(paragraph4Block3Text, textFont)); PdfFormattedParagraph paragraph5 = new PdfFormattedParagraph(); paragraph5.FirstLineIndent = 10; paragraph5.HorizontalAlign = PdfStringHorizontalAlign.Justified; paragraph5.Blocks.Add(new PdfFormattedTextBlock(paragraph5Block1Text, textFont)); PdfFormattedParagraph paragraph6 = new PdfFormattedParagraph(); paragraph6.SpacingBefore = 10; paragraph6.Blocks.Add(new PdfFormattedTextBlock(paragraph6Block1Text, textFont)); PdfFormattedTextBlock bulletBlock = new PdfFormattedTextBlock("\x76 ", new PdfStandardFont(PdfStandardFontFace.ZapfDingbats, 10)); PdfFormattedParagraph paragraph7 = new PdfFormattedParagraph(); paragraph7.SpacingBefore = 3; paragraph7.Bullet = bulletBlock; paragraph7.LeftIndentation = 10; paragraph7.Blocks.Add(new PdfFormattedTextBlock(paragraph7Block1Text, textFont)); PdfFormattedParagraph paragraph8 = new PdfFormattedParagraph(); paragraph8.SpacingBefore = 3; paragraph8.Bullet = bulletBlock; paragraph8.LeftIndentation = 10; paragraph8.Blocks.Add(new PdfFormattedTextBlock(paragraph8Block1Text, textFont)); PdfFormattedParagraph paragraph9 = new PdfFormattedParagraph(); paragraph9.SpacingBefore = 3; paragraph9.Bullet = bulletBlock; paragraph9.LeftIndentation = 10; paragraph9.Blocks.Add(new PdfFormattedTextBlock(paragraph9Block1Text, textFont)); PdfFormattedParagraph paragraph10 = new PdfFormattedParagraph(); paragraph10.SpacingBefore = 3; paragraph10.Bullet = bulletBlock; paragraph10.LeftIndentation = 10; paragraph10.Blocks.Add(new PdfFormattedTextBlock(paragraph10Block1Text, textFont)); PdfFormattedParagraph paragraph11 = new PdfFormattedParagraph(); paragraph11.SpacingBefore = 3; paragraph11.Bullet = bulletBlock; paragraph11.LeftIndentation = 10; paragraph11.Blocks.Add(new PdfFormattedTextBlock(paragraph11Block1Text, textFont)); PdfFormattedParagraph paragraph12 = new PdfFormattedParagraph(); paragraph12.SpacingBefore = 3; paragraph12.Bullet = bulletBlock; paragraph12.LeftIndentation = 10; paragraph12.Blocks.Add(new PdfFormattedTextBlock(paragraph12Block1Text, textFont)); PdfFormattedParagraph paragraph13 = new PdfFormattedParagraph(); paragraph13.SpacingBefore = 3; paragraph13.Bullet = bulletBlock; paragraph13.LeftIndentation = 10; paragraph13.Blocks.Add(new PdfFormattedTextBlock(paragraph13Block1Text, textFont)); PdfFormattedParagraph paragraph14 = new PdfFormattedParagraph(); paragraph14.SpacingBefore = 3; paragraph14.Bullet = bulletBlock; paragraph14.LeftIndentation = 10; paragraph14.Blocks.Add(new PdfFormattedTextBlock(paragraph14Block1Text, textFont)); PdfFormattedParagraph paragraph15 = new PdfFormattedParagraph(); paragraph15.SpacingBefore = 3; paragraph15.Bullet = bulletBlock; paragraph15.LeftIndentation = 10; paragraph15.Blocks.Add(new PdfFormattedTextBlock(paragraph15Block1Text, textFont)); PdfFormattedParagraph paragraph16 = new PdfFormattedParagraph(); paragraph16.SpacingBefore = 3; paragraph16.Bullet = bulletBlock; paragraph16.LeftIndentation = 10; paragraph16.Blocks.Add(new PdfFormattedTextBlock(paragraph16Block1Text, textFont)); PdfFormattedParagraph paragraph17 = new PdfFormattedParagraph(); paragraph17.SpacingBefore = 3; paragraph17.Bullet = bulletBlock; paragraph17.LeftIndentation = 10; paragraph17.Blocks.Add(new PdfFormattedTextBlock(paragraph17Block1Text, textFont)); PdfFormattedParagraph paragraph18 = new PdfFormattedParagraph(); paragraph18.SpacingBefore = 3; paragraph18.Bullet = bulletBlock; paragraph18.LeftIndentation = 10; paragraph18.Blocks.Add(new PdfFormattedTextBlock(paragraph18Block1Text, textFont)); PdfFormattedContent formattedContent = new PdfFormattedContent(); formattedContent.Paragraphs.Add(paragraph1); formattedContent.Paragraphs.Add(paragraph2); formattedContent.Paragraphs.Add(paragraph3); formattedContent.Paragraphs.Add(paragraph4); formattedContent.Paragraphs.Add(paragraph5); formattedContent.Paragraphs.Add(paragraph6); formattedContent.Paragraphs.Add(paragraph7); formattedContent.Paragraphs.Add(paragraph8); formattedContent.Paragraphs.Add(paragraph9); formattedContent.Paragraphs.Add(paragraph10); formattedContent.Paragraphs.Add(paragraph11); formattedContent.Paragraphs.Add(paragraph12); formattedContent.Paragraphs.Add(paragraph13); formattedContent.Paragraphs.Add(paragraph14); formattedContent.Paragraphs.Add(paragraph15); formattedContent.Paragraphs.Add(paragraph16); formattedContent.Paragraphs.Add(paragraph17); formattedContent.Paragraphs.Add(paragraph18); PdfFixedDocument document = new PdfFixedDocument(); PdfPage page = document.Pages.Add(); page.Graphics.DrawFormattedContent(formattedContent, 50, 50, 500, 700); page.Graphics.CompressAndClose(); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.formattedcontent.pdf") }; return output; }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run() { PdfFixedDocument document = new PdfFixedDocument(); document.OptionalContentProperties = new PdfOptionalContentProperties(); PdfStandardFont helveticaBold = new PdfStandardFont(PdfStandardFontFace.HelveticaBold, 18); PdfBrush blackBrush = new PdfBrush(); PdfBrush greenBrush = new PdfBrush(PdfRgbColor.DarkGreen); PdfBrush yellowBrush = new PdfBrush(PdfRgbColor.Yellow); PdfPen bluePen = new PdfPen(PdfRgbColor.DarkBlue, 5); PdfPen redPen = new PdfPen(PdfRgbColor.DarkRed, 5); PdfPage page = document.Pages.Add(); page.Graphics.DrawString("Simple optional content: the green rectangle", helveticaBold, blackBrush, 20, 50); PdfOptionalContentGroup ocgPage1 = new PdfOptionalContentGroup(); ocgPage1.Name = "Page 1 - Green Rectangle"; page.Graphics.BeginOptionalContentGroup(ocgPage1); page.Graphics.DrawRectangle(bluePen, greenBrush, 20, 100, 570, 400); page.Graphics.EndOptionalContentGroup(); page = document.Pages.Add(); page.Graphics.DrawString("Multipart optional content: the green rectangles", helveticaBold, blackBrush, 20, 50); PdfOptionalContentGroup ocgPage2 = new PdfOptionalContentGroup(); ocgPage2.Name = "Page 2 - Green Rectangles"; page.Graphics.BeginOptionalContentGroup(ocgPage2); page.Graphics.DrawRectangle(bluePen, greenBrush, 20, 200, 570, 200); page.Graphics.EndOptionalContentGroup(); page.Graphics.DrawRectangle(redPen, yellowBrush, 250, 90, 110, 680); page.Graphics.BeginOptionalContentGroup(ocgPage2); page.Graphics.DrawRectangle(bluePen, greenBrush, 20, 500, 570, 200); page.Graphics.EndOptionalContentGroup(); page = document.Pages.Add(); page.Graphics.DrawString("Imbricated optional content: the green and yellow rectangles", helveticaBold, blackBrush, 20, 50); PdfOptionalContentGroup ocgPage31 = new PdfOptionalContentGroup(); ocgPage31.Name = "Page 3 - Green Rectangle"; page.Graphics.BeginOptionalContentGroup(ocgPage31); page.Graphics.DrawRectangle(bluePen, greenBrush, 20, 100, 570, 600); PdfOptionalContentGroup ocgPage32 = new PdfOptionalContentGroup(); ocgPage32.Name = "Page 3 - Yellow Rectangle"; page.Graphics.BeginOptionalContentGroup(ocgPage32); page.Graphics.DrawRectangle(redPen, yellowBrush, 100, 200, 400, 300); page.Graphics.EndOptionalContentGroup(); // ocgPage32 page.Graphics.EndOptionalContentGroup(); // ocgPage31 page = document.Pages.Add(); page.Graphics.DrawString("Multipage optional content: the green rectangles on page 4 & 5", helveticaBold, blackBrush, 20, 50); PdfOptionalContentGroup ocgPage45 = new PdfOptionalContentGroup(); ocgPage45.Name = "Page 4 & 5 - Green Rectangles"; page.Graphics.BeginOptionalContentGroup(ocgPage45); page.Graphics.DrawRectangle(bluePen, greenBrush, 20, 200, 570, 200); page.Graphics.EndOptionalContentGroup(); page.Graphics.DrawRectangle(redPen, yellowBrush, 250, 90, 110, 680); page.Graphics.BeginOptionalContentGroup(ocgPage45); page.Graphics.DrawRectangle(bluePen, greenBrush, 20, 500, 570, 200); page.Graphics.EndOptionalContentGroup(); page = document.Pages.Add(); page.Graphics.DrawString("Multipage optional content: continued", helveticaBold, blackBrush, 20, 50); page.Graphics.BeginOptionalContentGroup(ocgPage45); page.Graphics.DrawRectangle(bluePen, greenBrush, 20, 200, 570, 200); page.Graphics.EndOptionalContentGroup(); page.Graphics.DrawRectangle(redPen, yellowBrush, 250, 90, 110, 680); page.Graphics.BeginOptionalContentGroup(ocgPage45); page.Graphics.DrawRectangle(bluePen, greenBrush, 20, 500, 570, 200); page.Graphics.EndOptionalContentGroup(); // Build the display tree for the optional content, // how its structure and relationships between optional content groups are presented to the user. PdfOptionalContentDisplayTreeNode ocgPage1Node = new PdfOptionalContentDisplayTreeNode(ocgPage1); document.OptionalContentProperties.DisplayTree.Nodes.Add(ocgPage1Node); PdfOptionalContentDisplayTreeNode ocgPage2Node = new PdfOptionalContentDisplayTreeNode(ocgPage2); document.OptionalContentProperties.DisplayTree.Nodes.Add(ocgPage2Node); PdfOptionalContentDisplayTreeNode ocgPage31Node = new PdfOptionalContentDisplayTreeNode(ocgPage31); document.OptionalContentProperties.DisplayTree.Nodes.Add(ocgPage31Node); PdfOptionalContentDisplayTreeNode ocgPage32Node = new PdfOptionalContentDisplayTreeNode(ocgPage32); ocgPage31Node.Nodes.Add(ocgPage32Node); PdfOptionalContentDisplayTreeNode ocgPage45Node = new PdfOptionalContentDisplayTreeNode(ocgPage45); document.OptionalContentProperties.DisplayTree.Nodes.Add(ocgPage45Node); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.optionalcontent.pdf") }; return output; }
/// <summary> /// Main method for running the sample. /// </summary> /// <param name="stream"></param> public static SampleOutputInfo[] Run() { // Create the pdf document PdfFixedDocument document = new PdfFixedDocument(); // Create a new page in the document PdfPage page = document.Pages.Add(); PdfBrush brush = new PdfBrush(PdfRgbColor.DarkRed); PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 36); page.Graphics.DrawString("Hello World", helvetica, brush, 100, 100); PdfContentStream cs = new PdfContentStream(page.Graphics); // Sets the stroke and fill colorspaces to DeviceRGB cs.SetStrokeColorSpace(new PdfRgbColorSpace()); cs.SetFillColorSpace(new PdfRgbColorSpace()); // Set stroke color to blue cs.SetStrokeColor(new double[] { 0, 0, 1 }); // Set fill color to green cs.SetFillColor(new double[] { 0, 1, 0 }); // Draw a line from (0, 0) to (page.Width/2, page.Height/2) // It will be drawn from top left corner to center of the page. cs.MoveTo(0, 0); cs.LineTo(page.Width / 2, page.Height / 2); cs.StrokePath(); // Begin a text section cs.BeginText(); cs.SetTextRendering(PdfTextRenderingMode.FillText); cs.SetTextMatrix(1, 0, 0, 1, 100, 150); cs.SetTextFontAndSize(helvetica, helvetica.Size); // This text will appear inverted because the coordinate system is in visual mode. byte[] binaryText = helvetica.EncodeString("Hello World"); cs.ShowText(new PdfCosBinaryString(binaryText)); cs.EndText(); // Reset coordinate system and the current graphics state to default PDF cs.ResetPdfCoordinateSystem(); // Sets the stroke and fill colorspaces to DeviceRGB cs.SetStrokeColorSpace(new PdfRgbColorSpace()); cs.SetFillColorSpace(new PdfRgbColorSpace()); // Set stroke color to blue cs.SetStrokeColor(new double[] { 0, 0, 1 }); // Set fill color to green cs.SetFillColor(new double[] { 0, 1, 0 }); // Draw a line from (0, 0) to (page.Width/2, page.Height/2) // It will be drawn from bottom left corner to center of the page because the coordinate system has been reset to default PDF. cs.MoveTo(0, 0); cs.LineTo(page.Width / 2, page.Height / 2); cs.StrokePath(); // Draw the text again cs.BeginText(); cs.SetTextRendering(PdfTextRenderingMode.FillText); cs.SetTextMatrix(1, 0, 0, 1, 100, 150); cs.SetTextFontAndSize(helvetica, helvetica.Size); // This text will appear ok. binaryText = helvetica.EncodeString("Hello World"); cs.ShowText(new PdfCosBinaryString(binaryText)); cs.EndText(); // Restore the visual coordinate system cs.RestoreVisualCoordinateSystem(); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.contentstream.pdf") }; return output; }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run(Stream input) { PdfBrush brush = new PdfBrush(); PdfPen redPen = new PdfPen(PdfRgbColor.Red, 1); PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 10); PdfFixedDocument document = new PdfFixedDocument(input); PdfContentExtractor ce = new PdfContentExtractor(document.Pages[0]); PdfVisualObjectCollection voc = ce.ExtractVisualObjects(false); PdfPath contour = null; for (int i = 0; i < voc.Count; i++) { switch (voc[i].Type) { case PdfVisualObjectType.Image: PdfImageVisualObject ivo = voc[i] as PdfImageVisualObject; contour = new PdfPath(); contour.StartSubpath(ivo.Image.ImageCorners[0].X - 5, ivo.Image.ImageCorners[0].Y + 5); contour.AddLineTo(ivo.Image.ImageCorners[1].X + 5, ivo.Image.ImageCorners[1].Y + 5); contour.AddLineTo(ivo.Image.ImageCorners[2].X + 5, ivo.Image.ImageCorners[2].Y - 5); contour.AddLineTo(ivo.Image.ImageCorners[3].X - 5, ivo.Image.ImageCorners[3].Y - 5); contour.CloseSubpath(); document.Pages[0].Graphics.DrawPath(redPen, contour); document.Pages[0].Graphics.DrawString("Image", helvetica, brush, ivo.Image.ImageCorners[0].X - 5, ivo.Image.ImageCorners[0].Y + 5); break; case PdfVisualObjectType.Text: PdfTextVisualObject tvo = voc[i] as PdfTextVisualObject; contour = new PdfPath(); contour.StartSubpath(tvo.TextFragment.FragmentCorners[0].X - 5, tvo.TextFragment.FragmentCorners[0].Y + 5); contour.AddLineTo(tvo.TextFragment.FragmentCorners[1].X + 5, tvo.TextFragment.FragmentCorners[1].Y + 5); contour.AddLineTo(tvo.TextFragment.FragmentCorners[2].X + 5, tvo.TextFragment.FragmentCorners[2].Y - 5); contour.AddLineTo(tvo.TextFragment.FragmentCorners[3].X - 5, tvo.TextFragment.FragmentCorners[3].Y - 5); contour.CloseSubpath(); document.Pages[0].Graphics.DrawPath(redPen, contour); document.Pages[0].Graphics.DrawString("Text", helvetica, brush, tvo.TextFragment.FragmentCorners[0].X - 5, tvo.TextFragment.FragmentCorners[0].Y + 5); break; case PdfVisualObjectType.Path: PdfPathVisualObject pvo = voc[i] as PdfPathVisualObject; // Examine all the path points and determine the minimum rectangle that bounds the path. double minX = 999999, minY = 999999, maxX = -999999, maxY = -999999; for (int j = 0; j < pvo.PathItems.Count; j++) { PdfPathItem pi = pvo.PathItems[j]; if (pi.Points != null) { for (int k = 0; k < pi.Points.Length; k++) { if (minX >= pi.Points[k].X) { minX = pi.Points[k].X; } if (minY >= pi.Points[k].Y) { minY = pi.Points[k].Y; } if (maxX <= pi.Points[k].X) { maxX = pi.Points[k].X; } if (maxY <= pi.Points[k].Y) { maxY = pi.Points[k].Y; } } } } contour = new PdfPath(); contour.StartSubpath(minX - 5, minY - 5); contour.AddLineTo(maxX + 5, minY - 5); contour.AddLineTo(maxX + 5, maxY + 5); contour.AddLineTo(minX - 5, maxY + 5); contour.CloseSubpath(); document.Pages[0].Graphics.DrawPath(redPen, contour); document.Pages[0].Graphics.DrawString("Path", helvetica, brush, minX - 5, maxY + 5); // Skip the rest of path objects, they are the evaluation message i = voc.Count; break; } } SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.pageobjects.pdf") }; return output; }
/// <summary> /// Main method for running the sample. /// </summary> /// <param name="imageStream"></param> /// <param name="pdfStream"></param> /// <param name="csStream"></param> /// <param name="vbStream"></param> public static SampleOutputInfo[] Run(Stream imageStream, Stream pdfStream, Stream csStream, Stream vbStream) { PdfPortfolio portfolio = new PdfPortfolio(); // Build the structure that describes how to files and folders in the portfolio are presented to the user. PdfPortfolioAttributeDefinitions portfolioAttributeDefinitions = new PdfPortfolioAttributeDefinitions(); PdfPortfolioAttributeDefinition nameAttribute = new PdfPortfolioAttributeDefinition(); nameAttribute.Name = "Name"; nameAttribute.Type = PdfPortfolioAttributeDefinitionType.String; portfolioAttributeDefinitions["name"] = nameAttribute; PdfPortfolioAttributeDefinition typeAttribute = new PdfPortfolioAttributeDefinition(); typeAttribute.Name = "Type"; typeAttribute.Type = PdfPortfolioAttributeDefinitionType.String; portfolioAttributeDefinitions["type"] = typeAttribute; portfolio.AttributeDefinitions = portfolioAttributeDefinitions; // Setup the folders structure PdfPortfolioFolder root = new PdfPortfolioFolder(); root.Name = "All files"; root.PortfolioAttributes = new PdfPortfolioItemAttributes(); root.PortfolioAttributes["name"] = new PdfCosString("All files"); PdfPortfolioFolder imagesFolder = new PdfPortfolioFolder(); imagesFolder.Name = "Images"; imagesFolder.PortfolioAttributes = new PdfPortfolioItemAttributes(); imagesFolder.PortfolioAttributes["name"] = new PdfCosString("Images (1)"); root.Folders.Add(imagesFolder); PdfPortfolioFolder pdfFolder = new PdfPortfolioFolder(); pdfFolder.Name = "PDFs"; pdfFolder.PortfolioAttributes = new PdfPortfolioItemAttributes(); pdfFolder.PortfolioAttributes["name"] = new PdfCosString("PDFs (1)"); root.Folders.Add(pdfFolder); PdfPortfolioFolder htmlFolder = new PdfPortfolioFolder(); htmlFolder.Name = "HTML"; htmlFolder.PortfolioAttributes = new PdfPortfolioItemAttributes(); htmlFolder.PortfolioAttributes["name"] = new PdfCosString("HTML (2)"); root.Folders.Add(htmlFolder); portfolio.Folders.Add(root); // Setup the portfolio items PdfPortfolioItem imageFile = new PdfPortfolioItem(); imageFile.Folder = imagesFolder; byte[] data = new byte[imageStream.Length]; imageStream.Read(data, 0, data.Length); imageFile.Payload = data; imageFile.FileName = "image.jpg"; imageFile.Attributes = new PdfPortfolioItemAttributes(); imageFile.Attributes["name"] = new PdfCosString("image.jpg"); imageFile.Attributes["type"] = new PdfCosString("JPEG image"); portfolio.Items.Add(imageFile); PdfPortfolioItem pdfFile = new PdfPortfolioItem(); pdfFile.Folder = pdfFolder; data = new byte[pdfStream.Length]; pdfStream.Read(data, 0, data.Length); pdfFile.Payload = data; pdfFile.FileName = "content.pdf"; pdfFile.Attributes = new PdfPortfolioItemAttributes(); pdfFile.Attributes["name"] = new PdfCosString("content.pdf"); pdfFile.Attributes["type"] = new PdfCosString("PDF file"); portfolio.Items.Add(pdfFile); PdfPortfolioItem csFile = new PdfPortfolioItem(); csFile.Folder = htmlFolder; data = new byte[csStream.Length]; csStream.Read(data, 0, data.Length); csFile.Payload = data; csFile.FileName = "portfolios.cs.html"; csFile.Attributes = new PdfPortfolioItemAttributes(); csFile.Attributes["name"] = new PdfCosString("portfolios.cs.html"); csFile.Attributes["type"] = new PdfCosString("HTML file"); portfolio.Items.Add(csFile); PdfPortfolioItem vbFile = new PdfPortfolioItem(); vbFile.Folder = htmlFolder; data = new byte[vbStream.Length]; vbStream.Read(data, 0, data.Length); vbFile.Payload = data; vbFile.FileName = "portfolios.vb.html"; vbFile.Attributes = new PdfPortfolioItemAttributes(); vbFile.Attributes["name"] = new PdfCosString("portfolios.vb.html"); vbFile.Attributes["type"] = new PdfCosString("HTML file"); portfolio.Items.Add(vbFile); portfolio.StartupDocument = pdfFile; SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(portfolio, "xfinium.pdf.sample.portfolios.pdf") }; return output; }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run() { PdfFixedDocument document = new PdfFixedDocument(); PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 12); PdfBrush brush = new PdfBrush(); PdfPage page = document.Pages.Add(); // First name page.Graphics.DrawString("First name:", helvetica, brush, 50, 50); PdfTextBoxField firstNameTextBox = new PdfTextBoxField("firstname"); page.Fields.Add(firstNameTextBox); firstNameTextBox.Widgets[0].Font = helvetica; firstNameTextBox.Widgets[0].VisualRectangle = new PdfVisualRectangle(150, 45, 200, 20); firstNameTextBox.Widgets[0].BorderColor = PdfRgbColor.Black; firstNameTextBox.Widgets[0].BorderWidth = 1; // Last name page.Graphics.DrawString("Last name:", helvetica, brush, 50, 80); PdfTextBoxField lastNameTextBox = new PdfTextBoxField("lastname"); page.Fields.Add(lastNameTextBox); lastNameTextBox.Widgets[0].Font = helvetica; lastNameTextBox.Widgets[0].VisualRectangle = new PdfVisualRectangle(150, 75, 200, 20); lastNameTextBox.Widgets[0].BorderColor = PdfRgbColor.Black; lastNameTextBox.Widgets[0].BorderWidth = 1; // Sex page.Graphics.DrawString("Sex:", helvetica, brush, 50, 110); PdfRadioButtonField sexRadioButton = new PdfRadioButtonField("sex"); PdfRadioButtonWidget maleRadioItem = new PdfRadioButtonWidget(); sexRadioButton.Widgets.Add(maleRadioItem); PdfRadioButtonWidget femaleRadioItem = new PdfRadioButtonWidget(); sexRadioButton.Widgets.Add(femaleRadioItem); page.Fields.Add(sexRadioButton); page.Graphics.DrawString("Male", helvetica, brush, 180, 110); maleRadioItem.ExportValue = "M"; maleRadioItem.CheckStyle = PdfCheckStyle.Circle; maleRadioItem.VisualRectangle = new PdfVisualRectangle(150, 105, 20, 20); maleRadioItem.BorderColor = PdfRgbColor.Black; maleRadioItem.BorderWidth = 1; page.Graphics.DrawString("Female", helvetica, brush, 280, 110); femaleRadioItem.ExportValue = "F"; femaleRadioItem.CheckStyle = PdfCheckStyle.Circle; femaleRadioItem.VisualRectangle = new PdfVisualRectangle(250, 105, 20, 20); femaleRadioItem.BorderColor = PdfRgbColor.Black; femaleRadioItem.BorderWidth = 1; // First car page.Graphics.DrawString("First car:", helvetica, brush, 50, 140); PdfComboBoxField firstCarList = new PdfComboBoxField("firstcar"); firstCarList.Items.Add(new PdfListItem("Mercedes", "Mercedes")); firstCarList.Items.Add(new PdfListItem("BMW", "BMW")); firstCarList.Items.Add(new PdfListItem("Audi", "Audi")); firstCarList.Items.Add(new PdfListItem("Volkswagen", "Volkswagen")); firstCarList.Items.Add(new PdfListItem("Porsche", "Porsche")); firstCarList.Items.Add(new PdfListItem("Honda", "Honda")); firstCarList.Items.Add(new PdfListItem("Toyota", "Toyota")); firstCarList.Items.Add(new PdfListItem("Lexus", "Lexus")); firstCarList.Items.Add(new PdfListItem("Infiniti", "Infiniti")); firstCarList.Items.Add(new PdfListItem("Acura", "Acura")); page.Fields.Add(firstCarList); firstCarList.Widgets[0].Font = helvetica; firstCarList.Widgets[0].VisualRectangle = new PdfVisualRectangle(150, 135, 200, 20); firstCarList.Widgets[0].BorderColor = PdfRgbColor.Black; firstCarList.Widgets[0].BorderWidth = 1; // Second car page.Graphics.DrawString("Second car:", helvetica, brush, 50, 170); PdfListBoxField secondCarList = new PdfListBoxField("secondcar"); secondCarList.Items.Add(new PdfListItem("Mercedes", "Mercedes")); secondCarList.Items.Add(new PdfListItem("BMW", "BMW")); secondCarList.Items.Add(new PdfListItem("Audi", "Audi")); secondCarList.Items.Add(new PdfListItem("Volkswagen", "Volkswagen")); secondCarList.Items.Add(new PdfListItem("Porsche", "Porsche")); secondCarList.Items.Add(new PdfListItem("Honda", "Honda")); secondCarList.Items.Add(new PdfListItem("Toyota", "Toyota")); secondCarList.Items.Add(new PdfListItem("Lexus", "Lexus")); secondCarList.Items.Add(new PdfListItem("Infiniti", "Infiniti")); secondCarList.Items.Add(new PdfListItem("Acura", "Acura")); page.Fields.Add(secondCarList); secondCarList.Widgets[0].Font = helvetica; secondCarList.Widgets[0].VisualRectangle = new PdfVisualRectangle(150, 165, 200, 60); secondCarList.Widgets[0].BorderColor = PdfRgbColor.Black; secondCarList.Widgets[0].BorderWidth = 1; // I agree page.Graphics.DrawString("I agree:", helvetica, brush, 50, 240); PdfCheckBoxField agreeCheckBox = new PdfCheckBoxField("agree"); page.Fields.Add(agreeCheckBox); agreeCheckBox.Widgets[0].Font = helvetica; (agreeCheckBox.Widgets[0] as PdfCheckWidget).ExportValue = "YES"; (agreeCheckBox.Widgets[0] as PdfCheckWidget).CheckStyle = PdfCheckStyle.Check; agreeCheckBox.Widgets[0].VisualRectangle = new PdfVisualRectangle(150, 235, 20, 20); agreeCheckBox.Widgets[0].BorderColor = PdfRgbColor.Black; agreeCheckBox.Widgets[0].BorderWidth = 1; // Sign here page.Graphics.DrawString("Sign here:", helvetica, brush, 50, 270); PdfSignatureField signHereField = new PdfSignatureField("signhere"); page.Fields.Add(signHereField); signHereField.Widgets[0].Font = helvetica; signHereField.Widgets[0].VisualRectangle = new PdfVisualRectangle(150, 265, 200, 60); // Submit form PdfPushButtonField submitBtn = new PdfPushButtonField("submit"); page.Fields.Add(submitBtn); submitBtn.Widgets[0].VisualRectangle = new PdfVisualRectangle(450, 45, 150, 30); (submitBtn.Widgets[0] as PdfPushButtonWidget).Caption = "Submit form"; submitBtn.Widgets[0].BackgroundColor = PdfRgbColor.LightGray; PdfSubmitFormAction submitFormAction = new PdfSubmitFormAction(); submitFormAction.DataFormat = PdfSubmitDataFormat.FDF; submitFormAction.Fields.Add("firstname"); submitFormAction.Fields.Add("lastname"); submitFormAction.Fields.Add("sex"); submitFormAction.Fields.Add("firstcar"); submitFormAction.Fields.Add("secondcar"); submitFormAction.Fields.Add("agree"); submitFormAction.Fields.Add("signhere"); submitFormAction.SubmitFields = true; submitFormAction.Url = "http://www.xfiniumsoft.com/"; submitBtn.Widgets[0].MouseUp = submitFormAction; // Reset form PdfPushButtonField resetBtn = new PdfPushButtonField("reset"); page.Fields.Add(resetBtn); resetBtn.Widgets[0].VisualRectangle = new PdfVisualRectangle(450, 85, 150, 30); (resetBtn.Widgets[0] as PdfPushButtonWidget).Caption = "Reset form"; resetBtn.Widgets[0].BackgroundColor = PdfRgbColor.LightGray; PdfResetFormAction resetFormAction = new PdfResetFormAction(); resetBtn.Widgets[0].MouseUp = resetFormAction; // Print form PdfPushButtonField printBtn = new PdfPushButtonField("print"); page.Fields.Add(printBtn); printBtn.Widgets[0].VisualRectangle = new PdfVisualRectangle(450, 125, 150, 30); (printBtn.Widgets[0] as PdfPushButtonWidget).Caption = "Print form"; printBtn.Widgets[0].BackgroundColor = PdfRgbColor.LightGray; PdfJavaScriptAction printAction = new PdfJavaScriptAction(); printAction.Script = "this.print(true);\n"; printBtn.Widgets[0].MouseUp = printAction; SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.formgenerator.pdf") }; return output; }
/// <summary> /// Main method for running the sample. /// </summary> public static SampleOutputInfo[] Run() { PdfFixedDocument document = new PdfFixedDocument(); PdfPage page = document.Pages.Add(); PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 20); PdfBrush blackBrush = new PdfBrush(PdfRgbColor.Black); page.Graphics.DrawString("The digits below, from 0 to 9, are drawn using a Type3 font.", helvetica, blackBrush, 50, 100); PdfType3Font t3 = new PdfType3Font("DemoT3"); t3.Size = 24; t3.FirstChar = (byte)' '; t3.LastChar = (byte)'9'; t3.FontMatrix = new PdfMatrix(0.01, 0, 0, 0.01, 0, 0); double[] widths = new double[] { 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; t3.Widths = widths; PdfPen hollowPen = new PdfPen(null, 8); PdfBrush hollowBrush = new PdfBrush(null); // space PdfType3Glyph t3s = new PdfType3Glyph(0x20, new PdfSize(100, 100)); t3.Glyphs.Add(t3s); // 0 PdfType3Glyph t30 = new PdfType3Glyph(0x30, new PdfSize(100, 100)); t30.Graphics.DrawRectangle(hollowPen, 5, 5, 90, 90); t30.Graphics.CompressAndClose(); t3.Glyphs.Add(t30); // 1 PdfType3Glyph t31 = new PdfType3Glyph(0x31, new PdfSize(100, 100)); t31.Graphics.DrawRectangle(hollowPen, 5, 5, 90, 90); t31.Graphics.DrawEllipse(hollowBrush, 40, 40, 20, 20); t31.Graphics.CompressAndClose(); t3.Glyphs.Add(t31); // 2 PdfType3Glyph t32 = new PdfType3Glyph(0x32, new PdfSize(100, 100)); t32.Graphics.DrawRectangle(hollowPen, 5, 5, 90, 90); t32.Graphics.DrawEllipse(hollowBrush, 15, 15, 20, 20); t32.Graphics.DrawEllipse(hollowBrush, 65, 65, 20, 20); t32.Graphics.CompressAndClose(); t3.Glyphs.Add(t32); // 3 PdfType3Glyph t33 = new PdfType3Glyph(0x33, new PdfSize(100, 100)); t33.Graphics.DrawRectangle(hollowPen, 5, 5, 90, 90); t33.Graphics.DrawEllipse(hollowBrush, 15, 15, 20, 20); t33.Graphics.DrawEllipse(hollowBrush, 40, 40, 20, 20); t33.Graphics.DrawEllipse(hollowBrush, 65, 65, 20, 20); t33.Graphics.CompressAndClose(); t3.Glyphs.Add(t33); // 4 PdfType3Glyph t34 = new PdfType3Glyph(0x34, new PdfSize(100, 100)); t34.Graphics.DrawRectangle(hollowPen, 5, 5, 90, 90); t34.Graphics.DrawEllipse(hollowBrush, 15, 15, 20, 20); t34.Graphics.DrawEllipse(hollowBrush, 65, 15, 20, 20); t34.Graphics.DrawEllipse(hollowBrush, 15, 65, 20, 20); t34.Graphics.DrawEllipse(hollowBrush, 65, 65, 20, 20); t34.Graphics.CompressAndClose(); t3.Glyphs.Add(t34); // 5 PdfType3Glyph t35 = new PdfType3Glyph(0x35, new PdfSize(100, 100)); t35.Graphics.DrawRectangle(hollowPen, 5, 5, 90, 90); t35.Graphics.DrawEllipse(hollowBrush, 15, 15, 20, 20); t35.Graphics.DrawEllipse(hollowBrush, 65, 15, 20, 20); t35.Graphics.DrawEllipse(hollowBrush, 40, 40, 20, 20); t35.Graphics.DrawEllipse(hollowBrush, 15, 65, 20, 20); t35.Graphics.DrawEllipse(hollowBrush, 65, 65, 20, 20); t35.Graphics.CompressAndClose(); t3.Glyphs.Add(t35); // 6 PdfType3Glyph t36 = new PdfType3Glyph(0x36, new PdfSize(100, 100)); t36.Graphics.DrawRectangle(hollowPen, 5, 5, 90, 90); t36.Graphics.DrawEllipse(hollowBrush, 15, 15, 20, 20); t36.Graphics.DrawEllipse(hollowBrush, 65, 15, 20, 20); t36.Graphics.DrawEllipse(hollowBrush, 15, 40, 20, 20); t36.Graphics.DrawEllipse(hollowBrush, 65, 40, 20, 20); t36.Graphics.DrawEllipse(hollowBrush, 15, 65, 20, 20); t36.Graphics.DrawEllipse(hollowBrush, 65, 65, 20, 20); t36.Graphics.CompressAndClose(); t3.Glyphs.Add(t36); // 7 PdfType3Glyph t37 = new PdfType3Glyph(0x37, new PdfSize(100, 100)); t37.Graphics.DrawRectangle(hollowPen, 5, 5, 90, 90); t37.Graphics.DrawEllipse(hollowBrush, 15, 15, 20, 20); t37.Graphics.DrawEllipse(hollowBrush, 65, 15, 20, 20); t37.Graphics.DrawEllipse(hollowBrush, 15, 40, 20, 20); t37.Graphics.DrawEllipse(hollowBrush, 40, 40, 20, 20); t37.Graphics.DrawEllipse(hollowBrush, 65, 40, 20, 20); t37.Graphics.DrawEllipse(hollowBrush, 15, 65, 20, 20); t37.Graphics.DrawEllipse(hollowBrush, 65, 65, 20, 20); t37.Graphics.CompressAndClose(); t3.Glyphs.Add(t37); // 8 PdfType3Glyph t38 = new PdfType3Glyph(0x38, new PdfSize(100, 100)); t38.Graphics.DrawRectangle(hollowPen, 5, 5, 90, 90); t38.Graphics.DrawEllipse(hollowBrush, 15, 15, 20, 20); t38.Graphics.DrawEllipse(hollowBrush, 40, 15, 20, 20); t38.Graphics.DrawEllipse(hollowBrush, 65, 15, 20, 20); t38.Graphics.DrawEllipse(hollowBrush, 15, 40, 20, 20); t38.Graphics.DrawEllipse(hollowBrush, 65, 40, 20, 20); t38.Graphics.DrawEllipse(hollowBrush, 15, 65, 20, 20); t38.Graphics.DrawEllipse(hollowBrush, 40, 65, 20, 20); t38.Graphics.DrawEllipse(hollowBrush, 65, 65, 20, 20); t38.Graphics.CompressAndClose(); t3.Glyphs.Add(t38); // 9 PdfType3Glyph t39 = new PdfType3Glyph(0x39, new PdfSize(100, 100)); t39.Graphics.DrawRectangle(hollowPen, 5, 5, 90, 90); t39.Graphics.DrawEllipse(hollowBrush, 15, 15, 20, 20); t39.Graphics.DrawEllipse(hollowBrush, 40, 15, 20, 20); t39.Graphics.DrawEllipse(hollowBrush, 65, 15, 20, 20); t39.Graphics.DrawEllipse(hollowBrush, 15, 40, 20, 20); t39.Graphics.DrawEllipse(hollowBrush, 40, 40, 20, 20); t39.Graphics.DrawEllipse(hollowBrush, 65, 40, 20, 20); t39.Graphics.DrawEllipse(hollowBrush, 15, 65, 20, 20); t39.Graphics.DrawEllipse(hollowBrush, 40, 65, 20, 20); t39.Graphics.DrawEllipse(hollowBrush, 65, 65, 20, 20); t39.Graphics.CompressAndClose(); t3.Glyphs.Add(t39); PdfBrush paleVioletRedbrush = new PdfBrush(PdfRgbColor.PaleVioletRed); page.Graphics.DrawString("0 1 2 3 4 5 6 7 8 9", t3, paleVioletRedbrush, 50, 150); PdfBrush midnightBluebrush = new PdfBrush(PdfRgbColor.MidnightBlue); page.Graphics.DrawString("0 1 2 3 4 5 6 7 8 9", t3, midnightBluebrush, 50, 200); SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.type3fonts.pdf") }; return output; }