├── GettingStarted ├── BezierConnectedLines │ ├── BezierConnectedLines.cs │ ├── BezierConnectedLines.csproj │ ├── BezierConnectedLines.gif │ ├── BezierConnectedLines.pdf │ └── README.md ├── ChangeTransparencyAndBlendMode │ ├── ChangeTransparencyAndBlendMode.csproj │ ├── ChangeTransparencyAndBlendModeTransform.cs │ ├── Program.cs │ ├── README.md │ ├── Sample.pdf │ └── Sample_Transformed.pdf ├── ContentSeparator │ ├── ContentSeparator.cs │ ├── ContentSeparator.csproj │ ├── Program.cs │ └── README.md ├── DigitalSignatureWithCustomAppearance │ ├── DigitalSignatureWithCustomAppearance.cs │ ├── DigitalSignatureWithCustomAppearance.csproj │ ├── DigitalSignatureWithCustomAppearance.pdf │ └── README.md ├── EmbedPageAsLayer │ ├── EmbedPageAsLayer.cs │ ├── EmbedPageAsLayer.csproj │ ├── EmbedPageAsLayer.pdf │ ├── README.md │ └── input.pdf ├── EmbedTrueTypeFontFile │ ├── EmbedTrueTypeFontFile.cs │ ├── EmbedTrueTypeFontFile.csproj │ ├── Program.cs │ └── README.md ├── MultipleDigitalSignatures │ ├── MultipleDigitalSignatures.cs │ ├── MultipleDigitalSignatures.csproj │ ├── MultipleDigitalSignatures.pdf │ └── README.md ├── PieAndDonutCharts │ ├── PieAndDonutCharts.cs │ ├── PieAndDonutCharts.csproj │ ├── PieAndDonutCharts.pdf │ ├── PieChart.cs │ ├── PiePart.cs │ └── README.md ├── README.md ├── RemoveUnusedResources │ ├── PDF4NET.Features.pdf │ ├── Program.cs │ ├── README.md │ ├── RemoveUnusedResources.csproj │ └── RemoveUnusedResources.sln ├── SearchAndRedact │ ├── README.md │ ├── SearchAndRedact.cs │ └── SearchAndRedact.csproj ├── TaggedFlowDocument │ ├── README.md │ ├── TaggedFlowDocument.cs │ └── TaggedFlowDocument.csproj └── TaggedTextExtractor │ ├── Program.cs │ ├── README.md │ ├── TaggedTextExtractor.cs │ └── TaggedTextExtractor.csproj ├── README.md ├── Reference ├── Actions │ ├── Actions.cs │ ├── Actions.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── AdvancedFontFeatures │ ├── AdvancedFontFeatures.cs │ ├── AdvancedFontFeatures.csproj │ └── README.md ├── Annotations │ ├── Annotations.cs │ ├── Annotations.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── Barcodes │ ├── Barcodes.cs │ ├── Barcodes.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── BatesNumbers │ ├── BatesNumbers.cs │ ├── BatesNumbers.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── CertifyingSignature │ ├── CertifyingSignature.cs │ ├── CertifyingSignature.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── ComplexScriptsFlowContent │ ├── ComplexScriptsFlowContent.cs │ ├── ComplexScriptsFlowContent.csproj │ └── README.md ├── ComplexScriptsFormFill │ ├── ComplexScriptsFormFill.cs │ ├── ComplexScriptsFormFill.csproj │ └── README.md ├── ComplexScriptsTables │ ├── ComplexScriptsTables.cs │ ├── ComplexScriptsTables.csproj │ └── README.md ├── ComplexScriptsText │ ├── ComplexScriptsText.cs │ ├── ComplexScriptsText.csproj │ └── README.md ├── ContentExtraction │ ├── ContentExtraction.cs │ ├── ContentExtraction.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── ContentStream │ ├── ContentStream.cs │ ├── ContentStream.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── DocumentAppend │ ├── DocumentAppend.cs │ ├── DocumentAppend.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── DocumentIncrementalUpdate │ ├── DocumentIncrementalUpdate.cs │ ├── DocumentIncrementalUpdate.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── DocumentPageByPageSave │ ├── DocumentPageByPageSave.cs │ ├── DocumentPageByPageSave.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── DocumentProperties │ ├── DocumentProperties.cs │ ├── DocumentProperties.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── DocumentSplit │ ├── DocumentSplit.cs │ ├── DocumentSplit.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── DocumentTimeStamp │ ├── DocumentTimeStamp.cs │ ├── DocumentTimeStamp.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── Emoji │ ├── Emoji.cs │ ├── Emoji.csproj │ └── README.md ├── Encryption │ ├── Encryption.cs │ ├── Encryption.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── FileAttachments │ ├── FileAttachments.cs │ ├── FileAttachments.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── FlowDocumentWithExternalPages │ ├── FlowDocumentWithExternalPages.cs │ ├── FlowDocumentWithExternalPages.csproj │ └── README.md ├── Fonts │ ├── Fonts.cs │ ├── Fonts.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── FormFill │ ├── FormFill.cs │ ├── FormFill.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── FormFillLowOverhead │ ├── FormFillLowOverhead.cs │ ├── FormFillLowOverhead.csproj │ └── README.md ├── FormGenerator │ ├── FormGenerator.cs │ ├── FormGenerator.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── FormatedContent │ ├── FormatedContent.csproj │ ├── FormattedContent.cs │ ├── Program.cs │ └── SampleOutputInfo.cs ├── GrayscaleConversion │ ├── GrayscaleConversion.cs │ ├── GrayscaleConversion.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── HeadersAndFooters │ ├── HeadersAndFooters.cs │ ├── HeadersAndFooters.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── Images │ ├── Images.cs │ ├── Images.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── Invoice │ ├── Invoice.cs │ ├── Invoice.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── Measurements │ ├── Measurements.cs │ ├── Measurements.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── MergeAndEncrypt │ ├── MergeAndEncrypt.cs │ ├── MergeAndEncrypt.csproj │ └── README.md ├── OptionalContent │ ├── OptionalContent.cs │ ├── OptionalContent.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── OptionalContentExtraction │ ├── OptionalContentExtraction.cs │ ├── OptionalContentExtraction.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── Outlines │ ├── Outlines.cs │ ├── Outlines.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── PAdESSignature │ ├── PAdESSignature.cs │ ├── PAdESSignature.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── PDFA │ ├── PDFA.cs │ ├── PDFA.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── PDFUA │ ├── PDFUA.cs │ ├── PDFUA.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── PageAnalyzer │ ├── PageAnalyzer.cs │ ├── PageAnalyzer.csproj │ └── README.md ├── PageImposition │ ├── PageImposition.cs │ ├── PageImposition.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── PageObjects │ ├── PageObjects.cs │ ├── PageObjects.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── Portfolios │ ├── Portfolios.cs │ ├── Portfolios.csproj │ ├── Program.cs │ └── SampleOutputInfo.cs ├── README.md ├── Redaction │ ├── Program.cs │ ├── Redaction.cs │ ├── Redaction.csproj │ └── SampleOutputInfo.cs ├── RemoveAndReplaceImages │ ├── Program.cs │ ├── RemoveAndReplaceImages.csproj │ ├── RemoveReplaceImages.cs │ └── SampleOutputInfo.cs ├── Render │ ├── HighDpiPDF2Image │ │ ├── HighDpiPDF2Image.cs │ │ ├── HighDpiPDF2Image.csproj │ │ └── README.md │ ├── Layers │ │ ├── Layers.cs │ │ ├── Layers.csproj │ │ └── README.md │ ├── MultiThreadedPDFToImage │ │ ├── MultiThreadedPDFToImage.cs │ │ ├── MultiThreadedPDFToImage.csproj │ │ └── README.md │ ├── PDF2BlackAndWhiteImage │ │ ├── PDF2BlackAndWhiteImage.cs │ │ ├── PDF2BlackAndWhiteImage.csproj │ │ └── README.md │ ├── PDF2ColorImage │ │ ├── PDF2ColorImage.cs │ │ ├── PDF2ColorImage.csproj │ │ └── README.md │ ├── PDF2FixedImageSize │ │ ├── PDFToFixedImageSize.cs │ │ ├── PDFToFixedImageSize.csproj │ │ └── README.md │ ├── PDF2GrayImage │ │ ├── PDF2GrayImage.cs │ │ ├── PDF2GrayImage.csproj │ │ └── README.md │ ├── PDF2MultipageBlackAndWhiteTiff │ │ ├── PDF2MultipageBlackAndWhiteTiff.cs │ │ ├── PDF2MultipageBlackAndWhiteTiff.csproj │ │ └── README.md │ ├── PDF2MultipageColorTiff │ │ ├── PDF2MultipageColorTiff.cs │ │ ├── PDF2MultipageColorTiff.csproj │ │ └── README.md │ ├── PDF2MultipageGrayTiff │ │ ├── PDF2MultipageGrayTiff.cs │ │ ├── PDF2MultipageGrayTiff.csproj │ │ └── README.md │ ├── PDF2TransparentImage │ │ ├── PDF2TransparentImage.cs │ │ ├── PDF2TransparentImage.csproj │ │ └── README.md │ └── SelectiveContentRendering │ │ ├── README.md │ │ ├── SelectiveContentRendering.cs │ │ └── SelectiveContentRendering.csproj ├── ResourceOptimization │ ├── README.md │ ├── ResourceOptimization.cs │ └── ResourceOptimization.csproj ├── SVGFont │ ├── README.md │ ├── SVGFont.cs │ └── SVGFont.csproj ├── SVGToPDF │ ├── Program.cs │ ├── SVGToPDF.csproj │ ├── SampleOutputInfo.cs │ └── SvgToPdf.cs ├── SaveSignedCopy │ ├── README.md │ ├── SaveSignedCopy.cs │ └── SaveSignedCopy.csproj ├── SearchText │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── SearchText.cs │ └── SearchText.csproj ├── ShowSignatureCertificate │ ├── README.md │ ├── ShowSignatureCertificate.cs │ └── ShowSignatureCertificate.csproj ├── SignatureDecode │ ├── README.md │ ├── SignatureDecode.cs │ └── SignatureDecode.csproj ├── SignatureWithTimeStamp │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── SignatureWithTimeStamp.cs │ └── SignatureWithTimeStamp.csproj ├── SimpleMerge │ ├── README.md │ ├── SimpleMerge.cs │ └── SimpleMerge.csproj ├── SimpleSignature │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── SimpleSignature.cs │ └── SimpleSignature.csproj ├── SimpleTable │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── SimpleTable.cs │ └── SimpleTable.csproj ├── SuperscriptSubscript │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── SuperscriptSubscript.cs │ └── SuperscriptSubscript.csproj ├── TableCellSpans │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── TableCellSpans.cs │ └── TableCellSpans.csproj ├── TableGroups │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── TableGroups.cs │ └── TableGroups.csproj ├── TableOfContents │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── TableOfContents.cs │ └── TableOfContents.csproj ├── Text │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── Text.cs │ └── Text.csproj ├── TiffToPdf │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── TiffToPdf.cs │ └── TiffToPdf.csproj ├── Type3Fonts │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── Type3Fonts.cs │ └── Type3Fonts.csproj ├── VectorGraphics │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── VectorGraphics.cs │ └── VectorGraphics.csproj ├── Watermarks │ ├── Program.cs │ ├── SampleOutputInfo.cs │ ├── Watermarks.cs │ └── Watermarks.csproj └── WatermarksLowOverhead │ ├── README.md │ ├── WatermarksLowOverhead.cs │ └── WatermarksLowOverhead.csproj ├── SupportFiles ├── Cluj.pdf ├── DigitaltsOrange.ttf ├── Invoice.pdf ├── NotoNaskhArabic-Regular.ttf ├── NotoNastaliqUrdu-Regular.ttf ├── NotoSansBengali-Regular.ttf ├── NotoSansCJKjp-Regular.ttf ├── NotoSansDevanagari-Regular.ttf ├── NotoSansGujarati-Regular.ttf ├── NotoSansGurmukhi-Regular.ttf ├── NotoSansKannada-Regular.ttf ├── NotoSansKhmer-Regular.ttf ├── NotoSansMyanmarLatin-Regular.ttf ├── NotoSansOriya-Regular.ttf ├── NotoSansTamil-Regular.ttf ├── NotoSansTelugu-Regular.ttf ├── NotoSerifLao-Regular.ttf ├── NotoSerifMalayalam-Regular.ttf ├── NotoSerifThai-Regular.ttf ├── O2SolutionsDemoCertificate.pfx ├── PDF4NET.Features.pdf ├── PDF4NET.Overview.pdf ├── PDF4NET.pdf ├── SegoeUIEmoji.ttf ├── airplane.u3d ├── arial.ttf ├── auto1.jpg ├── box.u3d ├── calibri.ttf ├── clock.swf ├── cmyk.tif ├── content.pdf ├── contentseparation.pdf ├── encrypted.pdf ├── formfill.pdf ├── image.jpg ├── layers.pdf ├── logo.png ├── people1.dat ├── population.dat ├── rgb.icc ├── sample.pdf ├── sample.tif ├── signature.png ├── softmask.png ├── stencilmask.png ├── tiger.svg ├── verdana.ttf └── verdanab.ttf └── Upgrade ├── 3D ├── 3D.cs └── 3D.csproj ├── Actions ├── Actions.cs └── Actions.csproj ├── Annotations ├── Annotations.cs └── Annotations.csproj ├── ArcsPies ├── ArcsPies.cs └── ArcsPies.csproj ├── Attachments ├── Attachments.cs └── Attachments.csproj ├── Barcodes ├── Barcodes.cs └── Barcodes.csproj ├── Bezier ├── Bezier.cs └── Bezier.csproj ├── Bookmarks ├── Bookmarks.cs └── Bookmarks.csproj ├── CharacterMap ├── CharacterMap.cs └── CharacterMap.csproj ├── ColorSpaces ├── ColorSpaces.cs └── ColorSpaces.csproj ├── DigitalSignature ├── DigitalSignature.cs └── DigitalSignature.csproj ├── DocAndViewer ├── DocAndViewer.cs └── DocAndViewer.csproj ├── EditPDF ├── EditPDF.cs └── EditPDF.csproj ├── Ellipses ├── Ellipses.cs └── Ellipses.csproj ├── Encryption ├── Encryption.cs └── Encryption.csproj ├── ExtractImages ├── ExtractImages.cs └── ExtractImages.csproj └── readme.md /GettingStarted/BezierConnectedLines/BezierConnectedLines.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /GettingStarted/BezierConnectedLines/BezierConnectedLines.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/GettingStarted/BezierConnectedLines/BezierConnectedLines.gif -------------------------------------------------------------------------------- /GettingStarted/BezierConnectedLines/BezierConnectedLines.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/GettingStarted/BezierConnectedLines/BezierConnectedLines.pdf -------------------------------------------------------------------------------- /GettingStarted/BezierConnectedLines/README.md: -------------------------------------------------------------------------------- 1 | The `BezierConnectedLines` sample shows how to draw a sequence of lines that connect through Bezier curves to give a smoother appearance to the connection points. 2 | 3 | The algorithm processes the list of points in groups of 3 points (pt1, pt2, pt3), pt2 being the connection point for the lines (pt1,pt2) and (pt2,pt3). The algorithm replaces pt2 with 3 intermediary points that define the Bezier curve. A smooth factor (between 0 and 0.5) specifies how much of the line is replaced by the Bezier curve (0 means no Bezier curve, 0.5 means half of the line is replaced by the curve). 4 | 5 | The algorithm returns 5 points for the first 3 points in the input list, points that define the start line, joining curve and end line. For the other groups of 3 points in the list it returns 4 points that define the joining curve and end line. 6 | 7 | The image below shows the same set of lines connected through Bezier curves using various smooth factors. 8 | 9 | ![Bezier connected lines](https://github.com/o2solutions/pdf4net/blob/master/GettingStarted/BezierConnectedLines/BezierConnectedLines.gif) 10 | 11 | -------------------------------------------------------------------------------- /GettingStarted/ChangeTransparencyAndBlendMode/ChangeTransparencyAndBlendMode.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /GettingStarted/ChangeTransparencyAndBlendMode/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Transforms; 6 | 7 | namespace ChangeTransparencyAndBlendMode 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | ChangeTransparencyAndBlendModeTransform tr = new ChangeTransparencyAndBlendModeTransform(); 14 | tr.EnableExtendedOperatorInformation = true; 15 | 16 | PDFFixedDocument document = new PDFFixedDocument("Sample.pdf"); 17 | PDFPageTransformer pageTransformer = new PDFPageTransformer(document.Pages[0]); 18 | pageTransformer.ApplyTransform(tr); 19 | document.Save("Sample_Transformed.pdf"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /GettingStarted/ChangeTransparencyAndBlendMode/README.md: -------------------------------------------------------------------------------- 1 | The `ChangeTransparencyAndBlendMode` sample shows how to modify the transparency and blend mode for graphics objects in a PDF file. 2 | 3 | The sample changes the transparency for red filled paths and the blend mode for blue filled paths. 4 | 5 | The input sample.pdf and output sample_transformed.pdf files are included. 6 | -------------------------------------------------------------------------------- /GettingStarted/ChangeTransparencyAndBlendMode/Sample.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/GettingStarted/ChangeTransparencyAndBlendMode/Sample.pdf -------------------------------------------------------------------------------- /GettingStarted/ChangeTransparencyAndBlendMode/Sample_Transformed.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/GettingStarted/ChangeTransparencyAndBlendMode/Sample_Transformed.pdf -------------------------------------------------------------------------------- /GettingStarted/ContentSeparator/ContentSeparator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /GettingStarted/ContentSeparator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace O2S.Components.PDF4NET.Samples 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | ContentSeparator cs = new ContentSeparator("..\\..\\..\\..\\..\\SupportFiles\\contentseparation.pdf", "cutcontour"); 10 | 11 | cs.KeepSeparationDiscardMainContent("CutContour.pdf"); 12 | cs.KeepMainDiscardSeparationContent("MainContent.pdf"); 13 | } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /GettingStarted/ContentSeparator/README.md: -------------------------------------------------------------------------------- 1 | The `ContentSeparator` sample shows how to separate the content of a PDF page based on the color used to paint the page content. 2 | 3 | The `PDFSeparateContentTransform` class is used to implement a page transform that analyzes the page content and keeps or discards the content based on specific conditions. The class uses a separation color space as filter for page content. 4 | 5 | The `PDFSeparateContentTransform` class is initialized with the separation name and a flag that indicates whether to keep the content painted with the separation color or discard it. When the flag is true, the transform keeps only the content painted with the separation colorspace and the other content is discarded. When the flag is false, the transform discards the content painted with the separation colorspace and keeps the remaining content. 6 | 7 | The transform caches the current path building operators and when a path painting operator is encountered, the path is either painted or discarded based on current condition. -------------------------------------------------------------------------------- /GettingStarted/DigitalSignatureWithCustomAppearance/DigitalSignatureWithCustomAppearance.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /GettingStarted/DigitalSignatureWithCustomAppearance/DigitalSignatureWithCustomAppearance.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/GettingStarted/DigitalSignatureWithCustomAppearance/DigitalSignatureWithCustomAppearance.pdf -------------------------------------------------------------------------------- /GettingStarted/DigitalSignatureWithCustomAppearance/README.md: -------------------------------------------------------------------------------- 1 | The `DigitalSignatureWithCustomAppearance` sample shows how to digitally sign a PDF file and use a hand written signature image for the signature appearance. 2 | 3 | The custom appearance is created using the [`PDFAnnotationAppearance`](https://o2sol.com/pdf4net/help/pdf4net/webframe.html#O2S.Components.PDF4NET.NetStandard~O2S.Components.PDF4NET.Annotations.PDFAnnotationAppearance.html) class. Its `Canvas` property allows to include any kind of graphic content in the signature appearance. The signature image (a .png file) is loaded in a [`PDFPngImage`](https://o2sol.com/pdf4net/help/pdf4net/webframe.html#O2S.Components.PDF4NET.NetStandard~O2S.Components.PDF4NET.Graphics.PDFPngImage.html) object and drawn on the appearance's canvas. 4 | 5 | After all the digital signature properties have been set, the custom signature appearance is attached to the signature field by setting the `NormalAppearance` property on the signature widget with the annotation appearance object. -------------------------------------------------------------------------------- /GettingStarted/EmbedPageAsLayer/EmbedPageAsLayer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET.Core; 4 | using O2S.Components.PDF4NET.Graphics; 5 | using O2S.Components.PDF4NET.Graphics.OptionalContent; 6 | 7 | namespace O2S.Components.PDF4NET.Samples 8 | { 9 | public class EmbedPageAsLayer 10 | { 11 | public static void Main(string[] args) 12 | { 13 | // Extract the page content from the source file. 14 | FileStream stream = File.OpenRead("input.pdf"); 15 | PDFFile source = new PDFFile(stream); 16 | PDFPageContent pageContent = source.ExtractPageContent(0); 17 | stream.Close(); 18 | 19 | PDFFixedDocument document = new PDFFixedDocument(); 20 | document.OptionalContentProperties = new PDFOptionalContentProperties(); 21 | PDFPage page = document.Pages.Add(); 22 | 23 | // Create an optional content group (layer) for the extracted page content. 24 | PDFOptionalContentGroup ocg = new PDFOptionalContentGroup(); 25 | ocg.Name = "Embedded page"; 26 | ocg.VisibilityState = PDFOptionalContentGroupVisibilityState.AlwaysVisible; 27 | ocg.PrintState = PDFOptionalContentGroupPrintState.NeverPrint; 28 | // Draw the extracted page content in the layer 29 | page.Canvas.BeginOptionalContentGroup(ocg); 30 | page.Canvas.DrawFormXObject(pageContent, 0, 0, page.Width, page.Height); 31 | page.Canvas.EndOptionalContentGroup(); 32 | 33 | // Build the display tree for the optional content 34 | PDFOptionalContentDisplayTreeNode ocgNode = new PDFOptionalContentDisplayTreeNode(ocg); 35 | document.OptionalContentProperties.DisplayTree.Nodes.Add(ocgNode); 36 | 37 | using (FileStream output = File.Create("EmbedPageAsLayer.pdf")) 38 | { 39 | document.Save(output); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /GettingStarted/EmbedPageAsLayer/EmbedPageAsLayer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /GettingStarted/EmbedPageAsLayer/EmbedPageAsLayer.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/GettingStarted/EmbedPageAsLayer/EmbedPageAsLayer.pdf -------------------------------------------------------------------------------- /GettingStarted/EmbedPageAsLayer/README.md: -------------------------------------------------------------------------------- 1 | The `EmbedPageAsLayer` sample shows how to take an existing PDF page and embed it in another page as a PDF layer. 2 | 3 | -------------------------------------------------------------------------------- /GettingStarted/EmbedPageAsLayer/input.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/GettingStarted/EmbedPageAsLayer/input.pdf -------------------------------------------------------------------------------- /GettingStarted/EmbedTrueTypeFontFile/EmbedTrueTypeFontFile.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /GettingStarted/EmbedTrueTypeFontFile/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace O2S.Components.PDF4NET.Samples 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 11 | 12 | EmbedTrueTypeFontFile.Run(supportPath + "content.pdf", "Sample_EmbedTrueTypeFontFile.pdf", "Verdana", supportPath + "verdana.ttf"); 13 | 14 | Console.WriteLine("Font has been embedded with success"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /GettingStarted/EmbedTrueTypeFontFile/README.md: -------------------------------------------------------------------------------- 1 | The `EmbedTrueTypeFontFile` sample shows how to embed a TrueType font file in an existing PDF file. 2 | The sample assumes the font definitions already exists in the file but the font data has not been embedded or only a subset has been embedded. 3 | -------------------------------------------------------------------------------- /GettingStarted/MultipleDigitalSignatures/MultipleDigitalSignatures.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /GettingStarted/MultipleDigitalSignatures/MultipleDigitalSignatures.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/GettingStarted/MultipleDigitalSignatures/MultipleDigitalSignatures.pdf -------------------------------------------------------------------------------- /GettingStarted/MultipleDigitalSignatures/README.md: -------------------------------------------------------------------------------- 1 | The `MultipleDigitalSignatures` sample shows how to sign a PDF file with multiple signatures. 2 | 3 | The first signature is added in normal mode (like in all the other signature related samples), but for the subsequent signatures the document must be opened and saved in incremental update mode. 4 | 5 | After the first signature is applied only new signatures can be added later (or annotations depending on the restrictions), no other content is allowed otherwise the signatures are invalidated. 6 | 7 | **NOTE:** This sample will not work properly with the evalaution version because of the evaluation message that is added to all PDF pages. This evaluation message causes the first signature to be invalidated when the second signature is applied. 8 | -------------------------------------------------------------------------------- /GettingStarted/PieAndDonutCharts/PieAndDonutCharts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using O2S.Components.PDF4NET.Graphics; 3 | 4 | namespace O2S.Components.PDF4NET.Samples.PieChart 5 | { 6 | public class PieAndDonutCharts 7 | { 8 | static void Main(string[] args) 9 | { 10 | PDFFixedDocument document = new PDFFixedDocument(); 11 | PDFPage page = document.Pages.Add(); 12 | 13 | PieChart donutChart = new PieChart(); 14 | donutChart.Parts.Add(new PiePart(60) { Fill = new PDFBrush(PDFRgbColor.Red), DonutHeight = 25 }); 15 | donutChart.Parts.Add(new PiePart(60) { Fill = new PDFBrush(PDFRgbColor.Blue), DonutHeight = 25 }); 16 | donutChart.Parts.Add(new PiePart(240) { Fill = new PDFBrush(PDFRgbColor.Green), DonutHeight = 25 }); 17 | 18 | donutChart.Render(page.Canvas, 50, 50, 200, 200); 19 | 20 | PieChart pieChart = new PieChart(); 21 | pieChart.Parts.Add(new PiePart(60) { Fill = new PDFBrush(PDFRgbColor.Red), ExplodeOffset = 5 }); 22 | pieChart.Parts.Add(new PiePart(90) { Fill = new PDFBrush(PDFRgbColor.Blue) }); 23 | pieChart.Parts.Add(new PiePart(210) { Fill = new PDFBrush(PDFRgbColor.Green) }); 24 | 25 | pieChart.Render(page.Canvas, 300, 50, 200, 200); 26 | 27 | page.Canvas.CompressAndClose(); 28 | 29 | document.Save("PieAndDonutCharts.pdf"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /GettingStarted/PieAndDonutCharts/PieAndDonutCharts.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /GettingStarted/PieAndDonutCharts/PieAndDonutCharts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/GettingStarted/PieAndDonutCharts/PieAndDonutCharts.pdf -------------------------------------------------------------------------------- /GettingStarted/PieAndDonutCharts/PiePart.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using O2S.Components.PDF4NET.Graphics; 3 | 4 | namespace O2S.Components.PDF4NET.Samples.PieChart 5 | { 6 | public class PiePart 7 | { 8 | public PiePart(double quantity) 9 | { 10 | Quantity = quantity; 11 | } 12 | 13 | private double quantity; 14 | 15 | public double Quantity 16 | { 17 | get => quantity; 18 | set 19 | { 20 | if (value <= 0) 21 | { 22 | throw new ArgumentOutOfRangeException("Quantity must be greater than 0"); 23 | } 24 | quantity = value; 25 | } 26 | } 27 | 28 | public PDFBrush Fill { get; set; } 29 | 30 | public PDFPen Outline { get; set; } 31 | 32 | private double explodeOffset; 33 | 34 | public double ExplodeOffset 35 | { 36 | get { return explodeOffset; } 37 | set 38 | { 39 | if (value < 0) 40 | { 41 | throw new ArgumentOutOfRangeException("ExplodeOffset must be greater than or equal to zero"); 42 | } 43 | explodeOffset = value; 44 | } 45 | } 46 | 47 | private double donutHeight; 48 | 49 | public double DonutHeight 50 | { 51 | get { return donutHeight; } 52 | set 53 | { 54 | if (value < 0) 55 | { 56 | throw new ArgumentOutOfRangeException("DonutHeight must be greater than or equal to zero"); 57 | } 58 | donutHeight = value; 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /GettingStarted/PieAndDonutCharts/README.md: -------------------------------------------------------------------------------- 1 | The `PieAndDonutCharts` sample shows how to create simple pie and donut charts using PDF4NET library. 2 | -------------------------------------------------------------------------------- /GettingStarted/README.md: -------------------------------------------------------------------------------- 1 | THe GettingStarted folder contains samples that combine multiple [**PDF4NET**](https://o2sol.com/pdf4net/overview.htm) features in order to implement more complex requirements. -------------------------------------------------------------------------------- /GettingStarted/RemoveUnusedResources/PDF4NET.Features.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/GettingStarted/RemoveUnusedResources/PDF4NET.Features.pdf -------------------------------------------------------------------------------- /GettingStarted/RemoveUnusedResources/README.md: -------------------------------------------------------------------------------- 1 | The `RemoveUnusedResources` sample shows how to cleanup a PDF page of unused resources in order to reduce its size after extraction. 2 | 3 | Many scanner devices generate PDF files that include all scanned images in a single /Resources dictionary and that dictionary is referenced from all the pages. 4 | 5 | When a page is extracted, all the resources in the /Resources dictionary are extracted. For these scanned documents this means that all the scanned images are extracted with each page. When the extracted page is saved as a new document, the size of the new document matches the size of the original file. 6 | 7 | A solution to this problem is to scan the page content to detect the resources actually used on the page and remove the unused ones. Since this operation adds an overhead on the page extraction process, it is recomended to used when it is known the source PDF file have this problem. 8 | 9 | The sample code implements a custom page transform that scans the page content, keeps track of used resources and removes the unused ones. 10 | 11 | The application code splits a source PDF file into single pages. It shows simple page extraction and saving and in this situation the output files have almost the same size of the source file. It also shows page extraction and saving with removal of unused resources and in this situation the outfiles are much smaller. 12 | -------------------------------------------------------------------------------- /GettingStarted/RemoveUnusedResources/RemoveUnusedResources.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /GettingStarted/RemoveUnusedResources/RemoveUnusedResources.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31321.278 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoveUnusedResources", "RemoveUnusedResources.csproj", "{8FF821DC-A6D6-4AE3-A0A5-5AE56DB52B79}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8FF821DC-A6D6-4AE3-A0A5-5AE56DB52B79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8FF821DC-A6D6-4AE3-A0A5-5AE56DB52B79}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8FF821DC-A6D6-4AE3-A0A5-5AE56DB52B79}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8FF821DC-A6D6-4AE3-A0A5-5AE56DB52B79}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {827A08F5-726B-44BE-ADBA-662F07D64547} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /GettingStarted/SearchAndRedact/README.md: -------------------------------------------------------------------------------- 1 | The `SearchAndRedact` sample shows how to redact the results of a search operation. 2 | 3 | The `PDFContentExtractor` class is used to search for text in a PDF page. 4 | 5 | The `PDFContentRedactor` class is used to redact content from a PDF page. Multiple strings can be redacted in one step by enclosing the `PDFContentRedactor.RedactArea` calls in a `PDFContentRedactor.BeginRedaction` / `PDFContentRedactor.ApplyRedaction` section. The actual redaction is executed when `PDFContentRedactor.ApplyRedaction` is called. 6 | -------------------------------------------------------------------------------- /GettingStarted/SearchAndRedact/SearchAndRedact.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET.Content; 4 | using O2S.Components.PDF4NET.Redaction; 5 | 6 | namespace O2S.Components.PDF4NET.Samples 7 | { 8 | public class SearchAndRedact 9 | { 10 | public static void Main(string[] args) 11 | { 12 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 13 | 14 | FileStream input = File.OpenRead(supportPath + "content.pdf"); 15 | PDFFixedDocument document = new PDFFixedDocument(input); 16 | input.Close(); 17 | 18 | PDFContentExtractor ce = new PDFContentExtractor(document.Pages[0]); 19 | PDFTextSearchResultCollection searchResults = ce.SearchText("lorem"); 20 | 21 | if (searchResults.Count > 0) 22 | { 23 | PDFContentRedactor cr = new PDFContentRedactor(document.Pages[0]); 24 | 25 | cr.BeginRedaction(); 26 | 27 | for (int i = 0; i < searchResults.Count; i++) 28 | { 29 | cr.RedactArea(searchResults[i].VisualBounds); 30 | } 31 | 32 | cr.ApplyRedaction(); 33 | } 34 | 35 | using(FileStream output = File.Create("RedactedSearchResults.pdf")) 36 | { 37 | document.Save(output); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /GettingStarted/SearchAndRedact/SearchAndRedact.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /GettingStarted/TaggedFlowDocument/README.md: -------------------------------------------------------------------------------- 1 | The `TaggedFlowDocument` sample shows how to create a fully tagged PDF document using the FlowDocument API. 2 | 3 | Just by setting the EnableAutomaticTagging property to true on the PDFFlowDocumentDefaults object that is passed to the PDFFlowDocument constructor, the document is tagged automatically. 4 | 5 | The sample also shows how to customize the tagging information for the logo image. 6 | -------------------------------------------------------------------------------- /GettingStarted/TaggedFlowDocument/TaggedFlowDocument.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /GettingStarted/TaggedTextExtractor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace O2S.Components.PDF4NET.Samples 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 11 | 12 | string taggedText = TaggedTextExtractor.ExtractText(supportPath + "invoice.pdf"); 13 | 14 | Console.WriteLine(taggedText); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /GettingStarted/TaggedTextExtractor/README.md: -------------------------------------------------------------------------------- 1 | The `TaggedTextExtractor` sample shows how to extract text from a PDF file in the reading order defined by the document's tag structure. 2 | The first step is to retrive the structure elements representing content items in reading order. Then the text runs are extracted from the document. 3 | Next the text runs are placed in reading order based on their associated structure element. Finally the text runs are combined into lines of text. 4 | -------------------------------------------------------------------------------- /GettingStarted/TaggedTextExtractor/TaggedTextExtractor.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Actions/Actions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Actions/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Actions 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Actions.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/AdvancedFontFeatures/AdvancedFontFeatures.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/AdvancedFontFeatures/README.md: -------------------------------------------------------------------------------- 1 | The `AdvancedFontFeatures` sample shows how to activate/deactivate advanced font features, such as ligatures, etc, when drawing text. 2 | -------------------------------------------------------------------------------- /Reference/Annotations/Annotations.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Annotations/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Annotations 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream flashInput = new FileStream(supportPath + "clock.swf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | FileStream u3dInput = new FileStream(supportPath + "airplane.u3d", FileMode.Open, FileAccess.Read, FileShare.Read); 18 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Annotations.Run(flashInput, u3dInput); 19 | flashInput.Dispose(); 20 | u3dInput.Dispose(); 21 | 22 | 23 | for (int i = 0; i < output.Length; i++) 24 | { 25 | FileStream outStream = File.OpenWrite(output[i].FileName); 26 | output[i].Document.Save(outStream, output[i].SecurityHandler); 27 | outStream.Flush(); 28 | outStream.Dispose(); 29 | } 30 | 31 | Console.WriteLine("File(s) saved with success to current folder."); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Reference/Barcodes/Barcodes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Barcodes/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Barcodes 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Barcodes.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/BatesNumbers/BatesNumbers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | using O2S.Components.PDF4NET.Content; 6 | 7 | namespace O2S.Components.PDF4NET.Samples 8 | { 9 | /// 10 | /// BatesNumbers sample. 11 | /// 12 | public class BatesNumbers 13 | { 14 | /// 15 | /// Main method for running the sample. 16 | /// 17 | public static SampleOutputInfo[] Run(Stream input) 18 | { 19 | // Load the input file. 20 | PDFFixedDocument document = new PDFFixedDocument(input); 21 | 22 | PDFBatesNumberAppearance bna = new PDFBatesNumberAppearance(); 23 | bna.Location = new PDFPoint(25, 5); 24 | bna.Brush = new PDFBrush(PDFRgbColor.DarkRed); 25 | 26 | PDFBatesNumberProvider bnp = new PDFBatesNumberProvider(); 27 | bnp.Prefix = "O2S"; 28 | bnp.Suffix = "PDF4NET"; 29 | bnp.StartNumber = 1; 30 | 31 | PDFBatesNumber.WriteBatesNumber(document, bnp, bna); 32 | 33 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "batesnumbers.pdf") }; 34 | return output; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Reference/BatesNumbers/BatesNumbers.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/BatesNumbers/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class BatesNumbers 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream batesNumbersInput = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.BatesNumbers.Run(batesNumbersInput); 18 | batesNumbersInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/CertifyingSignature/CertifyingSignature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using O2S.Components.PDF4NET; 3 | using System.Security.Cryptography.X509Certificates; 4 | using System.IO; 5 | using O2S.Components.PDF4NET.Forms; 6 | using O2S.Components.PDF4NET.DigitalSignatures; 7 | 8 | namespace O2S.Components.PDF4NET.Samples.NetCore 9 | { 10 | /// 11 | /// CertifyingSignature sample. 12 | /// 13 | public class CertifyingSignature 14 | { 15 | /// 16 | /// Main method for running the sample. 17 | /// 18 | public static SampleOutputInfo[] Run(Stream formStream, X509Certificate2 certificate) 19 | { 20 | PDFFixedDocument document = new PDFFixedDocument(formStream); 21 | 22 | document.PDFVersion = PDFVersion.Version16; 23 | PDFSignatureField signField = document.Form.Fields["signhere"] as PDFSignatureField; 24 | PDFCmsDigitalSignature signature = new PDFCmsDigitalSignature(); 25 | signature.SignatureDigestAlgorithm = PDFDigitalSignatureDigestAlgorithm.Sha256; 26 | signature.Certificate = certificate; 27 | signature.ContactInfo = "techsupport@o2sol.com"; 28 | signature.Location = "Cluj Napoca"; 29 | signature.Name = "O2 Solutions Support"; 30 | signature.Reason = "Certifying signature"; 31 | signField.Signature = signature; 32 | // Certify the document with the signature included in the field. 33 | document.CertifyDocument(signField, PDFDigitalSignatureAllowedChanges.AllowFormFilling); 34 | 35 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "certifyingsignature.pdf") }; 36 | return output; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Reference/CertifyingSignature/CertifyingSignature.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/CertifyingSignature/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using System.Security.Cryptography.X509Certificates; 5 | using O2S.Components.PDF4NET; 6 | using O2S.Components.PDF4NET.Samples; 7 | 8 | namespace O2S.Components.PDF4NET.Samples.NetCore 9 | { 10 | class CertifyingSignature 11 | { 12 | static void Main(string[] args) 13 | { 14 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 15 | 16 | X509Certificate2 certificate = new X509Certificate2(supportPath + "O2SolutionsDemoCertificate.pfx", "P@ssw0rd!", X509KeyStorageFlags.Exportable); 17 | FileStream formStream = File.OpenRead(supportPath + "formfill.pdf"); 18 | 19 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.CertifyingSignature.Run(formStream, certificate); 20 | 21 | formStream.Close(); 22 | 23 | for (int i = 0; i < output.Length; i++) 24 | { 25 | FileStream outStream = new FileStream(output[i].FileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read); 26 | output[i].Document.Save(outStream, output[i].SecurityHandler); 27 | outStream.Flush(); 28 | outStream.Dispose(); 29 | } 30 | 31 | Console.WriteLine("File(s) saved with success to current folder."); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Reference/ComplexScriptsFlowContent/ComplexScriptsFlowContent.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/ComplexScriptsFlowContent/README.md: -------------------------------------------------------------------------------- 1 | The `ComplexScriptsFlowContent` sample shows how to display Arabic, Bengali, Devanagari, Gujarati, Gurmukhi, Hebrew, Kannada, Kashmiri, Khmer, Kurdish, Lao, Malayalam, Myanmar Burmese, Oriya, Persian, Sindhi, Tamil, Telugu, Thai, Urdu and Uyghur text in flow documents. 2 | -------------------------------------------------------------------------------- /Reference/ComplexScriptsFormFill/ComplexScriptsFormFill.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/ComplexScriptsFormFill/README.md: -------------------------------------------------------------------------------- 1 | The `ComplexScriptsFormFill` sample shows how to fill forms with Arabic, Bengali, Devanagari, Gujarati, Gurmukhi, Hebrew, Kannada, Kashmiri, Khmer, Kurdish, Lao, Malayalam, Myanmar Burmese, Oriya, Persian, Sindhi, Tamil, Telugu, Thai, Urdu and Uyghur text. 2 | -------------------------------------------------------------------------------- /Reference/ComplexScriptsTables/ComplexScriptsTables.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/ComplexScriptsTables/README.md: -------------------------------------------------------------------------------- 1 | The `ComplexScriptsTables` sample shows how to creates tables with Arabic, Bengali, Devanagari, Gujarati, Gurmukhi, Hebrew, Kannada, Kashmiri, Khmer, Kurdish, Lao, Malayalam, Myanmar Burmese, Oriya, Persian, Sindhi, Tamil, Telugu, Thai, Urdu and Uyghur text. 2 | -------------------------------------------------------------------------------- /Reference/ComplexScriptsText/ComplexScriptsText.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/ComplexScriptsText/README.md: -------------------------------------------------------------------------------- 1 | The `ComplexScriptsText` sample shows how to draw simple text using complex scripts such as: Arabic, Bengali, Devanagari, Gujarati, Gurmukhi, Hebrew, Kannada, Kashmiri, Khmer, Kurdish, Lao, Malayalam, Myanmar Burmese, Oriya, Persian, Sindhi, Tamil, Telugu, Thai, Urdu and Uyghur. 2 | -------------------------------------------------------------------------------- /Reference/ContentExtraction/ContentExtraction.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/ContentExtraction/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class ContentExtraction 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream contentExtractionInput = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.ContentExtraction.Run(contentExtractionInput); 18 | contentExtractionInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/ContentStream/ContentStream.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/ContentStream/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class ContentStream 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.ContentStream.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/DocumentAppend/DocumentAppend.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/DocumentAppend/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class DocumentAppend 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream file1Input = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | FileStream file2Input = new FileStream(supportPath + "formfill.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 18 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.DocumentAppend.Run(file1Input, file2Input); 19 | file1Input.Dispose(); 20 | file2Input.Dispose(); 21 | 22 | 23 | for (int i = 0; i < output.Length; i++) 24 | { 25 | FileStream outStream = File.OpenWrite(output[i].FileName); 26 | output[i].Document.Save(outStream, output[i].SecurityHandler); 27 | outStream.Flush(); 28 | outStream.Dispose(); 29 | } 30 | 31 | Console.WriteLine("File(s) saved with success to current folder."); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Reference/DocumentIncrementalUpdate/DocumentIncrementalUpdate.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/DocumentIncrementalUpdate/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class DocumentIncrementalUpdate 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | File.Copy(supportPath + "content.pdf", "documentincrementalupdate.pdf", true); 17 | FileStream incrementalUpdateInput = 18 | new FileStream("documentincrementalupdate.pdf", FileMode.Open, FileAccess.ReadWrite, FileShare.Read); 19 | O2S.Components.PDF4NET.Samples.DocumentIncrementalUpdate.Run(incrementalUpdateInput); 20 | incrementalUpdateInput.Flush(); 21 | incrementalUpdateInput.Dispose(); 22 | 23 | Console.WriteLine("File(s) saved with success to current folder."); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Reference/DocumentPageByPageSave/DocumentPageByPageSave.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | using O2S.Components.PDF4NET.Redaction; 6 | 7 | namespace O2S.Components.PDF4NET.Samples 8 | { 9 | /// 10 | /// DocumentPageByPageSave sample. 11 | /// 12 | public class DocumentPageByPageSave 13 | { 14 | /// 15 | /// Main method for running the sample. 16 | /// 17 | public static SampleOutputInfo[] Run(Stream output) 18 | { 19 | PDFFixedDocument document = new PDFFixedDocument(); 20 | 21 | // Init the save operation 22 | document.BeginSave(output); 23 | 24 | PDFRgbColor color = new PDFRgbColor(); 25 | PDFBrush brush = new PDFBrush(color); 26 | Random rnd = new Random(); 27 | 28 | for (int i = 0; i < 3; i++) 29 | { 30 | PDFPage page = document.Pages.Add(); 31 | page.Width = 1000; 32 | page.Height = 1000; 33 | 34 | for (int y = 1; y <= page.Height; y++) 35 | { 36 | for (int x = 0; x < page.Width; x++) 37 | { 38 | color.R = (byte)rnd.Next(256); 39 | color.G = (byte)rnd.Next(256); 40 | color.B = (byte)rnd.Next(256); 41 | 42 | page.Canvas.DrawRectangle(brush, x, y - 1, 1, 1); 43 | } 44 | 45 | if ((y % 100) == 0) 46 | { 47 | // Compress the graphics that have been drawn so far and save them. 48 | page.Canvas.Compress(); 49 | page.SaveGraphics(); 50 | } 51 | } 52 | 53 | // Close the page graphics and save the page. 54 | page.Canvas.CompressAndClose(); 55 | page.Save(); 56 | } 57 | 58 | // Finish the document. 59 | document.EndSave(); 60 | 61 | return null; 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Reference/DocumentPageByPageSave/DocumentPageByPageSave.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/DocumentPageByPageSave/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class DocumentPageByPageSave 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream documentPageByPageSaveOutput = 17 | new FileStream("documentpagebypagesave.pdf", FileMode.Create, FileAccess.ReadWrite, FileShare.Read); 18 | O2S.Components.PDF4NET.Samples.DocumentPageByPageSave.Run(documentPageByPageSaveOutput); 19 | documentPageByPageSaveOutput.Flush(); 20 | documentPageByPageSaveOutput.Dispose(); 21 | 22 | Console.WriteLine("File(s) saved with success to current folder."); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Reference/DocumentProperties/DocumentProperties.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/DocumentProperties/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class DocumentProperties 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.DocumentProperties.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/DocumentSplit/DocumentSplit.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | using O2S.Components.PDF4NET.Destinations; 6 | using O2S.Components.PDF4NET.Actions; 7 | using O2S.Components.PDF4NET.Core; 8 | 9 | namespace O2S.Components.PDF4NET.Samples 10 | { 11 | /// 12 | /// DocumentSplit sample. 13 | /// 14 | public class DocumentSplit 15 | { 16 | /// 17 | /// Main method for running the sample. 18 | /// 19 | public static SampleOutputInfo[] Run(Stream input) 20 | { 21 | // The input file is split by extracting pages from source file and inserting them in new empty PDF documents. 22 | PDFFile file = new PDFFile(input); 23 | SampleOutputInfo[] output = new SampleOutputInfo[file.PageCount]; 24 | 25 | for (int i = 0; i < file.PageCount; i++) 26 | { 27 | PDFFixedDocument document = new PDFFixedDocument(); 28 | PDFPage page = file.ExtractPage(i); 29 | document.Pages.Add(page); 30 | 31 | output[i] = new SampleOutputInfo(document, string.Format("documentsplit.{0}.pdf", i + 1)); 32 | } 33 | 34 | return output; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Reference/DocumentSplit/DocumentSplit.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/DocumentSplit/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class DocumentSplit 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream splitInput = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.DocumentSplit.Run(splitInput); 18 | splitInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/DocumentTimeStamp/DocumentTimeStamp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using O2S.Components.PDF4NET; 3 | using System.Security.Cryptography.X509Certificates; 4 | using System.IO; 5 | using O2S.Components.PDF4NET.Forms; 6 | using O2S.Components.PDF4NET.DigitalSignatures; 7 | 8 | namespace O2S.Components.PDF4NET.Samples 9 | { 10 | /// 11 | /// DocumentTimeStamp sample. 12 | /// 13 | public class DocumentTimeStamp 14 | { 15 | /// 16 | /// Main method for running the sample. 17 | /// 18 | public static SampleOutputInfo[] Run(Stream formStream, SignatureTimestampNeeded onTimeStamp) 19 | { 20 | PDFFixedDocument document = new PDFFixedDocument(formStream); 21 | 22 | PDFSignatureField signField = document.Form.Fields["signhere"] as PDFSignatureField; 23 | signField.Signature = new PDFDocumentTimeStamp(); 24 | signField.Signature.TimestampDigestAlgorithm = PDFDigitalSignatureDigestAlgorithm.Sha256; 25 | signField.Signature.OnSignatureTimestampNeeded += onTimeStamp; 26 | 27 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "documenttimestamp.pdf") }; 28 | return output; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Reference/DocumentTimeStamp/DocumentTimeStamp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/DocumentTimeStamp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Net; 4 | using System.Reflection; 5 | using O2S.Components.PDF4NET; 6 | using O2S.Components.PDF4NET.DigitalSignatures; 7 | 8 | namespace O2S.Components.PDF4NET.Samples.NetCore 9 | { 10 | class DocumentTimeStamp 11 | { 12 | static void Main(string[] args) 13 | { 14 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 15 | 16 | FileStream formStream = File.OpenRead(supportPath + "formfill.pdf"); 17 | 18 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.DocumentTimeStamp.Run(formStream, OnSignatureTimeStamp); 19 | 20 | formStream.Close(); 21 | 22 | for (int i = 0; i < output.Length; i++) 23 | { 24 | FileStream outStream = new FileStream(output[i].FileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read); 25 | output[i].Document.Save(outStream, output[i].SecurityHandler); 26 | outStream.Flush(); 27 | outStream.Dispose(); 28 | } 29 | 30 | Console.WriteLine("File(s) saved with success to current folder."); 31 | } 32 | 33 | private static void OnSignatureTimeStamp(PDFTimeStampEventData eventData) 34 | { 35 | HttpWebRequest tsaReq = (HttpWebRequest)WebRequest.Create(""); 36 | 37 | tsaReq.ContentType = "application/timestamp-query"; 38 | tsaReq.Method = "POST"; 39 | Stream tsaReqStream = tsaReq.GetRequestStream(); 40 | tsaReqStream.Write(eventData.TimeStampRequest, 0, eventData.TimeStampRequest.Length); 41 | 42 | HttpWebResponse tsaResp = (HttpWebResponse)tsaReq.GetResponse(); 43 | Stream tsaRespStream = tsaResp.GetResponseStream(); 44 | 45 | byte[] buffer = new byte[65536]; 46 | int responseSize = tsaRespStream.Read(buffer, 0, buffer.Length); 47 | 48 | eventData.TimeStampResponse = new byte[responseSize]; 49 | Array.Copy(buffer, 0, eventData.TimeStampResponse, 0, responseSize); 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Reference/Emoji/Emoji.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Emoji/README.md: -------------------------------------------------------------------------------- 1 | The `Emoji` sample shows how to include emojis and other graphical characters in PDF text. 2 | -------------------------------------------------------------------------------- /Reference/Encryption/Encryption.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Encryption/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Encryption 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream encryptionInput = new FileStream(supportPath + "encrypted.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Encryption.Run(encryptionInput); 18 | encryptionInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/FileAttachments/FileAttachments.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | 6 | namespace O2S.Components.PDF4NET.Samples 7 | { 8 | /// 9 | /// FileAttachments sample. 10 | /// 11 | public class FileAttachments 12 | { 13 | /// 14 | /// Main method for running the sample. 15 | /// 16 | public static SampleOutputInfo[] Run(Stream s1, Stream s2) 17 | { 18 | PDFFixedDocument document = new PDFFixedDocument(); 19 | document.DisplayMode = PDFDisplayMode.UseAttachments; 20 | 21 | PDFStandardFont helvetica = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16); 22 | PDFBrush blackBrush = new PDFBrush(); 23 | PDFPage page = document.Pages.Add(); 24 | page.Canvas.DrawString("This document contains 2 file attachments:", helvetica, blackBrush, 50, 50); 25 | page.Canvas.DrawString("1. fileattachments.cs.html", helvetica, blackBrush, 50, 70); 26 | page.Canvas.DrawString("2. fileattachments.vb.html", helvetica, blackBrush, 50, 90); 27 | 28 | byte[] fileData1 = new byte[s1.Length]; 29 | s1.Read(fileData1, 0, fileData1.Length); 30 | PDFDocumentFileAttachment fileAttachment1 = new PDFDocumentFileAttachment(); 31 | fileAttachment1.Payload = fileData1; 32 | fileAttachment1.FileName = "fileattachments.cs.html"; 33 | fileAttachment1.Description = "C# Source Code for FileAttachments sample"; 34 | document.FileAttachments.Add(fileAttachment1); 35 | 36 | byte[] fileData2 = new byte[s2.Length]; 37 | s2.Read(fileData2, 0, fileData2.Length); 38 | PDFDocumentFileAttachment fileAttachment2 = new PDFDocumentFileAttachment(); 39 | fileAttachment2.Payload = fileData1; 40 | fileAttachment2.FileName = "fileattachments.vb.html"; 41 | fileAttachment2.Description = "VB.NET Source Code for FileAttachments sample"; 42 | document.FileAttachments.Add(fileAttachment2); 43 | 44 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "fileattachments.pdf") }; 45 | return output; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Reference/FileAttachments/FileAttachments.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/FileAttachments/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class FileAttachments 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream attachmentStream1 = new FileStream(supportPath + "fileattachments_cs.html", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | FileStream attachmentStream2 = new FileStream(supportPath + "fileattachments_vb.html", FileMode.Open, FileAccess.Read, FileShare.Read); 18 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.FileAttachments.Run(attachmentStream1, attachmentStream2); 19 | attachmentStream1.Dispose(); 20 | attachmentStream2.Dispose(); 21 | 22 | 23 | for (int i = 0; i < output.Length; i++) 24 | { 25 | FileStream outStream = File.OpenWrite(output[i].FileName); 26 | output[i].Document.Save(outStream, output[i].SecurityHandler); 27 | outStream.Flush(); 28 | outStream.Dispose(); 29 | } 30 | 31 | Console.WriteLine("File(s) saved with success to current folder."); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Reference/FlowDocumentWithExternalPages/FlowDocumentWithExternalPages.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/FlowDocumentWithExternalPages/README.md: -------------------------------------------------------------------------------- 1 | The `FlowDocumentWithExternalPages` sample shows how integrate PDF pages from external PDF files into a flow document. External pages can be read only (flow content will not be added to them) or they can be writeable and flow content can be added to them. 2 | -------------------------------------------------------------------------------- /Reference/Fonts/Fonts.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Fonts/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Fonts 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream ttfStream = new FileStream(supportPath + "verdana.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Fonts.Run(ttfStream); 18 | ttfStream.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/FormFill/FormFill.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | using O2S.Components.PDF4NET.Forms; 6 | 7 | namespace O2S.Components.PDF4NET.Samples 8 | { 9 | /// 10 | /// FormFill sample. 11 | /// 12 | public class FormFill 13 | { 14 | /// 15 | /// Main method for running the sample. 16 | /// 17 | /// 18 | public static SampleOutputInfo[] Run(Stream stream) 19 | { 20 | PDFFixedDocument document = new PDFFixedDocument(stream); 21 | (document.Form.Fields["firstname"] as PDFTextBoxField).Text = "John"; 22 | (document.Form.Fields["lastname"] as PDFTextBoxField).Value = "Doe"; 23 | 24 | (document.Form.Fields["sex"].Widgets[0] as PDFRadioButtonWidget).Checked = true; 25 | 26 | (document.Form.Fields["firstcar"] as PDFDropDownListField).SelectedIndex = 0; 27 | 28 | (document.Form.Fields["secondcar"] as PDFListBoxField).SelectedIndex = 1; 29 | 30 | (document.Form.Fields["agree"] as PDFCheckBoxField).Checked = true; 31 | document.Form.FlattenFields(); 32 | 33 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "formfill.pdf") }; 34 | return output; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Reference/FormFill/FormFill.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/FormFill/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class FormFill 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream formStream = new FileStream(supportPath + "formfill.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.FormFill.Run(formStream); 18 | formStream.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/FormFillLowOverhead/FormFillLowOverhead.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Core; 5 | 6 | namespace O2S.Components.PDF4NET.Samples.NetCore 7 | { 8 | class FormFillLowOverhead 9 | { 10 | static void Main(string[] args) 11 | { 12 | FileStream pdfStream = File.OpenRead("..\\..\\..\\..\\..\\SupportFiles\\formfill.pdf"); 13 | PDFFileEx pdfFile = new PDFFileEx(pdfStream); 14 | pdfStream.Close(); 15 | 16 | // For text fields the value is the field text 17 | pdfFile.SetFieldValue("firstname", "John"); 18 | pdfFile.SetFieldValue("lastname", "Doe"); 19 | 20 | // For radio buttons the value is the export value of the selected widget 21 | pdfFile.SetFieldValue("sex", "M"); 22 | 23 | // For drop down lists and listboxes the value is the index of the selected item 24 | pdfFile.SetFieldValue("firstcar", 0); 25 | pdfFile.SetFieldValue("secondcar", 1); 26 | 27 | // For checkboxes the value is true for checked and false for unchecked 28 | pdfFile.SetFieldValue("agree", true); 29 | 30 | pdfFile.FlattenFormFields(); 31 | pdfFile.Save("FormFillLowOverhead.pdf"); 32 | 33 | Console.WriteLine("File saved with success to current folder."); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Reference/FormFillLowOverhead/FormFillLowOverhead.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/FormFillLowOverhead/README.md: -------------------------------------------------------------------------------- 1 | The `FormFillLowOverhead` sample shows how to fill form fields using the new API available in PDFFileEx class. 2 | -------------------------------------------------------------------------------- /Reference/FormGenerator/FormGenerator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/FormGenerator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class FormGenerator 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.FormGenerator.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/FormatedContent/FormatedContent.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/FormatedContent/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class FormatedContent 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.FormattedContent.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/GrayscaleConversion/GrayscaleConversion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | using O2S.Components.PDF4NET.Transforms; 6 | 7 | namespace O2S.Components.PDF4NET.Samples 8 | { 9 | /// 10 | /// GrayscaleConversion sample. 11 | /// 12 | public class GrayscaleConversion 13 | { 14 | /// 15 | /// Main method for running the sample. 16 | /// 17 | public static SampleOutputInfo[] Run(Stream input) 18 | { 19 | // Load the input file. 20 | PDFFixedDocument document = new PDFFixedDocument(input); 21 | 22 | PDFConvertToGrayTransform grayTransform = new PDFConvertToGrayTransform(); 23 | PDFPageTransformer pageTransformer = new PDFPageTransformer(document.Pages[3]); 24 | pageTransformer.ApplyTransform(grayTransform); 25 | 26 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "grayscaleconversion.pdf") }; 27 | return output; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Reference/GrayscaleConversion/GrayscaleConversion.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/GrayscaleConversion/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class GrayscaleConversion 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream grayscaleConversionInput = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.GrayscaleConversion.Run(grayscaleConversionInput); 18 | grayscaleConversionInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/HeadersAndFooters/HeadersAndFooters.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/HeadersAndFooters/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.Pcl 8 | { 9 | class HeadersAndFooters 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream verdanaStream = new FileStream(supportPath + "verdana.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | FileStream verdanaBoldStream = new FileStream(supportPath + "verdanab.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 18 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.HeadersAndFooters.Run(verdanaStream, verdanaBoldStream, logoStream); 19 | verdanaStream.Dispose(); 20 | verdanaBoldStream.Dispose(); 21 | 22 | 23 | for (int i = 0; i < output.Length; i++) 24 | { 25 | FileStream outStream = File.OpenWrite(output[i].FileName); 26 | output[i].Document.Save(outStream, output[i].SecurityHandler); 27 | outStream.Flush(); 28 | outStream.Dispose(); 29 | } 30 | 31 | Console.WriteLine("File(s) saved with success to current folder."); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Reference/Images/Images.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Images/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Images 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream imageStream = new FileStream(supportPath + "image.jpg", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | FileStream cmykImageStream = new FileStream(supportPath + "cmyk.tif", FileMode.Open, FileAccess.Read, FileShare.Read); 18 | FileStream softMaskStream = new FileStream(supportPath + "softmask.png", FileMode.Open, FileAccess.Read, FileShare.Read); 19 | FileStream stencilMaskStream = new FileStream(supportPath + "stencilmask.png", FileMode.Open, FileAccess.Read, FileShare.Read); 20 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Images.Run(imageStream, cmykImageStream, softMaskStream, stencilMaskStream); 21 | imageStream.Dispose(); 22 | cmykImageStream.Dispose(); 23 | softMaskStream.Dispose(); 24 | stencilMaskStream.Dispose(); 25 | 26 | 27 | for (int i = 0; i < output.Length; i++) 28 | { 29 | FileStream outStream = File.OpenWrite(output[i].FileName); 30 | output[i].Document.Save(outStream, output[i].SecurityHandler); 31 | outStream.Flush(); 32 | outStream.Dispose(); 33 | } 34 | 35 | Console.WriteLine("File(s) saved with success to current folder."); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Reference/Invoice/Invoice.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Invoice/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.Pcl 8 | { 9 | class Invoice 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream logoStream = new FileStream(supportPath + "logo.png", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | FileStream invoiceVerdanaStream = new FileStream(supportPath + "verdana.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 18 | FileStream invoiceVerdanaBoldStream = new FileStream(supportPath + "verdanab.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 19 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Invoice.Run(invoiceVerdanaStream, invoiceVerdanaBoldStream, logoStream); 20 | logoStream.Dispose(); 21 | invoiceVerdanaStream.Dispose(); 22 | invoiceVerdanaBoldStream.Dispose(); 23 | 24 | 25 | for (int i = 0; i < output.Length; i++) 26 | { 27 | FileStream outStream = File.OpenWrite(output[i].FileName); 28 | output[i].Document.Save(outStream, output[i].SecurityHandler); 29 | outStream.Flush(); 30 | outStream.Dispose(); 31 | } 32 | 33 | Console.WriteLine("File(s) saved with success to current folder."); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Reference/Measurements/Measurements.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Measurements/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Measurements 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Measurements.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/MergeAndEncrypt/MergeAndEncrypt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Core.Security; 6 | using O2S.Components.PDF4NET.Samples; 7 | using O2S.Components.PDF4NET.Utilities; 8 | 9 | namespace O2S.Components.PDF4NET.Samples.NetCore 10 | { 11 | class MergeAndEncrypt 12 | { 13 | static void Main(string[] args) 14 | { 15 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 16 | 17 | PDFMerger merger = new PDFMerger(); 18 | merger.AppendFile(supportPath + "content.pdf"); 19 | merger.AppendFile(supportPath + "formfill.pdf"); 20 | merger.AppendFile(supportPath + "encrypted.pdf", "pdf4net"); 21 | 22 | PDFAesSecurityHandler aes256e = new PDFAesSecurityHandler(); 23 | aes256e.KeySize = 256; 24 | aes256e.UseEnhancedPasswordValidation = true; 25 | aes256e.UserPassword = "pdfmerger"; 26 | merger.Save("mergeandencrypt.pdf", aes256e); 27 | 28 | Console.WriteLine("Merged file saved with success to current folder."); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Reference/MergeAndEncrypt/MergeAndEncrypt.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/MergeAndEncrypt/README.md: -------------------------------------------------------------------------------- 1 | The `MergeAndEncrypt` sample shows how to merge multiple PDF files, some of them being encrypted. The resulted merged file is also saved using AES-256 encryption. 2 | -------------------------------------------------------------------------------- /Reference/OptionalContent/OptionalContent.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/OptionalContent/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class OptionalContent 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.OptionalContent.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/OptionalContentExtraction/OptionalContentExtraction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | using O2S.Components.PDF4NET.Core; 6 | using O2S.Components.PDF4NET.Content; 7 | 8 | namespace O2S.Components.PDF4NET.Samples 9 | { 10 | /// 11 | /// OptionalContentExtraction sample. 12 | /// 13 | public class OptionalContentExtraction 14 | { 15 | /// 16 | /// Main method for running the sample. 17 | /// 18 | public static SampleOutputInfo[] Run(Stream input) 19 | { 20 | PDFFile file = new PDFFile(input); 21 | 22 | PDFFixedDocument document = new PDFFixedDocument(); 23 | PDFPage page = document.Pages.Add(); 24 | 25 | PDFPageOptionalContent oc1 = file.ExtractPageOptionalContentGroup(4, "1"); 26 | page.Canvas.DrawFormXObject(oc1, 0, 0, page.Width / 2, page.Height / 2); 27 | PDFPageOptionalContent oc2 = file.ExtractPageOptionalContentGroup(4, "2"); 28 | page.Canvas.DrawFormXObject(oc2, page.Width / 2, 0, page.Width / 2, page.Height / 2); 29 | PDFPageOptionalContent oc3 = file.ExtractPageOptionalContentGroup(4, "3"); 30 | page.Canvas.DrawFormXObject(oc3, 0, page.Height / 2, page.Width / 2, page.Height / 2); 31 | PDFPageOptionalContent oc4 = file.ExtractPageOptionalContentGroup(4, "4"); 32 | page.Canvas.DrawFormXObject(oc4, page.Width / 2, page.Height / 2, page.Width / 2, page.Height / 2); 33 | 34 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "optionalcontentextraction.pdf") }; 35 | return output; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Reference/OptionalContentExtraction/OptionalContentExtraction.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/OptionalContentExtraction/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class OptionalContentExtraction 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream optionalContentExtractionInput = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.OptionalContentExtraction.Run(optionalContentExtractionInput); 18 | optionalContentExtractionInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/Outlines/Outlines.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Outlines/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Outlines 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Outlines.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/PAdESSignature/PAdESSignature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using O2S.Components.PDF4NET; 3 | using System.Security.Cryptography.X509Certificates; 4 | using System.IO; 5 | using O2S.Components.PDF4NET.Forms; 6 | using O2S.Components.PDF4NET.DigitalSignatures; 7 | 8 | namespace O2S.Components.PDF4NET.Samples 9 | { 10 | /// 11 | /// PAdESSignature sample. 12 | /// 13 | public class PAdESSignature 14 | { 15 | /// 16 | /// Main method for running the sample. 17 | /// 18 | public static SampleOutputInfo[] Run(Stream formStream, X509Certificate2 certificate) 19 | { 20 | PDFFixedDocument document = new PDFFixedDocument(formStream); 21 | 22 | document.PDFVersion = PDFVersion.Version17; 23 | document.VersionExtension = new PDFVersionExtension("/ESIC", 2, PDFVersion.Version17); 24 | 25 | PDFSignatureField signField = document.Form.Fields["signhere"] as PDFSignatureField; 26 | PDFPadesDigitalSignature signature = new PDFPadesDigitalSignature(); 27 | signature.SignatureDigestAlgorithm = PDFDigitalSignatureDigestAlgorithm.Sha256; 28 | signature.Certificate = certificate; 29 | signature.ContactInfo = "techsupport@o2sol.com"; 30 | signature.Location = "Cluj Napoca"; 31 | signature.Name = "O2 Solutions Support"; 32 | signature.Reason = "PAdES signature"; 33 | signField.Signature = signature; 34 | 35 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "padessignature.pdf") }; 36 | return output; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Reference/PAdESSignature/PAdESSignature.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/PAdESSignature/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using System.Security.Cryptography.X509Certificates; 5 | 6 | namespace O2S.Components.PDF4NET.Samples.NetCore 7 | { 8 | class PADESSignature 9 | { 10 | static void Main(string[] args) 11 | { 12 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 13 | 14 | X509Certificate2 certificate = new X509Certificate2(supportPath + "O2SolutionsDemoCertificate.pfx", "P@ssw0rd!", X509KeyStorageFlags.Exportable); 15 | FileStream formStream = File.OpenRead(supportPath + "formfill.pdf"); 16 | 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.PAdESSignature.Run(formStream, certificate); 18 | 19 | formStream.Close(); 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = new FileStream(output[i].FileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/PDFA/PDFA.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/PDFA/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | using O2S.Components.PDF4NET.Standards; 7 | 8 | namespace O2S.Components.PDF4NET.Samples.NetCore 9 | { 10 | class PDFA 11 | { 12 | static void Main(string[] args) 13 | { 14 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 15 | 16 | 17 | FileStream iccInput = new FileStream(supportPath + "rgb.icc", FileMode.Open, FileAccess.Read, FileShare.Read); 18 | FileStream ttfInput = new FileStream(supportPath + "verdana.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 19 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.PDFA.Run(iccInput, ttfInput); 20 | iccInput.Dispose(); 21 | ttfInput.Dispose(); 22 | 23 | 24 | PDFAFormat[] pdfaFormats = new PDFAFormat[] { PDFAFormat.PDFA1b, PDFAFormat.PDFA2u, PDFAFormat.PDFA3u }; 25 | for (int i = 0; i < output.Length; i++) 26 | { 27 | FileStream outStream = File.OpenWrite(output[i].FileName); 28 | PDFAFormatter.Save(output[i].Document as PDFFixedDocument, outStream, pdfaFormats[i]); 29 | outStream.Flush(); 30 | outStream.Dispose(); 31 | } 32 | 33 | Console.WriteLine("File(s) saved with success to current folder."); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Reference/PDFUA/PDFUA.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/PDFUA/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples..NetCore 8 | { 9 | class PDFUA 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = ".\\..\\..\\..\\..\\..\\Support\\"; 14 | 15 | FileStream logoStream = new FileStream(supportPath + "logo.png", FileMode.Open, FileAccess.Read, FileShare.Read); 16 | FileStream verdanaStream = new FileStream(supportPath + "verdana.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | FileStream verdanaBoldStream = new FileStream(supportPath + "verdanab.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 18 | SampleOutputInfo output = O2S.Components.PDF4NET.Samples.PDFUA.Run(verdanaStream, verdanaBoldStream, logoStream); 19 | logoStream.Dispose(); 20 | verdanaStream.Dispose(); 21 | verdanaBoldStream.Dispose(); 22 | 23 | FileStream outStream = File.OpenWrite(output.FileName); 24 | PDFUAFormatter.Save(output.Document as PDFFixedDocument, outStream, PDFUAFormat.PDFUA1); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | 28 | Console.WriteLine("File(s) saved with success to current folder."); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Reference/PageAnalyzer/PageAnalyzer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/PageImposition/PageImposition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | using O2S.Components.PDF4NET.Core; 6 | 7 | namespace O2S.Components.PDF4NET.Samples 8 | { 9 | /// 10 | /// PageImposition sample. 11 | /// 12 | public class PageImposition 13 | { 14 | /// 15 | /// Main method for running the sample. 16 | /// 17 | public static SampleOutputInfo[] Run(Stream input) 18 | { 19 | PDFFile file = new PDFFile(input); 20 | PDFPageContent[] content = file.ExtractPageContent(0, file.PageCount - 1); 21 | file = null; 22 | 23 | PDFFixedDocument document = new PDFFixedDocument(); 24 | PDFPage page1 = document.Pages.Add(); 25 | // Draw the same page content 4 times on the new page, the content is scaled to half and flipped. 26 | page1.Canvas.DrawFormXObject(content[0], 27 | 0, 0, page1.Width / 2, page1.Height / 2); 28 | page1.Canvas.DrawFormXObject(content[0], 29 | page1.Width / 2, 0, page1.Width / 2, page1.Height / 2, 0, PDFFlipDirection.VerticalFlip); 30 | page1.Canvas.DrawFormXObject(content[0], 31 | 0, page1.Height / 2, page1.Width / 2, page1.Height / 2, 0, PDFFlipDirection.HorizontalFlip); 32 | page1.Canvas.DrawFormXObject(content[0], 33 | page1.Width / 2, page1.Height / 2, page1.Width / 2, page1.Height / 2, 34 | 0, PDFFlipDirection.VerticalFlip | PDFFlipDirection.HorizontalFlip); 35 | 36 | PDFPage page2 = document.Pages.Add(); 37 | // Draw 3 pages on the new page. 38 | page2.Canvas.DrawFormXObject(content[0], 39 | 0, 0, page2.Width / 2, page2.Height / 2); 40 | page2.Canvas.DrawFormXObject(content[1], 41 | page2.Width / 2, 0, page2.Width / 2, page2.Height / 2); 42 | page2.Canvas.DrawFormXObject(content[2], 43 | 0, page2.Height, page2.Height / 2, page2.Width, 90); 44 | 45 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "pageimposition.pdf") }; 46 | return output; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Reference/PageImposition/PageImposition.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/PageImposition/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class PageImposition 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream pageImpositionInput = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.PageImposition.Run(pageImpositionInput); 18 | pageImpositionInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/PageObjects/PageObjects.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/PageObjects/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class PageObjects 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream pageObjectsInput = new FileStream(supportPath + "pageobjects.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.PageObjects.Run(pageObjectsInput); 18 | pageObjectsInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/Portfolios/Portfolios.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Portfolios/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Portfolios 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream imagesStream = new FileStream(supportPath + "image.jpg", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | FileStream pdfStream = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 18 | FileStream csStream = new FileStream(supportPath + "portfolios_cs.html", FileMode.Open, FileAccess.Read, FileShare.Read); 19 | FileStream vbStream = new FileStream(supportPath + "portfolios_vb.html", FileMode.Open, FileAccess.Read, FileShare.Read); 20 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Portfolios.Run(imagesStream, pdfStream, csStream, vbStream); 21 | imagesStream.Dispose(); 22 | pdfStream.Dispose(); 23 | csStream.Dispose(); 24 | vbStream.Dispose(); 25 | 26 | 27 | for (int i = 0; i < output.Length; i++) 28 | { 29 | FileStream outStream = File.OpenWrite(output[i].FileName); 30 | output[i].Document.Save(outStream, output[i].SecurityHandler); 31 | outStream.Flush(); 32 | outStream.Dispose(); 33 | } 34 | 35 | Console.WriteLine("File(s) saved with success to current folder."); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Reference/README.md: -------------------------------------------------------------------------------- 1 | The Reference folder contains basic [**PDF4NET**](https://o2sol.com/pdf4net/overview.htm) samples, each one demonstrating a specific [**PDF4NET**](https://o2sol.com/pdf4net/overview.htm) feature. -------------------------------------------------------------------------------- /Reference/Redaction/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Redaction 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream redactionStream = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Redaction.Run(redactionStream); 18 | redactionStream.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/Redaction/Redaction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | using O2S.Components.PDF4NET.Redaction; 6 | 7 | namespace O2S.Components.PDF4NET.Samples 8 | { 9 | /// 10 | /// Redaction sample. 11 | /// 12 | public class Redaction 13 | { 14 | /// 15 | /// Main method for running the sample. 16 | /// 17 | public static SampleOutputInfo[] Run(Stream input) 18 | { 19 | PDFFixedDocument document = new PDFFixedDocument(input); 20 | PDFContentRedactor crText = new PDFContentRedactor(document.Pages[0]); 21 | // Redact a rectangular area of 200*100 points and leave the redacted area uncovered. 22 | crText.RedactArea(new PDFDisplayRectangle(50, 50, 200, 100)); 23 | // Redact a rectangular area of 200*100 points and mark the redacted area with red. 24 | crText.RedactArea(new PDFDisplayRectangle(50, 350, 200, 100), PDFRgbColor.Red); 25 | 26 | PDFContentRedactor crImages = new PDFContentRedactor(document.Pages[2]); 27 | // Initialize the bulk redaction. 28 | crImages.BeginRedaction(); 29 | // Prepare for redaction a rectangular area of 500*100 points and leave the redacted area uncovered. 30 | crImages.RedactArea(new PDFDisplayRectangle(50, 50, 500, 100)); 31 | // Prepare for redaction a rectangular area of 200*100 points and mark the redacted area with red. 32 | crImages.RedactArea(new PDFDisplayRectangle(50, 350, 500, 100), PDFRgbColor.Red); 33 | // When images are redacted, the cleared pixels are set to 0. Depending on image colorspace the redacted area can appear black or colored. 34 | // Finish the redaction 35 | crImages.ApplyRedaction(); 36 | 37 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "redaction.pdf") }; 38 | return output; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Reference/Redaction/Redaction.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/RemoveAndReplaceImages/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class RemoveAndReplaceImages 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream removeReplaceImagesInput = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.RemoveReplaceImages.Run(removeReplaceImagesInput); 18 | removeReplaceImagesInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/RemoveAndReplaceImages/RemoveAndReplaceImages.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Render/HighDpiPDF2Image/HighDpiPDF2Image.cs: -------------------------------------------------------------------------------- 1 | using O2S.Components.PDF4NET.Rendering; 2 | using O2S.Components.PDF4NET.Rendering.RenderingSurfaces; 3 | using System; 4 | using System.IO; 5 | 6 | namespace O2S.Components.PDF4NET.Samples.NetCore 7 | { 8 | class HighDpiPDF2Image 9 | { 10 | static void Main(string[] args) 11 | { 12 | string supportPath = "..\\..\\..\\..\\..\\..\\SupportFiles\\"; 13 | 14 | FileStream fs = File.OpenRead(supportPath + "PDF4NET.pdf"); 15 | PDFFixedDocument document = new PDFFixedDocument(fs); 16 | fs.Close(); 17 | 18 | PDFPageRenderer pageRenderer = new PDFPageRenderer(document.Pages[0]); 19 | 20 | PDFRendererSettings settings = new PDFRendererSettings(6400, 6400); 21 | settings.RenderingSurface = pageRenderer.CreateRenderingSurface>(settings.DpiX, settings.DpiY); 22 | 23 | // Output will be a 32bit 52889*74845 pixels RGBA TIFF 24 | FileStream pngStream = File.Create("PDF4NET.Page.0.tiff"); 25 | pageRenderer.ConvertPageToImage(pngStream, PDFPageImageFormat.Tiff, settings); 26 | pngStream.Flush(); 27 | pngStream.Close(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/Render/HighDpiPDF2Image/HighDpiPDF2Image.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/Render/HighDpiPDF2Image/README.md: -------------------------------------------------------------------------------- 1 | The `HighDpiPDF2Image` sample shows how to convert a PDF page to a very large TIFF image using a strip based rendering surface. 2 | At 6400dpi the output image is 52889x74845 pixels, 32bpp. Its size is 15GB. 3 | -------------------------------------------------------------------------------- /Reference/Render/Layers/Layers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Rendering; 5 | using O2S.Components.PDF4NET.Rendering.RenderingSurfaces; 6 | 7 | namespace O2S.Components.PDF4NET.Samples 8 | { 9 | class Layers 10 | { 11 | public static void Main(string[] args) 12 | { 13 | FileStream pdfStream = File.OpenRead("..\\..\\..\\..\\..\\..\\SupportFiles\\layers.PDF"); 14 | PDFFixedDocument document = new PDFFixedDocument(PDFStream); 15 | pdfStream.Dispose(); 16 | 17 | PDFPageRenderer pageRenderer = new PDFPageRenderer(document.Pages[0]); 18 | 19 | PDFRendererSettings settings = new PDFRendererSettings(96, 96); 20 | settings.RenderingSurface = pageRenderer.CreateRenderingSurface>(settings.DpiX, settings.DpiY); 21 | 22 | FileStream imageStream = File.Create("Layers.AllContent.tiff"); 23 | // By default all page content is rendered, layers visibility is ignored. 24 | pageRenderer.ConvertPageToImage(imageStream, PDFPageImageFormat.Tiff, settings); 25 | imageStream.Flush(); 26 | imageStream.Close(); 27 | 28 | // Render only the layers that are displayed when the document is viewed. 29 | settings.LayerRenderTarget = PDFLayerRenderTarget.View; 30 | imageStream = File.Create("Layers.View.tiff"); 31 | pageRenderer.ConvertPageToImage(imageStream, PDFPageImageFormat.Tiff, settings); 32 | imageStream.Flush(); 33 | imageStream.Close(); 34 | 35 | // Render only the layers that are displayed when the document is printed. 36 | settings.LayerRenderTarget = PDFLayerRenderTarget.Print; 37 | imageStream = File.Create("Layers.Print.tiff"); 38 | pageRenderer.ConvertPageToImage(imageStream, PDFPageImageFormat.Tiff, settings); 39 | imageStream.Flush(); 40 | imageStream.Close(); 41 | 42 | Console.WriteLine("Layers sample completed."); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Reference/Render/Layers/Layers.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/Render/Layers/README.md: -------------------------------------------------------------------------------- 1 | The `Layers` sample shows how to convert a PDF page to image and consider layer visiblity in the process. 2 | By default all page content is rendered. The `PDFRendererSettings.LayerRenderTarget` property lets specify what kind of layers should be considered when page is rendered. 3 | -------------------------------------------------------------------------------- /Reference/Render/MultiThreadedPDFToImage/MultiThreadedPDFToImage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Rendering; 5 | using O2S.Components.PDF4NET.Rendering.RenderingSurfaces; 6 | 7 | namespace O2S.Components.PDF4NET.Samples 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | PDFFixedDocument document = new PDFFixedDocument("..\\..\\..\\..\\..\\..\\SupportFiles\\cluj.pdf"); 14 | 15 | PDFRendererSettings settings = new PDFRendererSettings(); 16 | settings.DpiX = 300; 17 | settings.DpiY = 300; 18 | PDFPageRenderer renderer = new PDFPageRenderer(document.Pages[0]); 19 | settings.RenderingSurface = renderer.CreateRenderingSurface>(settings.DpiX, settings.DpiY); 20 | 21 | settings.RenderThreadCount = 0; 22 | RenderPage(renderer, settings); 23 | 24 | settings.RenderThreadCount = 2; 25 | RenderPage(renderer, settings); 26 | 27 | settings.RenderThreadCount = 4; 28 | RenderPage(renderer, settings); 29 | } 30 | 31 | private static void RenderPage(PDFPageRenderer renderer, PDFRendererSettings settings) 32 | { 33 | DateTime start, end; 34 | TimeSpan total = new TimeSpan(); 35 | int runCount = 3; 36 | 37 | for (int i = 0; i < runCount; i++) 38 | { 39 | start = DateTime.Now; 40 | 41 | renderer.ConvertPageToImage(settings); 42 | 43 | end = DateTime.Now; 44 | total = total + (end - start); 45 | 46 | settings.RenderingSurface.Save(string.Format($"ThreadCount.{settings.RenderThreadCount}.Pass.{i + 1}.tif"), PDFPageImageFormat.Tiff); 47 | } 48 | 49 | Console.WriteLine($"Thread count: {settings.RenderThreadCount} - Runs: {runCount} - Average duration: {total / runCount}"); 50 | 51 | Console.WriteLine(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Reference/Render/MultiThreadedPDFToImage/MultiThreadedPDFToImage.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/Render/MultiThreadedPDFToImage/README.md: -------------------------------------------------------------------------------- 1 | The `MultiThreadedPDFToImage` sample shows how to use multiple threads for PDF rendering. 2 | By default the rendering processed is single threaded but you can set the `PDFRendererSettings.RenderThreadCount` property to 2 or 4 to use 2 or 4 threads for PDF rendering. 3 | -------------------------------------------------------------------------------- /Reference/Render/PDF2BlackAndWhiteImage/PDF2BlackAndWhiteImage.cs: -------------------------------------------------------------------------------- 1 | using O2S.Components.PDF4NET.Rendering; 2 | using O2S.Components.PDF4NET.Rendering.RenderingSurfaces; 3 | using O2S.Components.PDF4NET.Rendering.Imaging; 4 | using System; 5 | using System.IO; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class PDF2BlackAndWhiteImage 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | FileStream fs = File.OpenRead(supportPath + "PDF4NET.pdf"); 16 | PDFFixedDocument document = new PDFFixedDocument(fs); 17 | fs.Close(); 18 | 19 | PDFPageRenderer pageRenderer = new PDFPageRenderer(document.Pages[0]); 20 | 21 | PDFRendererSettings settings = new PDFRendererSettings(144, 144); 22 | PDFBlackWhiteRenderingSurface bwSurface = pageRenderer.CreateRenderingSurface(settings.DpiX, settings.DpiY); 23 | // Use a simple threshold filter for conversion to B/W 24 | // Everything below 128 becomes black, everything above 128 becomes white 25 | bwSurface.BinarizationFilter = new PDFThresholdFilter(128); 26 | settings.RenderingSurface = bwSurface; 27 | 28 | // Output will be a 1bit B/W PNG 29 | FileStream pngStream = File.Create("PDF4NET.Page.0.Dithering-Off.png"); 30 | pageRenderer.ConvertPageToImage(pngStream, PDFPageImageFormat.Png, settings); 31 | pngStream.Flush(); 32 | pngStream.Close(); 33 | 34 | // Use a dithering filter for conversion to B/W 35 | bwSurface.BinarizationFilter = new PDFFloydSteinbergDitheringFilter(); 36 | 37 | // Output will be a 1bit B/W PNG 38 | pngStream = File.Create("PDF4NET.Page.0.Dithering-On.png"); 39 | pageRenderer.ConvertPageToImage(pngStream, PDFPageImageFormat.Png, settings); 40 | pngStream.Flush(); 41 | pngStream.Close(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Reference/Render/PDF2BlackAndWhiteImage/PDF2BlackAndWhiteImage.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/Render/PDF2BlackAndWhiteImage/README.md: -------------------------------------------------------------------------------- 1 | The `PDF2BlackAndWhiteImage` sample shows how to convert a PDF page to a Black and White image. 2 | -------------------------------------------------------------------------------- /Reference/Render/PDF2ColorImage/PDF2ColorImage.cs: -------------------------------------------------------------------------------- 1 | using O2S.Components.PDF4NET.Rendering; 2 | using O2S.Components.PDF4NET.Rendering.RenderingSurfaces; 3 | using System; 4 | using System.IO; 5 | 6 | namespace O2S.Components.PDF4NET.Samples.NetCore 7 | { 8 | class PDF2ColorImage 9 | { 10 | static void Main(string[] args) 11 | { 12 | string supportPath = "..\\..\\..\\..\\..\\..\\SupportFiles\\"; 13 | 14 | FileStream fs = File.OpenRead(supportPath + "PDF4NET.pdf"); 15 | PDFFixedDocument document = new PDFFixedDocument(fs); 16 | fs.Close(); 17 | 18 | PDFPageRenderer pageRenderer = new PDFPageRenderer(document.Pages[0]); 19 | 20 | PDFRendererSettings settings = new PDFRendererSettings(144, 144); 21 | // Set background to light gray 22 | // Transparency does not matter as the PDFRgbRenderingSurface does not support transparency 23 | settings.BackgroundColor = 0x00D0D0D0; 24 | settings.RenderingSurface = pageRenderer.CreateRenderingSurface(settings.DpiX, settings.DpiY); 25 | 26 | // Output will be a 24bit RGB PNG 27 | FileStream pngStream = File.Create("PDF4NET.Page.0.png"); 28 | pageRenderer.ConvertPageToImage(pngStream, PDFPageImageFormat.Png, settings); 29 | pngStream.Flush(); 30 | pngStream.Close(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Reference/Render/PDF2ColorImage/PDF2ColorImage.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/Render/PDF2ColorImage/README.md: -------------------------------------------------------------------------------- 1 | The `PDF2ColorImage` sample shows how to convert a PDF page to an opaque color image. An RGB (no alpha) rendering surface is used for conversion. 2 | -------------------------------------------------------------------------------- /Reference/Render/PDF2FixedImageSize/PDFToFixedImageSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | using O2S.Components.PDF4NET.Rendering; 6 | 7 | namespace O2S.Components.PDF4NET.Samples 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | FileStream pdfStream = File.OpenRead("..\\..\\..\\..\\..\\..\\SupportFiles\\PDF4NET.pdf"); 14 | PDFFixedDocument document = new PDFFixedDocument(pdfStream); 15 | pdfStream.Dispose(); 16 | 17 | PDFPageRenderer renderer = new PDFPageRenderer(document.Pages[0]); 18 | 19 | // Convert PDF page to fixed image size 1920x1080 20 | using (FileStream pngStream = File.OpenWrite("PDF4NET.Render-1920x1080.png")) 21 | { 22 | PDFRendererSettings settings = new PDFRendererSettings(96, 96); 23 | settings.OutputImageSize = new PDFSize(1920, 1080); 24 | renderer.ConvertPageToImage(pngStream, PDFPageImageFormat.Png, settings); 25 | pngStream.Flush(); 26 | } 27 | 28 | // Convert PDF page to image size 1920xProportionalHeight 29 | using (FileStream pngStream = File.OpenWrite("PDF4NET.Render-1920xProportionalHeight.png")) 30 | { 31 | PDFRendererSettings settings = new PDFRendererSettings(96, 96); 32 | settings.OutputImageSize = new PDFSize(1920, 0); 33 | renderer.ConvertPageToImage(pngStream, PDFPageImageFormat.Png, settings); 34 | pngStream.Flush(); 35 | } 36 | 37 | // Convert PDF page to image size ProportionalWidth x 1080 38 | using (FileStream pngStream = File.OpenWrite("PDF4NET.Render-ProportionalWidthx1080.png")) 39 | { 40 | PDFRendererSettings settings = new PDFRendererSettings(96, 96); 41 | settings.OutputImageSize = new PDFSize(0, 1080); 42 | renderer.ConvertPageToImage(pngStream, PDFPageImageFormat.Png, settings); 43 | pngStream.Flush(); 44 | } 45 | 46 | Console.WriteLine("PDFToFixedImageSize sample completed with success."); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Reference/Render/PDF2FixedImageSize/PDFToFixedImageSize.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/Render/PDF2FixedImageSize/README.md: -------------------------------------------------------------------------------- 1 | The `PDFToFixedImageSize` sample shows how to convert a PDF page to an image of fixed size. 2 | This is done by settings the `OutputImageSize` property on the `PDFRendererSettings` object. When this property is set, the `PDFRendererSettings.DpiX` and `PDFRendererSettings.DpiY` properties are ignored. 3 | If either `Width` or `Height` properties of the `OutputImageSize` are set to 0, they are computed automatically to keep the original page aspect ratio. 4 | 5 | -------------------------------------------------------------------------------- /Reference/Render/PDF2GrayImage/PDF2GrayImage.cs: -------------------------------------------------------------------------------- 1 | using O2S.Components.PDF4NET.Rendering; 2 | using O2S.Components.PDF4NET.Rendering.RenderingSurfaces; 3 | using System; 4 | using System.IO; 5 | 6 | namespace O2S.Components.PDF4NET.Samples.NetCore 7 | { 8 | class PDF2GrayImage 9 | { 10 | static void Main(string[] args) 11 | { 12 | string supportPath = "..\\..\\..\\..\\..\\..\\SupportFiles\\"; 13 | 14 | FileStream fs = File.OpenRead(supportPath + "PDF4NET.pdf"); 15 | PDFFixedDocument document = new PDFFixedDocument(fs); 16 | fs.Close(); 17 | 18 | PDFPageRenderer pageRenderer = new PDFPageRenderer(document.Pages[0]); 19 | 20 | PDFRendererSettings settings = new PDFRendererSettings(144, 144); 21 | settings.RenderingSurface = pageRenderer.CreateRenderingSurface(settings.DpiX, settings.DpiY); 22 | 23 | // Output will be a 8bit Gray PNG 24 | FileStream pngStream = File.Create("PDF4NET.Page.0.png"); 25 | pageRenderer.ConvertPageToImage(pngStream, PDFPageImageFormat.Png, settings); 26 | pngStream.Flush(); 27 | pngStream.Close(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/Render/PDF2GrayImage/PDF2GrayImage.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/Render/PDF2GrayImage/README.md: -------------------------------------------------------------------------------- 1 | The `PDF2GrayImage` sample shows how to convert a PDF page to a grayscale image. A Gray8 rendering surface is used for conversion. 2 | -------------------------------------------------------------------------------- /Reference/Render/PDF2MultipageBlackAndWhiteTiff/PDF2MultipageBlackAndWhiteTiff.cs: -------------------------------------------------------------------------------- 1 | using O2S.Components.PDF4NET.Rendering; 2 | using O2S.Components.PDF4NET.Rendering.RenderingSurfaces; 3 | using O2S.Components.PDF4NET.Rendering.Imaging; 4 | using System; 5 | using System.IO; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class PDF2MultipageBlackAndWhiteTiff 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | FileStream fs = File.OpenRead(supportPath + "PDF4NET.pdf"); 16 | PDFFixedDocument document = new PDFFixedDocument(fs); 17 | fs.Close(); 18 | 19 | PDFDocumentRenderer documentRenderer = new PDFDocumentRenderer(document); 20 | 21 | PDFRendererSettings settings = new PDFRendererSettings(144, 144); 22 | PDFBlackWhiteRenderingSurface bwSurface = new PDFBlackWhiteRenderingSurface(); 23 | bwSurface.BinarizationFilter = new PDFFloydSteinbergDitheringFilter(); 24 | settings.RenderingSurface = bwSurface; 25 | 26 | // Output will be a 1bit B/W CCIT G4 compressed multipage TIFF 27 | FileStream tiffStream = File.Create("PDF4NET.tif"); 28 | documentRenderer.ConvertToMultipageImage("0-3", settings, PDFPageImageFormat.Tiff, tiffStream); 29 | tiffStream.Flush(); 30 | tiffStream.Close(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Reference/Render/PDF2MultipageBlackAndWhiteTiff/PDF2MultipageBlackAndWhiteTiff.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/Render/PDF2MultipageBlackAndWhiteTiff/README.md: -------------------------------------------------------------------------------- 1 | The `PDF2MultipageBlackAndWhiteTiff` sample shows how to convert a PDF document to a multipage Black & White TIFF image with CCITT G4 compression. 2 | -------------------------------------------------------------------------------- /Reference/Render/PDF2MultipageColorTiff/PDF2MultipageColorTiff.cs: -------------------------------------------------------------------------------- 1 | using O2S.Components.PDF4NET.Rendering; 2 | using O2S.Components.PDF4NET.Rendering.RenderingSurfaces; 3 | using System; 4 | using System.IO; 5 | 6 | namespace O2S.Components.PDF4NET.Samples.NetCore 7 | { 8 | class PDF2MultipageColorTiff 9 | { 10 | static void Main(string[] args) 11 | { 12 | string supportPath = "..\\..\\..\\..\\..\\..\\SupportFiles\\"; 13 | 14 | FileStream fs = File.OpenRead(supportPath + "PDF4NET.pdf"); 15 | PDFFixedDocument document = new PDFFixedDocument(fs); 16 | fs.Close(); 17 | 18 | PDFDocumentRenderer documentRenderer = new PDFDocumentRenderer(document); 19 | 20 | PDFRendererSettings settings = new PDFRendererSettings(144, 144); 21 | settings.RenderingSurface = new PDFRgbRenderingSurface(1224, 1584); 22 | 23 | // Output will be a 24bit RGB multipage TIFF 24 | FileStream tiffStream = File.Create("PDF4NET.tif"); 25 | documentRenderer.ConvertToMultipageImage("0-3", settings, PDFPageImageFormat.TiffLzwCompressed, tiffStream); 26 | tiffStream.Flush(); 27 | tiffStream.Close(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/Render/PDF2MultipageColorTiff/PDF2MultipageColorTiff.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/Render/PDF2MultipageColorTiff/README.md: -------------------------------------------------------------------------------- 1 | The `PDF2MultipageColorTiff` sample shows how to convert a PDF document to a multipage color TIFF image with LZW compression. 2 | -------------------------------------------------------------------------------- /Reference/Render/PDF2MultipageGrayTiff/PDF2MultipageGrayTiff.cs: -------------------------------------------------------------------------------- 1 | using O2S.Components.PDF4NET.Rendering; 2 | using O2S.Components.PDF4NET.Rendering.RenderingSurfaces; 3 | using System; 4 | using System.IO; 5 | 6 | namespace O2S.Components.PDF4NET.Samples.NetCore 7 | { 8 | class PDF2MultipageGrayTiff 9 | { 10 | static void Main(string[] args) 11 | { 12 | string supportPath = "..\\..\\..\\..\\..\\..\\SupportFiles\\"; 13 | 14 | FileStream fs = File.OpenRead(supportPath + "PDF4NET.pdf"); 15 | PDFFixedDocument document = new PDFFixedDocument(fs); 16 | fs.Close(); 17 | 18 | PDFDocumentRenderer documentRenderer = new PDFDocumentRenderer(document); 19 | 20 | PDFRendererSettings settings = new PDFRendererSettings(144, 144); 21 | settings.RenderingSurface = new PDFGray8RenderingSurface(1224, 1584); 22 | 23 | // Output will be a 8bit gray multipage TIFF 24 | FileStream tiffStream = File.Create("PDF4NET.tif"); 25 | documentRenderer.ConvertToMultipageImage("0-3", settings, PDFPageImageFormat.TiffLzwCompressed, tiffStream); 26 | tiffStream.Flush(); 27 | tiffStream.Close(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/Render/PDF2MultipageGrayTiff/PDF2MultipageGrayTiff.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/Render/PDF2MultipageGrayTiff/README.md: -------------------------------------------------------------------------------- 1 | The `PDF2MultipageGrayTiff` sample shows how to convert a PDF document to a multipage gray TIFF image with LZW compression. 2 | -------------------------------------------------------------------------------- /Reference/Render/PDF2TransparentImage/PDF2TransparentImage.cs: -------------------------------------------------------------------------------- 1 | using O2S.Components.PDF4NET.Rendering; 2 | using O2S.Components.PDF4NET.Rendering.RenderingSurfaces; 3 | using System; 4 | using System.IO; 5 | 6 | namespace O2S.Components.PDF4NET.Samples.NetCore 7 | { 8 | class PDF2TransparentImage 9 | { 10 | static void Main(string[] args) 11 | { 12 | string supportPath = "..\\..\\..\\..\\..\\..\\SupportFiles\\"; 13 | 14 | FileStream fs = File.OpenRead(supportPath + "PDF4NET.pdf"); 15 | PDFFixedDocument document = new PDFFixedDocument(fs); 16 | fs.Close(); 17 | 18 | PDFPageRenderer pageRenderer = new PDFPageRenderer(document.Pages[0]); 19 | 20 | PDFRendererSettings settings = new PDFRendererSettings(144, 144); 21 | // Set background to transparent white (ARGB format) 22 | settings.BackgroundColor = 0x00FFFFFF; 23 | settings.RenderingSurface = pageRenderer.CreateRenderingSurface>(settings.DpiX, settings.DpiY); 24 | 25 | // Output will be a 32bit RGBA PNG 26 | FileStream pngStream = File.Create("PDF4NET.Page.0.png"); 27 | pageRenderer.ConvertPageToImage(pngStream, PDFPageImageFormat.Png, settings); 28 | pngStream.Flush(); 29 | pngStream.Close(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/Render/PDF2TransparentImage/PDF2TransparentImage.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/Render/PDF2TransparentImage/README.md: -------------------------------------------------------------------------------- 1 | The `PDF2TransparentImage` sample shows how to convert a PDF page to a transparent PNG image. A RGBA rendering surface is used for conversion. 2 | -------------------------------------------------------------------------------- /Reference/Render/SelectiveContentRendering/README.md: -------------------------------------------------------------------------------- 1 | The `SelectiveContentRendering` sample shows how to convert a PDF page to image and include only some of the content. The rendering settings allow to exclude the following elements: cevtor graphics, text, images, form fields and annotations. 2 | -------------------------------------------------------------------------------- /Reference/Render/SelectiveContentRendering/SelectiveContentRendering.cs: -------------------------------------------------------------------------------- 1 | using O2S.Components.PDF4NET.Rendering; 2 | using O2S.Components.PDF4NET.Rendering.RenderingSurfaces; 3 | using System; 4 | using System.IO; 5 | 6 | namespace O2S.Components.PDF4NET.Samples.NetCore 7 | { 8 | class SelectiveContentRendering 9 | { 10 | static void Main(string[] args) 11 | { 12 | string supportPath = "..\\..\\..\\..\\..\\..\\SupportFiles\\"; 13 | 14 | FileStream fs = File.OpenRead(supportPath + "PDF4NET.pdf"); 15 | PDFFixedDocument document = new PDFFixedDocument(fs); 16 | fs.Close(); 17 | 18 | PDFPageRenderer pageRenderer = new PDFPageRenderer(document.Pages[0]); 19 | 20 | PDFRendererSettings settings = new PDFRendererSettings(144, 144); 21 | // Render only text and vector graphics, do not render images 22 | settings.RenderAnnotations = true; 23 | settings.RenderFormFields = true; 24 | settings.RenderText = true; 25 | settings.RenderGraphics = true; 26 | settings.RenderImages = false; 27 | settings.RenderingSurface = pageRenderer.CreateRenderingSurface(settings.DpiX, settings.DpiY); 28 | 29 | // Output will be a 24bit RGB PNG 30 | FileStream pngStream = File.Create("PDF4NET.Page.0.png"); 31 | pageRenderer.ConvertPageToImage(pngStream, PDFPageImageFormat.Png, settings); 32 | pngStream.Flush(); 33 | pngStream.Close(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Reference/Render/SelectiveContentRendering/SelectiveContentRendering.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Reference/ResourceOptimization/README.md: -------------------------------------------------------------------------------- 1 | The `ResourceOptimization` sample shows how to merge fonts and images in a PDF in order to reduce the final file size. 2 | The `PDFResourceOptimizer` class searches for identical font and image objects in the PDF file and merges them into a single object. 3 | -------------------------------------------------------------------------------- /Reference/ResourceOptimization/ResourceOptimization.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/SVGFont/README.md: -------------------------------------------------------------------------------- 1 | The `SVGFont` sample shows how to draw text using a font that uses additional SVG graphics for glyph definitions. 2 | -------------------------------------------------------------------------------- /Reference/SVGFont/SVGFont.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/SVGToPDF/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class SVGToPDF 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream svgInput = new FileStream(supportPath + "tiger.svg", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.SvgToPDF.Run(svgInput); 18 | svgInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/SVGToPDF/SVGToPDF.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/SVGToPDF/SvgToPdf.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | using O2S.Components.PDF4NET.Canvas.Svg; 6 | 7 | namespace O2S.Components.PDF4NET.Samples 8 | { 9 | /// 10 | /// Svg to PDF conversion sample. 11 | /// 12 | public class SvgToPDF 13 | { 14 | /// 15 | /// Main method for running the sample. 16 | /// 17 | public static SampleOutputInfo[] Run(Stream input) 18 | { 19 | PDFFixedDocument document = new PDFFixedDocument(); 20 | PDFPage page = document.Pages.Add(); 21 | 22 | PDFSvgDrawing svg = new PDFSvgDrawing(input); 23 | page.Canvas.DrawFormXObject(svg, 20, 20, page.Width - 40, page.Width - 40); 24 | 25 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "svgtopdf.pdf") }; 26 | return output; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Reference/SaveSignedCopy/README.md: -------------------------------------------------------------------------------- 1 | The `SaveSignedCopy` sample shows how to save the copy of a PDF document that is covered by a digital signature. 2 | 3 | The input document has been signed (field Signature1) then a stamp has been added to first page and a second signature on the second page. 4 | The sample saves the copy covered by the first signature, so the stamp and 2nd signature are not included. 5 | -------------------------------------------------------------------------------- /Reference/SaveSignedCopy/SaveSignedCopy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.DigitalSignatures; 6 | using O2S.Components.PDF4NET.Forms; 7 | using O2S.Components.PDF4NET.Samples; 8 | using O2S.Components.PDF4NET.Utilities; 9 | 10 | namespace O2S.Components.PDF4NET.Samples.NetCore 11 | { 12 | class SaveSignedCopy 13 | { 14 | static void Main(string[] args) 15 | { 16 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 17 | 18 | FileStream signedFile = File.OpenRead(supportPath + "PDF4NET.pdf"); 19 | PDFFixedDocument document = new PDFFixedDocument(signedFile); 20 | PDFSignatureField signature1Field = document.Form.Fields["Signature1"] as PDFSignatureField; 21 | 22 | PDFComputedDigitalSignature signature1 = signature1Field.Signature as PDFComputedDigitalSignature; 23 | 24 | FileStream signedCopy = File.Create("PDF4NET.Signature1.Copy.pdf"); 25 | signature1.SaveSignedCopy(signedFile, signedCopy); 26 | signedCopy.Flush(); 27 | signedCopy.Close(); 28 | 29 | Console.WriteLine("SignedCopy copy saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/SaveSignedCopy/SaveSignedCopy.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/SearchText/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class SearchText 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream searchTextInput = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.SearchText.Run(searchTextInput); 18 | searchTextInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/SearchText/SearchText.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/ShowSignatureCertificate/README.md: -------------------------------------------------------------------------------- 1 | The `ShowSignatureCertificate` sample shows how to get the certificate from a digital signature and display its information. 2 | -------------------------------------------------------------------------------- /Reference/ShowSignatureCertificate/ShowSignatureCertificate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using System.Security.Cryptography.X509Certificates; 5 | using O2S.Components.PDF4NET; 6 | using O2S.Components.PDF4NET.DigitalSignatures; 7 | using O2S.Components.PDF4NET.Forms; 8 | using O2S.Components.PDF4NET.Samples; 9 | using O2S.Components.PDF4NET.Utilities; 10 | 11 | namespace O2S.Components.PDF4NET.Samples.NetCore 12 | { 13 | class ShowSignatureCertificate 14 | { 15 | static void Main(string[] args) 16 | { 17 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 18 | 19 | FileStream signedFile = File.OpenRead(supportPath + "PDF4NET.pdf"); 20 | PDFFixedDocument document = new PDFFixedDocument(signedFile); 21 | PDFSignatureField signature1Field = document.Form.Fields["Signature1"] as PDFSignatureField; 22 | 23 | PDFComputedDigitalSignature signature1 = signature1Field.Signature as PDFComputedDigitalSignature; 24 | X509Certificate2 x509 = signature1.Certificate; 25 | 26 | //Print to console information contained in the certificate. 27 | Console.WriteLine("{0}Subject: {1}{0}", Environment.NewLine, x509.Subject); 28 | Console.WriteLine("{0}Issuer: {1}{0}", Environment.NewLine, x509.Issuer); 29 | Console.WriteLine("{0}Version: {1}{0}", Environment.NewLine, x509.Version); 30 | Console.WriteLine("{0}Valid Date: {1}{0}", Environment.NewLine, x509.NotBefore); 31 | Console.WriteLine("{0}Expiry Date: {1}{0}", Environment.NewLine, x509.NotAfter); 32 | Console.WriteLine("{0}Thumbprint: {1}{0}", Environment.NewLine, x509.Thumbprint); 33 | Console.WriteLine("{0}Serial Number: {1}{0}", Environment.NewLine, x509.SerialNumber); 34 | Console.WriteLine("{0}Friendly Name: {1}{0}", Environment.NewLine, x509.PublicKey.Oid.FriendlyName); 35 | Console.WriteLine("{0}Public Key Format: {1}{0}", Environment.NewLine, x509.PublicKey.EncodedKeyValue.Format(true)); 36 | Console.WriteLine("{0}Raw Data Length: {1}{0}", Environment.NewLine, x509.RawData.Length); 37 | Console.WriteLine("{0}Certificate to string: {1}{0}", Environment.NewLine, x509.ToString(true)); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Reference/ShowSignatureCertificate/ShowSignatureCertificate.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/SignatureDecode/README.md: -------------------------------------------------------------------------------- 1 | The `SignatureDecode` sample shows how to decompose a digital signature into basic building ASN.1 blocks. 2 | -------------------------------------------------------------------------------- /Reference/SignatureDecode/SignatureDecode.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/SignatureWithTimeStamp/SignatureWithTimeStamp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using O2S.Components.PDF4NET; 3 | using System.Security.Cryptography.X509Certificates; 4 | using System.IO; 5 | using O2S.Components.PDF4NET.Forms; 6 | using O2S.Components.PDF4NET.DigitalSignatures; 7 | 8 | namespace O2S.Components.PDF4NET.Samples 9 | { 10 | /// 11 | /// SignatureWithTimeStamp sample. 12 | /// 13 | public class SignatureWithTimeStamp 14 | { 15 | /// 16 | /// Main method for running the sample. 17 | /// 18 | public static SampleOutputInfo[] Run(Stream formStream, X509Certificate2 certificate, SignatureTimestampNeeded onTimeStamp) 19 | { 20 | PDFFixedDocument document = new PDFFixedDocument(formStream); 21 | 22 | PDFSignatureField signField = document.Form.Fields["signhere"] as PDFSignatureField; 23 | PDFCmsDigitalSignature signature = new PDFCmsDigitalSignature(); 24 | signature.SignatureDigestAlgorithm = PDFDigitalSignatureDigestAlgorithm.Sha256; 25 | signature.Certificate = certificate; 26 | signature.ContactInfo = "techsupport@o2sol.com"; 27 | signature.Location = "Cluj Napoca"; 28 | signature.Name = "O2 Solutions Support"; 29 | signature.Reason = "Signature with timestamp"; 30 | signature.OnSignatureTimestampNeeded += onTimeStamp; 31 | signField.Signature = signature; 32 | 33 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "signaturewithtimestamp.pdf") }; 34 | return output; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Reference/SignatureWithTimeStamp/SignatureWithTimeStamp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/SimpleMerge/README.md: -------------------------------------------------------------------------------- 1 | The `SimpleMerge` sample shows how to merge 2 PDF files with a single line of code. 2 | -------------------------------------------------------------------------------- /Reference/SimpleMerge/SimpleMerge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | using O2S.Components.PDF4NET.Utilities; 7 | 8 | namespace O2S.Components.PDF4NET.Samples.NetCore 9 | { 10 | class SimpleMerge 11 | { 12 | static void Main(string[] args) 13 | { 14 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 15 | 16 | PDFMerger.MergeFiles("simplemerge.pdf", 17 | supportPath + "content.pdf", supportPath + "formfill.pdf"); 18 | 19 | Console.WriteLine("Merged file saved with success to current folder."); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Reference/SimpleMerge/SimpleMerge.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/SimpleSignature/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using System.Security.Cryptography.X509Certificates; 5 | 6 | namespace O2S.Components.PDF4NET.Samples.NetCore 7 | { 8 | class SimpleSignature 9 | { 10 | static void Main(string[] args) 11 | { 12 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 13 | 14 | X509Certificate2 certificate = new X509Certificate2(supportPath + "O2SolutionsDemoCertificate.pfx", "P@ssw0rd!", X509KeyStorageFlags.Exportable); 15 | FileStream formStream = File.OpenRead(supportPath + "formfill.pdf"); 16 | 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.SimpleSignature.Run(formStream, certificate); 18 | 19 | formStream.Close(); 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = new FileStream(output[i].FileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/SimpleSignature/SimpleSignature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using O2S.Components.PDF4NET; 3 | using System.Security.Cryptography.X509Certificates; 4 | using System.IO; 5 | using O2S.Components.PDF4NET.Forms; 6 | using O2S.Components.PDF4NET.DigitalSignatures; 7 | 8 | namespace O2S.Components.PDF4NET.Samples 9 | { 10 | /// 11 | /// SimpleSignature sample. 12 | /// 13 | public class SimpleSignature 14 | { 15 | /// 16 | /// Main method for running the sample. 17 | /// 18 | public static SampleOutputInfo[] Run(Stream formStream, X509Certificate2 certificate) 19 | { 20 | PDFFixedDocument document = new PDFFixedDocument(formStream); 21 | 22 | PDFSignatureField signField = document.Form.Fields["signhere"] as PDFSignatureField; 23 | PDFCmsDigitalSignature signature = new PDFCmsDigitalSignature(); 24 | signature.SignatureDigestAlgorithm = PDFDigitalSignatureDigestAlgorithm.Sha256; 25 | signature.Certificate = certificate; 26 | signature.ContactInfo = "techsupport@o2sol.com"; 27 | signature.Location = "Cluj Napoca"; 28 | signature.Name = "O2 Solutions Support"; 29 | signature.Reason = "Simple signature"; 30 | signField.Signature = signature; 31 | 32 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "simplesignature.pdf") }; 33 | return output; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Reference/SimpleSignature/SimpleSignature.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/SimpleTable/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class SimpleTable 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream peopleStream = new FileStream(supportPath + "people1.dat", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | FileStream simpleTableVerdanaStream = new FileStream(supportPath + "verdana.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 18 | FileStream simpleTableVerdanaBoldStream = new FileStream(supportPath + "verdanab.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 19 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.SimpleTable.Run(simpleTableVerdanaStream, simpleTableVerdanaBoldStream, peopleStream); 20 | peopleStream.Dispose(); 21 | simpleTableVerdanaStream.Dispose(); 22 | simpleTableVerdanaBoldStream.Dispose(); 23 | 24 | 25 | for (int i = 0; i < output.Length; i++) 26 | { 27 | FileStream outStream = File.OpenWrite(output[i].FileName); 28 | output[i].Document.Save(outStream, output[i].SecurityHandler); 29 | outStream.Flush(); 30 | outStream.Dispose(); 31 | } 32 | 33 | Console.WriteLine("File(s) saved with success to current folder."); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Reference/SimpleTable/SimpleTable.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/SuperscriptSubscript/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.Pcl 8 | { 9 | class SuperscriptSubscript 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | FileStream verdanaStream = new FileStream(supportPath + "verdana.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.SuperscriptSubscript.Run(verdanaStream); 17 | verdanaStream.Dispose(); 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/SuperscriptSubscript/SuperscriptSubscript.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/TableCellSpans/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class TableCellSpans 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream verdanaStream = new FileStream(supportPath + "verdana.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.TableCellSpans.Run(verdanaStream); 18 | verdanaStream.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/TableCellSpans/TableCellSpans.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/TableGroups/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class TableGroups 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream populationStream = new FileStream(supportPath + "population.dat", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | FileStream verdanaStream = new FileStream(supportPath + "verdana.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 18 | FileStream verdanaBoldStream = new FileStream(supportPath + "verdanab.ttf", FileMode.Open, FileAccess.Read, FileShare.Read); 19 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.TableGroups.Run(verdanaStream, verdanaBoldStream, populationStream); 20 | populationStream.Dispose(); 21 | verdanaStream.Dispose(); 22 | verdanaBoldStream.Dispose(); 23 | 24 | 25 | for (int i = 0; i < output.Length; i++) 26 | { 27 | FileStream outStream = File.OpenWrite(output[i].FileName); 28 | output[i].Document.Save(outStream, output[i].SecurityHandler); 29 | outStream.Flush(); 30 | outStream.Dispose(); 31 | } 32 | 33 | Console.WriteLine("File(s) saved with success to current folder."); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Reference/TableGroups/TableGroups.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/TableOfContents/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class TableOfContents 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.TableOfContents.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/TableOfContents/TableOfContents.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Text/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Text 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Text.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/Text/Text.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/TiffToPdf/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class TiffToPDF 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream tiffStream = new FileStream(supportPath + "sample.tif", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.TiffToPDF.Run(tiffStream); 18 | tiffStream.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/TiffToPdf/TiffToPdf.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using O2S.Components.PDF4NET; 4 | using O2S.Components.PDF4NET.Graphics; 5 | 6 | namespace O2S.Components.PDF4NET.Samples 7 | { 8 | /// 9 | /// Tiff to PDF conversion sample. 10 | /// 11 | public class TiffToPDF 12 | { 13 | /// 14 | /// Main method for running the sample. 15 | /// 16 | public static SampleOutputInfo[] Run(Stream input) 17 | { 18 | PDFFixedDocument document = new PDFFixedDocument(); 19 | PDFTiffImage tiff = new PDFTiffImage(input); 20 | 21 | for (int i = 0; i < tiff.FrameCount; i++) 22 | { 23 | tiff.ActiveFrame = i; 24 | PDFPage page = document.Pages.Add(); 25 | page.Canvas.DrawImage(tiff, 0, 0, page.Width, page.Height); 26 | } 27 | 28 | SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "tifftopdf.pdf") }; 29 | return output; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Reference/TiffToPdf/TiffToPdf.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Type3Fonts/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Type3Fonts 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Type3Fonts.Run(); 17 | 18 | 19 | for (int i = 0; i < output.Length; i++) 20 | { 21 | FileStream outStream = File.OpenWrite(output[i].FileName); 22 | output[i].Document.Save(outStream, output[i].SecurityHandler); 23 | outStream.Flush(); 24 | outStream.Dispose(); 25 | } 26 | 27 | Console.WriteLine("File(s) saved with success to current folder."); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Reference/Type3Fonts/Type3Fonts.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/VectorGraphics/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class VectorGraphics 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream iccStream = new FileStream(supportPath + "rgb.icc", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.VectorGraphics.Run(iccStream); 18 | iccStream.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/VectorGraphics/VectorGraphics.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/Watermarks/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using O2S.Components.PDF4NET; 5 | using O2S.Components.PDF4NET.Samples; 6 | 7 | namespace O2S.Components.PDF4NET.Samples.NetCore 8 | { 9 | class Watermarks 10 | { 11 | static void Main(string[] args) 12 | { 13 | string supportPath = "..\\..\\..\\..\\..\\SupportFiles\\"; 14 | 15 | 16 | FileStream watermarksInput = new FileStream(supportPath + "content.pdf", FileMode.Open, FileAccess.Read, FileShare.Read); 17 | SampleOutputInfo[] output = O2S.Components.PDF4NET.Samples.Watermarks.Run(watermarksInput); 18 | watermarksInput.Dispose(); 19 | 20 | 21 | for (int i = 0; i < output.Length; i++) 22 | { 23 | FileStream outStream = File.OpenWrite(output[i].FileName); 24 | output[i].Document.Save(outStream, output[i].SecurityHandler); 25 | outStream.Flush(); 26 | outStream.Dispose(); 27 | } 28 | 29 | Console.WriteLine("File(s) saved with success to current folder."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Reference/Watermarks/Watermarks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reference/WatermarksLowOverhead/README.md: -------------------------------------------------------------------------------- 1 | The `WatermarksLowOverhead` sample shows how to add content to existing PDF pages using the new API available in PDFFileEx class. 2 | -------------------------------------------------------------------------------- /Reference/WatermarksLowOverhead/WatermarksLowOverhead.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /SupportFiles/Cluj.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/Cluj.pdf -------------------------------------------------------------------------------- /SupportFiles/DigitaltsOrange.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/DigitaltsOrange.ttf -------------------------------------------------------------------------------- /SupportFiles/Invoice.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/Invoice.pdf -------------------------------------------------------------------------------- /SupportFiles/NotoNaskhArabic-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoNaskhArabic-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoNastaliqUrdu-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoNastaliqUrdu-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSansBengali-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSansBengali-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSansCJKjp-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSansCJKjp-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSansDevanagari-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSansDevanagari-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSansGujarati-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSansGujarati-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSansGurmukhi-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSansGurmukhi-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSansKannada-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSansKannada-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSansKhmer-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSansKhmer-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSansMyanmarLatin-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSansMyanmarLatin-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSansOriya-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSansOriya-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSansTamil-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSansTamil-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSansTelugu-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSansTelugu-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSerifLao-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSerifLao-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSerifMalayalam-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSerifMalayalam-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/NotoSerifThai-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/NotoSerifThai-Regular.ttf -------------------------------------------------------------------------------- /SupportFiles/O2SolutionsDemoCertificate.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/O2SolutionsDemoCertificate.pfx -------------------------------------------------------------------------------- /SupportFiles/PDF4NET.Features.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/PDF4NET.Features.pdf -------------------------------------------------------------------------------- /SupportFiles/PDF4NET.Overview.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/PDF4NET.Overview.pdf -------------------------------------------------------------------------------- /SupportFiles/PDF4NET.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/PDF4NET.pdf -------------------------------------------------------------------------------- /SupportFiles/SegoeUIEmoji.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/SegoeUIEmoji.ttf -------------------------------------------------------------------------------- /SupportFiles/airplane.u3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/airplane.u3d -------------------------------------------------------------------------------- /SupportFiles/arial.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/arial.ttf -------------------------------------------------------------------------------- /SupportFiles/auto1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/auto1.jpg -------------------------------------------------------------------------------- /SupportFiles/box.u3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/box.u3d -------------------------------------------------------------------------------- /SupportFiles/calibri.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/calibri.ttf -------------------------------------------------------------------------------- /SupportFiles/clock.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/clock.swf -------------------------------------------------------------------------------- /SupportFiles/cmyk.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/cmyk.tif -------------------------------------------------------------------------------- /SupportFiles/content.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/content.pdf -------------------------------------------------------------------------------- /SupportFiles/contentseparation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/contentseparation.pdf -------------------------------------------------------------------------------- /SupportFiles/encrypted.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/encrypted.pdf -------------------------------------------------------------------------------- /SupportFiles/formfill.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/formfill.pdf -------------------------------------------------------------------------------- /SupportFiles/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/image.jpg -------------------------------------------------------------------------------- /SupportFiles/layers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/layers.pdf -------------------------------------------------------------------------------- /SupportFiles/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/logo.png -------------------------------------------------------------------------------- /SupportFiles/rgb.icc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/rgb.icc -------------------------------------------------------------------------------- /SupportFiles/sample.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/sample.pdf -------------------------------------------------------------------------------- /SupportFiles/sample.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/sample.tif -------------------------------------------------------------------------------- /SupportFiles/signature.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/signature.png -------------------------------------------------------------------------------- /SupportFiles/softmask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/softmask.png -------------------------------------------------------------------------------- /SupportFiles/stencilmask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/stencilmask.png -------------------------------------------------------------------------------- /SupportFiles/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/verdana.ttf -------------------------------------------------------------------------------- /SupportFiles/verdanab.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2solutions/pdf4net/c9f921168ddb44b657200cb4806a470ef455d3e6/SupportFiles/verdanab.ttf -------------------------------------------------------------------------------- /Upgrade/3D/3D.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/Actions/Actions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/Annotations/Annotations.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/ArcsPies/ArcsPies.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/Attachments/Attachments.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/Barcodes/Barcodes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/Bezier/Bezier.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/Bookmarks/Bookmarks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/CharacterMap/CharacterMap.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/ColorSpaces/ColorSpaces.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/DigitalSignature/DigitalSignature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Drawing; 4 | using System.Security.Cryptography.X509Certificates; 5 | using O2S.Components.PDF4NET; 6 | using O2S.Components.PDF4NET.Forms; 7 | using O2S.Components.PDF4NET.DigitalSignatures; 8 | using O2S.Components.PDF4NET.Graphics; 9 | //using O2S.Components.PDF4NET.Security; 10 | 11 | namespace O2S.Samples.PDF4NET 12 | { 13 | /// 14 | /// This sample shows how to sign a PDF file using X.509 certificates. 15 | /// 16 | class DigitalSignature 17 | { 18 | /// 19 | /// The main entry point for the application. 20 | /// 21 | [STAThread] 22 | static void Main(string[] args) 23 | { 24 | // Create the pdf document 25 | //PDF4NET v5: PDFDocument doc = new PDFDocument(); 26 | PDFFixedDocument doc = new PDFFixedDocument(); 27 | 28 | // Create a blank page 29 | //PDF4NET v5: PDFPage page = doc.AddPage(); 30 | PDFPage page = doc.Pages.Add(); 31 | 32 | // Create the signature field. 33 | PDFSignatureField sign = new PDFSignatureField("Signature"); 34 | //PDF4NET v5: sign.Widgets[0].DisplayRectangle = new DisplayRectangle(50, 100, 200, 40); 35 | sign.Widgets[0].DisplayRectangle = new PDFDisplayRectangle(50, 100, 200, 40); 36 | // Create the digital signature. 37 | //PDF4NET v5: sign.Signature = new PDFDigitalSignature(); 38 | PDFCmsDigitalSignature ds = new PDFCmsDigitalSignature(); 39 | // The certificate is loaded from disk, but it also can be loaded from a certificate store. 40 | ds.Certificate = new X509Certificate2("..\\..\\..\\..\\..\\SupportFiles\\O2SolutionsDemoCertificate.pfx", "P@ssw0rd!", X509KeyStorageFlags.Exportable); 41 | ds.Location = "Romania"; 42 | ds.Reason = "For demo"; 43 | ds.ContactInfo = "techsupport@o2sol.com"; 44 | sign.Signature = ds; 45 | page.Fields.Add(sign); 46 | 47 | doc.Save("Sample_DigitalSign.pdf"); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Upgrade/DigitalSignature/DigitalSignature.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/DocAndViewer/DocAndViewer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/EditPDF/EditPDF.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/Ellipses/Ellipses.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/Encryption/Encryption.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/ExtractImages/ExtractImages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | using System.Drawing; 5 | using System.Drawing.Imaging; 6 | using O2S.Components.PDF4NET; 7 | using O2S.Components.PDF4NET.Content; 8 | //using O2S.Components.PDF4NET.PDFFile; 9 | 10 | namespace O2S.Samples.PDF4NET 11 | { 12 | class ExtractImages 13 | { 14 | static void Main(string[] args) 15 | { 16 | // Load the PDF file. 17 | //PDF4NET v5: PDFDocument doc = new PDFDocument("..\\SupportFiles\\Images.pdf"); 18 | PDFFixedDocument doc = new PDFFixedDocument("..\\..\\..\\..\\..\\SupportFiles\\content.pdf"); 19 | 20 | //for (int i = 0; i < doc.Pages.Count; i++) 21 | //{ 22 | // Convert the pages to PDFImportedPage to get access to ExtractImages method. 23 | //PDF4NET v5: PDFImportedPage ip = doc.Pages[i] as PDFImportedPage; 24 | PDFContentExtractor ce = new PDFContentExtractor(doc.Pages[2]); 25 | //PDF4NET v5: Bitmap[] images = ip.ExtractImages(); 26 | PDFVisualImageCollection images = ce.ExtractImages(true); 27 | // Save the page images to disk, if there are any. 28 | for (int j = 0; j < images.Count; j++) 29 | { 30 | //PDF4NET v5: images[j].Save("image" + i.ToString() + j.ToString() + ".png", ImageFormat.Png); 31 | FileStream fs = File.OpenWrite("image" + j.ToString() + ".png"); 32 | images[j].Save(fs, PDFVisualImageSaveFormat.Png); 33 | fs.Flush(); 34 | fs.Close(); 35 | } 36 | //} 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Upgrade/ExtractImages/ExtractImages.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Upgrade/readme.md: -------------------------------------------------------------------------------- 1 | The Upgrade folder contains the old [**PDF4NET**](https://o2sol.com/pdf4net/overview.htm) samples that have been upgraded to [**PDF4NET**](https://o2sol.com/pdf4net/overview.htm) 10. 2 | 3 | The lines of code that need to be updated are commented with //PDF4NET v5: 4 | 5 | Below them are written the lines of code that replaces them. 6 | 7 | For example: 8 | 9 | //PDF4NET v5: PDFDocument doc = new PDFDocument(); 10 | PDFFixedDocument doc = new PDFFixedDocument(); --------------------------------------------------------------------------------