### Ruby PDFNet Setup Source: https://docs.apryse.com/core/samples/annotationtest Includes necessary modules and sets up output/input paths for Ruby PDFNet examples. ```Ruby #--------------------------------------------------------------------------------------- # Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved. # Consult LICENSE.txt regarding license information. #--------------------------------------------------------------------------------------- require '../../../PDFNetC/Lib/PDFNetRuby' include PDFNetRuby require '../../LicenseKey/RUBY/LicenseKey' $stdout.sync = true $output_path = "../../TestFiles/Output/" $input_path = "../../TestFiles/" def FloatToStr(float) if float.to_i() == float.to_f() return float.to_i().to_s() else return float.to_f().to_s() end end ``` -------------------------------- ### Install PDFTron.iOS Packages Source: https://docs.apryse.com/xamarin/guides/get-started/integrate-ios Select and install the 'PDFTron.iOS' and 'PDFTron.iOS.Tools' packages from the newly added NuGet source. ```csharp PDFTron.iOS ``` ```csharp PDFTron.iOS.Tools ``` -------------------------------- ### Create and Customize Sound Annotations Source: https://docs.apryse.com/xamarin/samples/annotationtest This example shows how to create two Sound annotations with different icons (Speaker and Microphone) and add them to a page. ```csharp Sound snd = Sound.Create( doc, new Rect( 100, 500, 120, 520 ) ); snd.SetColor( new ColorPt(1,1,0) ); snd.SetIcon(Sound.Icon.e_Speaker ); snd.RefreshAppearance(); page7.AnnotPushBack( snd ); ``` ```csharp Sound snd = Sound.Create( doc, new Rect( 200, 500, 220, 520 ) ); snd.SetColor(new ColorPt(1,1,0) ); snd.SetIcon(Sound.Icon.e_Mic ); snd.RefreshAppearance(); page7.AnnotPushBack( snd ); ``` -------------------------------- ### Setup iOS User Interface Source: https://docs.apryse.com/xamarin/guides/forms/basics/open/document This C# method sets up the user interface for the iOS document viewer, including creating a PTTabbedDocumentViewController and opening a document. ```csharp void SetupUserInterface() { mTabViewController = new PTTabbedDocumentViewController(); UINavigationController navigationController = new UINavigationController(mTabViewController); AddChildViewController(navigationController); View.AddSubview(navigationController.View); navigationController.DidMoveToParentViewController(this); NSUrl fileURL = NSBundle.MainBundle.GetUrlForResource("sample", "pdf"); mTabViewController.OpenDocumentWithURL(fileURL); } ``` -------------------------------- ### Setup Android User Interface Source: https://docs.apryse.com/xamarin/guides/forms/basics/open/document This C# method sets up the user interface for the Android document viewer, including inflating a layout and opening a document with the DocumentView. ```csharp void SetupUserInterface() { activity = this.Context as Activity; view = activity.LayoutInflater.Inflate(Resource.Layout.AdvancedViewerLayout, this, false); mDocumentView = view.FindViewById(Resource.Id.document_view); var context = this.Context; FragmentManager childManager = null; if (context is AppCompatActivity) { var activity = context as AppCompatActivity; var manager = activity.SupportFragmentManager; var fragments = manager.Fragments; if (fragments.Count > 0) { childManager = fragments[0].ChildFragmentManager; } if (childManager != null) { mDocumentView.OpenDocument(GetFile(), "", GetConfig(), childManager); } } } ``` -------------------------------- ### Create Basic Line Annotation Source: https://docs.apryse.com/xamarin/samples/annotationtest Creates a basic line annotation with specified start and end points, and start/end styles. This is a foundational example for creating line annotations. ```csharp { Line line=Line.Create(doc, new Rect(10, 400, 200, 600)); line.SetStartPoint(new Point(25, 426 ) ); line.SetEndPoint(new Point(180,555) ); line.SetStartStyle(Line.EndingStyle.e_Circle); line.SetEndStyle(Line.EndingStyle.e_Square); ``` -------------------------------- ### Install Apryse Packages Manually Source: https://docs.apryse.com/xamarin/guides/get-started/integrate-android Install the Apryse packages manually using the NuGet Package Manager Console. Ensure you replace 'path_to_package' with the actual directory containing the .nupkg files. ```powershell Install-Package path_to_package\PDFTron.Android.11.0.0.nupkg ``` ```powershell Install-Package path_to_package\PDFTron.Android.Tools.11.0.0.nupkg ``` -------------------------------- ### Open a Document in DocumentActivity Source: https://docs.apryse.com/xamarin/guides/get-started/view-android Launch the DocumentActivity to display a PDF document from a URL. This example uses a ViewerConfig to set the cache path and builds an Intent to start the activity. ```csharp var config = new pdftron.PDF.Config.ViewerConfig.Builder().OpenUrlCachePath (this.CacheDir.AbsolutePath).Build(); var intent = DocumentActivity.IntentBuilder.FromActivityClass(this, Java.Lang.Class.FromType(typeof(DocumentActivity))) .WithUri(Android.Net.Uri.Parse("https://pdftron.s3.amazonaws.com/downloads/pdfref.pdf")) .UsingConfig(config) .Build(); StartActivity(intent); ``` -------------------------------- ### Redact Document with JavaScript Source: https://docs.apryse.com/web/samples/pdfredacttest Use this JavaScript code to redact sensitive content from a PDF document. Ensure the Redaction package is included and follow the get started guide for WebViewer setup. ```javascript //--------------------------------------------------------------------------------------- // Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved. // Consult legal.txt regarding legal and license information. //--------------------------------------------------------------------------------------- (exports => { exports.runPDFRedactTest = () => { const PDFNet = exports.Core.PDFNet; const main = async () => { // Relative path to the folder containing test files. const inputPath = '../TestFiles/'; try { const doc = await PDFNet.PDFDoc.createFromURL(inputPath + 'newsletter.pdf'); doc.initSecurityHandler(); doc.lock(); const redactionArray = []; // we will contain a list of redaction objects in this array redactionArray.push(await PDFNet.Redactor.redactionCreate(1, await PDFNet.Rect.init(100, 100, 550, 600), false, 'Top Secret')); redactionArray.push(await PDFNet.Redactor.redactionCreate(2, await PDFNet.Rect.init(30, 30, 450, 450), true, 'Negative Redaction')); redactionArray.push(await PDFNet.Redactor.redactionCreate(2, await PDFNet.Rect.init(0, 0, 100, 100), false, 'Positive')); redactionArray.push(await PDFNet.Redactor.redactionCreate(2, await PDFNet.Rect.init(100, 100, 200, 200), false, 'Positive')); redactionArray.push(await PDFNet.Redactor.redactionCreate(2, await PDFNet.Rect.init(300, 300, 400, 400), false, '')); redactionArray.push(await PDFNet.Redactor.redactionCreate(2, await PDFNet.Rect.init(500, 500, 600, 600), false, '')); redactionArray.push(await PDFNet.Redactor.redactionCreate(3, await PDFNet.Rect.init(0, 0, 700, 20), false, '')); const blue = await PDFNet.ColorPt.init(0.1, 0.2, 0.6, 0); const timesFont = await PDFNet.Font.create(doc, PDFNet.Font.StandardType1Font.e_times_roman); const appear = { redaction_overlay: true, positive_overlay_color: blue, border: false, font: timesFont, show_redacted_content_regions: true }; PDFNet.Redactor.redact(doc, redactionArray, appear, false, false); const docbuf = await doc.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_linearized); saveBufferAsPDFDoc(docbuf, 'redacted.pdf'); console.log('Done...'); } catch (err) { console.log(err.stack); } }; // add your own license key as the second parameter, e.g. PDFNet.runWithCleanup(main, 'YOUR_LICENSE_KEY') PDFNet.runWithCleanup(main); }; })(window); // eslint-disable-next-line spaced-comment //# sourceURL=PDFRedactTest.js ``` -------------------------------- ### Initialize PDFNet and Open Document Source: https://docs.apryse.com/core/samples/elementreaderadvtest/go Sets up the PDFNet SDK and opens a PDF document for processing. This is the entry point for the application. Requires `PDFNet.Initialize` and a valid license key. ```go static void Main(string[] args) { try { PDFNet.Initialize(PDFTronLicense.Key); Console.WriteLine("-------------------------------------------------"); Console.WriteLine("Extract page element information from all "); Console.WriteLine("pages in the document."); // Open the test file } ``` -------------------------------- ### Initialize PDFNet and Configure Resources Source: https://docs.apryse.com/xamarin/samples/pdfdrawtest This snippet shows how to initialize the Apryse SDK and optionally set resource paths, color management profiles, and font substitutions. This is typically done once at the start of your application. ```csharp using System; using System.Drawing; using System.Runtime.InteropServices; using pdftron; using pdftron.Common; using pdftron.PDF; using pdftron.SDF; using NUnit.Framework; namespace MiscellaneousSamples { /// //--------------------------------------------------------------------------------------- // The following sample illustrates how to convert PDF documents to various raster image // formats (such as PNG, JPEG, BMP, TIFF), as well as how to convert a PDF page to GDI+ Bitmap // for further manipulation and/or display in WinForms applications. //--------------------------------------------------------------------------------------- /// [TestFixture] public class PDFDrawTest { /// /// The main entry point for the application. /// [Test] public static void Sample() { // The first step in every application using PDFNet is to initialize the // library and set the path to common PDF resources. The library is usually // initialized only once, but calling Initialize() multiple times is also fine. try { // Optional: Set ICC color profiles to fine tune color conversion // for PDF 'device' color spaces. You can use your own ICC profiles. // Standard Adobe color profiles can be download from Adobes site: // http://www.adobe.com/support/downloads/iccprofiles/iccprofiles_win.html // // Simply drop all *.icc files in PDFNet resource folder or you specify // the full pathname. //--- // PDFNet.SetResourcesPath("../../../..//resources"); // PDFNet.SetColorManagement(); // PDFNet.SetDefaultDeviceCMYKProfile("USWebCoatedSWOP.icc"); // will search in PDFNet resource folder. // PDFNet.SetDefaultDeviceRGBProfile("AdobeRGB1998.icc"); // Optional: Set predefined font mappings to override default font // substitution for documents with missing fonts. For example: //--- // PDFNet.AddFontSubst("StoneSans-Semibold", "C:/WINDOWS/Fonts/comic.ttf"); // PDFNet.AddFontSubst("StoneSans", "comic.ttf"); // search for 'comic.ttf' in PDFNet resource folder. // PDFNet.AddFontSubst(PDFNet.CharacterOrdering.e_Identity, "C:/WINDOWS/Fonts/arialuni.ttf"); // PDFNet.AddFontSubst(PDFNet.CharacterOrdering.e_Japan1, "C:/Program Files/Adobe/Acrobat 7.0/Resource/CIDFont/KozMinProVI-Regular.otf"); // PDFNet.AddFontSubst(PDFNet.CharacterOrdering.e_Japan2, "c:/myfonts/KozMinProVI-Regular.otf"); // // If fonts are in PDFNet resource folder, it is not necessary to specify // the full path name. For example, //--- // PDFNet.AddFontSubst(PDFNet.CharacterOrdering.e_Korea1, "AdobeMyungjoStd-Medium.otf"); // PDFNet.AddFontSubst(PDFNet.CharacterOrdering.e_CNS1, "AdobeSongStd-Light.otf"); // PDFNet.AddFontSubst(PDFNet.CharacterOrdering.e_GB1, "AdobeMingStd-Light.otf"); } catch (Exception) { Console.WriteLine("The specified color profile was not found."); } // Relative path to the folder containing test files. const string input_path = "TestFiles/"; using (PDFDraw draw = new PDFDraw()) { //-------------------------------------------------------------------------------- // Example 1) Convert the first PDF page to PNG at 92 DPI. // A three step tutorial to convert PDF page to an image. try { // A) Open the PDF document. using (PDFDoc doc = new PDFDoc(Utils.GetAssetTempFile(input_path + "tiger.pdf"))) { // Initialize the security handler, in case the PDF is encrypted. doc.InitSecurityHandler(); // B) The output resolution is set to 92 DPI. draw.SetDPI(92); // C) Rasterize the first page in the document and save the result as PNG. Page pg = doc.GetPage(1); draw.Export(pg, Utils.CreateExternalFile("tiger_92dpi.png")); } } catch (Exception e) { Console.WriteLine("Error converting PDF to image: " + e.Message); } } } } } ``` -------------------------------- ### PDFNet Initialization and Conversion Overview (Go) Source: https://docs.apryse.com/core/samples/converttest This Go sample provides an overview of using the PDFNet Convert utility class for various document conversions. It includes setup for input/output paths and notes on printer requirements for certain formats. ```Go //--------------------------------------------------------------------------------------- // Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved. // Consult LICENSE.txt regarding license information. //--------------------------------------------------------------------------------------- package main import ( "fmt" "runtime" . "pdftron" ) import "pdftron/Samples/LicenseKey/GO" //--------------------------------------------------------------------------------------- // The following sample illustrates how to use the PDF.Convert utility class to convert // documents and files to PDF, XPS, SVG, or EMF. // // Certain file formats such as XPS, EMF, PDF, and raster image formats can be directly // converted to PDF or XPS. Other formats are converted using a virtual driver. To check // if ToPDF (or ToXPS) require that PDFNet printer is installed use Convert.RequiresPrinter(filename). // The installing application must be run as administrator. The manifest for this sample // specifies appropriate the UAC elevation. // // Note: the PDFNet printer is a virtual XPS printer supported on Vista SP1 and Windows 7. // For Windows XP SP2 or higher, or Vista SP0 you need to install the XPS Essentials Pack (or // equivalent redistributables). You can download the XPS Essentials Pack from: // http://www.microsoft.com/downloads/details.aspx?FamilyId=B8DCFFDD-E3A5-44CC-8021-7649FD37FFEE&displaylang=en // Windows XP Sp2 will also need the Microsoft Core XML Services (MSXML) 6.0: // http://www.microsoft.com/downloads/details.aspx?familyid=993C0BCF-3BCF-4009-BE21-27E85E1857B1&displaylang=en // // Note: Convert.fromEmf and Convert.toEmf will only work on Windows and require GDI+. // // Please contact us if you have any questions. //--------------------------------------------------------------------------------------- // Relative path to the folder containing the test files. var inputPath = "../../TestFiles/" var outputPath = "../../TestFiles/Output/" ``` -------------------------------- ### Configure Default Popups in Modular UI Source: https://docs.apryse.com/web/guides/modular-ui/ui-import-and-export This example shows the default configuration for annotationPopup, textPopup, and contextMenuPopup in a Modular UI setup. These popups are available starting from version 11.8. ```javascript "popups": { "annotationPopup": [ { "dataElement": "viewFileButton" }, { "dataElement": "annotationCommentButton" }, { "dataElement": "annotationStyleEditButton" }, { "dataElement": "annotationDateEditButton" }, { "dataElement": "annotationRedactButton" }, { "dataElement": "annotationCropButton" }, { "dataElement": "annotationContentEditButton" }, { "dataElement": "annotationClearSignatureButton" }, { "dataElement": "annotationGroupButton" }, { "dataElement": "annotationUngroupButton" }, { "dataElement": "formFieldEditButton" }, { "dataElement": "calibratePopupButton" }, { "dataElement": "linkButton" }, { "dataElement": "fileAttachmentDownload" }, { "dataElement": "annotationDeleteButton" }, { "dataElement": "shortCutKeysFor3D" }, { "dataElement": "playSoundButton" }, { "dataElement": "openAlignmentButton" } ], "textPopup": [ { "dataElement": "copyTextButton" }, { "dataElement": "textHighlightToolButton" }, { "dataElement": "textUnderlineToolButton" }, { "dataElement": "textSquigglyToolButton" }, { "dataElement": "textStrikeoutToolButton" }, { "dataElement": "textRedactToolButton" }, { "dataElement": "linkButton" } ], "contextMenuPopup": [ { "dataElement": "panToolButton" }, { "dataElement": "stickyToolButton" }, { "dataElement": "highlightToolButton" }, { "dataElement": "freeHandToolButton" }, { "dataElement": "freeHandHighlightToolButton" }, { "dataElement": "freeTextToolButton" }, { "dataElement": "markInsertTextToolButton" }, { "dataElement": "markReplaceTextToolButton" } ] } ``` -------------------------------- ### Install Apryse NuGet Package Source: https://docs.apryse.com/xamarin/guides/get-started/integrate-android Install the Apryse NuGet package through the Visual Studio NuGet Package Manager. This automatically includes all required dependencies. ```powershell Install-Package Apryse ``` -------------------------------- ### Build Custom Annotation Toolbar with C# Source: https://docs.apryse.com/xamarin/guides/viewer/new-ui-integration This example demonstrates how to build a custom annotation toolbar by adding predefined tool buttons to the scrollable and sticky regions. ```csharp 1// Supply a unique tag for the toolbar that will be referenced internally 2AnnotationToolbarBuilder builder = AnnotationToolbarBuilder.WithTag("my_unique_annotate_toolbar_tag") 3 // Set a display name for this toolbar 4 .SetToolbarName("Text Annotate") 5 // Adds three tool buttons (text highlight, freehand highlight, and text underline) to the scrollable region (left) 6 .AddToolButton(ToolbarButtonType.TextHighlight, DefaultToolbars.ButtonId.TextHighlight.Value()) 7 .AddToolButton(ToolbarButtonType.FreeHighlight, DefaultToolbars.ButtonId.FreeHighlight.Value()) 8 .AddToolButton(ToolbarButtonType.TextUnderline, DefaultToolbars.ButtonId.TextUnderline.Value()) 9 // Adds two tool buttons (undo and redo) to the sticky region 10 .AddToolStickyButton(ToolbarButtonType.Undo, DefaultToolbars.ButtonId.Undo.Value()) 11 .AddToolStickyButton(ToolbarButtonType.Redo, DefaultToolbars.ButtonId.Redo.Value()); 12 13// Then supply the builder to ViewerConfig, which will be passed on to your viewer 14ViewerConfig config = new ViewerConfig.Builder() 15 // Add out custom annotation toolbar 16 .AddToolbarBuilder(builder) 17 // Other ViewerConfig settings... 18 .Build(); ``` -------------------------------- ### Initialize PDFNet and Setup Paths - C# Source: https://docs.apryse.com/core/samples/elementbuildertest/csharp Initializes the PDFNet SDK and sets up input and output paths for test files. Ensure PDFTronLicense.Key() is valid. ```csharp PDFNet.initialize(PDFTronLicense.Key()); // Relative path to the folder containing test files. String input_path = "../../TestFiles/"; String output_path = "../../TestFiles/Output/"; ``` -------------------------------- ### React Native App Component (GitHub Install) Source: https://docs.apryse.com/ios/guides/get-started/react-native/view-a-document This example shows a basic React Native component for displaying a PDF document using the Apryse SDK, intended for projects installed via GitHub. It includes setup for JavaScript enablement and handling navigation button presses. ```javascript import React, { Component } from "react"; import { Platform, StyleSheet, Text, View, PermissionsAndroid, BackHandler, NativeModules, Alert, } from "react-react-native"; import { DocumentView, RNPdftron } from "react-native-pdftron"; type Props = {}; export default class App extends Component { constructor(props) { super(props); RNPdftron.enableJavaScript(true); } onLeadingNavButtonPressed = () => { console.log("leading nav button pressed"); if (Platform.OS === "ios") { Alert.alert( "App", "onLeadingNavButtonPressed", [{ text: "OK", onPress: () => console.log("OK Pressed") }], { cancelable: true } ); } else { BackHandler.exitApp(); } }; render() { const path = "https://pdftron.s3.amazonaws.com/downloads/pl/PDFTRON_mobile_about.pdf"; return ( ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: "center", alignItems: "center", backgroundColor: "#F5FCFF", }, }); ``` -------------------------------- ### Initialize Apryse SDK and Create a PDF Document in Go Source: https://docs.apryse.com/core/guides/get-started/go Initialize the Apryse SDK with your license key, create a new PDF document, add a page, and save it as a linearized PDF. Ensure your license key is kept confidential. ```go package main import ( . "github.com/pdftron/pdftron-go/v2" ) func main() { PDFNetInitialize("YOUR_APRYSE_LICENSE_KEY"); doc := NewPDFDoc() page := doc.PageCreate() // Start a new page doc.PagePushBack(page) // Add the page to document doc.Save("output.pdf", uint(SDFDocE_linearized)); // Save the document as a linearized PDF doc.Close() } ``` -------------------------------- ### React Native App Component (NPM Install) Source: https://docs.apryse.com/ios/guides/get-started/react-native/view-a-document This example demonstrates a React Native component for viewing PDF documents using the Apryse SDK, suitable for projects installed via NPM. It includes essential setup like enabling JavaScript and defining navigation button behavior. ```javascript import React, { Component } from "react"; import { Platform, StyleSheet, Text, View, PermissionsAndroid, BackHandler, NativeModules, Alert, } from "react-native"; import { DocumentView, RNPdftron } from "@pdftron/react-native-pdf"; type Props = {}; export default class App extends Component { constructor(props) { super(props); RNPdftron.enableJavaScript(true); } onLeadingNavButtonPressed = () => { console.log("leading nav button pressed"); if (Platform.OS === "ios") { Alert.alert( "App", "onLeadingNavButtonPressed", [{ text: "OK", onPress: () => console.log("OK Pressed") }], { cancelable: true } ); } else { BackHandler.exitApp(); } }; render() { const path = "https://pdftron.s3.amazonaws.com/downloads/pl/PDFTRON_mobile_about.pdf"; return ( ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: "center", alignItems: "center", backgroundColor: "#F5FCFF", }, }); ``` -------------------------------- ### Listen for Annotation Toolbar Events with C# Source: https://docs.apryse.com/xamarin/guides/viewer/new-ui-integration This example demonstrates how to listen for annotation toolbar button events by adding a listener to the PdfViewCtrlTabHostFragment2. ```csharp 1mPdfViewCtrlTabHostFragment.ToolbarOptionsItemSelected += (sender, e) => 2{ 3 // The button id defined previously in the AnnotationToolbarBuilder 4 var id = e.P0.ItemId; 5 e.Handled = false; 6}; ``` -------------------------------- ### Initialize PDFNet with License Key (Ruby) Source: https://docs.apryse.com/core/faq/bad-license-key Provides an example of initializing the PDFNet SDK with a license key in Ruby. ```ruby PDFNet.Initialize("YOUR APRYSE LICENSE KEY::Testing::123") ``` -------------------------------- ### Printer Installation and Setup Source: https://docs.apryse.com/core/samples/convertprinttest/csharp Checks if the PDFTron PDFNet printer is installed. If not, it attempts to install it. Sets the printer name for subsequent operations. ```C# if (PrinterIsInstalled("PDFTron PDFNet")){ PrinterSetPrinterName("PDFTron PDFNet") }else if (! PrinterIsInstalled()){ fmt.Println("Installing printer (requires Windows platform and administrator)") PrinterInstall() fmt.Println("Installed printer " + PrinterGetPrinterName()) } ``` -------------------------------- ### Low-Level API Annotation Example Source: https://docs.apryse.com/xamarin/samples/annotationtest This function demonstrates using the low-level SDF/Cos API to add various types of annotations to a PDF document. ```csharp AnnotationLowLevelAPI(doc); ``` -------------------------------- ### Initialize Apryse SDK and Create a PDF Document in Go Source: https://docs.apryse.com/core/guides/get-started/go This snippet demonstrates how to initialize the Apryse SDK with a license key, create a new PDF document, add a blank page, and save the document as a linearized PDF. Ensure you replace 'YOUR_APRYSE_LICENSE_KEY' with your actual license key. ```go package main import ( . "github.com/pdftron/pdftron-go/v2" ) func main() { PDFNetInitialize("YOUR_APRYSE_LICENSE_KEY"); doc := NewPDFDoc() page := doc.PageCreate() // Start a new page doc.PagePushBack(page) // Add the page to document doc.Save("output.pdf", uint(SDFDocE_linearized)); // Save the document as a linearized PDF doc.Close() } ``` -------------------------------- ### Install and Start WebViewer Samples Source: https://docs.apryse.com/web/guides/video/comparing-videos Commands to clone the WebViewer-Video GitHub sample and install dependencies. ```sh npm i npm run start-samples ``` -------------------------------- ### Successful Application Start Output Source: https://docs.apryse.com/web/guides/get-started/blazor This is an example of the expected output when the Blazor application starts successfully. ```shell Building... info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5067 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development info: Microsoft.Hosting.Lifetime[0] Content root path: /path/to/your/project ``` -------------------------------- ### Initialize Apryse SDK with a commercial license key (Go) Source: https://docs.apryse.com/core/guides/info/license Use this Go code to initialize the Apryse SDK with your commercial license key. Remember to substitute the placeholder with your purchased license. ```go PDFNetInitialize("Insert trial key or commercial license key here after purchase") ``` -------------------------------- ### Create and Customize a Text Annotation with User Icon Source: https://docs.apryse.com/xamarin/samples/annotationtest This example demonstrates creating a Text annotation, setting a custom user icon, content, and color, then adding it to a page. ```csharp Text txt = Text.Create( doc, new Rect( 10, 20, 30, 40 ) ); txt.SetIcon( "UserIcon" ); txt.SetContents( "User defined icon, unrecognized by appearance generator" ); txt.SetColor(new ColorPt(0,1,0) ); txt.RefreshAppearance(); page6.AnnotPushBack( txt ); ``` -------------------------------- ### Add a custom link to the quick menu in Java Source: https://docs.apryse.com/xamarin/guides/ui-customization/customize-quick-menu?platform=android Handle the `ShowQuickMenu` event to add a new `QuickMenuItem`. This example adds a 'Custom Link' item with a specific icon and order for the Square annotation type. ```java if (annot.getType() == Annot.e_Square) { QuickMenuItem item = new QuickMenuItem(MainActivity.this, R.id.qm_custom_link, QuickMenuItem.FIRST_ROW_MENU); item.setTitle(R.string.qm_custom_link); item.setIcon(R.drawable.ic_link_black_24dp); item.setOrder(3); ArrayList items = new ArrayList<>(1); items.add(item); quickMenu.addMenuEntries(items); } ``` -------------------------------- ### Successful Apryse SDK Installation Output Source: https://docs.apryse.com/core/guides/get-started/python3?platform=linux This is an example of the expected output after a successful installation of the apryse-sdk package. ```shell Looking in indexes: https://pypi.org/simple, Collecting apryse-sdk Downloading apryse_sdk-.whl Installing collected packages: apryse-sdk Successfully installed apryse-sdk- ``` -------------------------------- ### Successful SDK Installation Output Source: https://docs.apryse.com/core/guides/get-started/dotnetcore?platform=mac Example output indicating a successful installation of the Apryse SDK package. ```bash Build succeeded. info : Adding PackageReference for package 'PDFTron.NET.ARM' into project ... info : Installed PDFTron.NET.ARM . info : PackageReference for package 'PDFTron.NET.ARM' version '' added ... log : Restored /.csproj. ``` -------------------------------- ### Initialize PDFNet and Run Application Source: https://docs.apryse.com/core/samples/pdfviewsimpletest This is the main entry point for the application. It initializes PDFNet with the provided license key and then runs the PDFViewSimple form. ```csharp static void Main() { PDFNet.Initialize(PDFTronLicense.Key); Application.Run(new PDFViewSimple()); } ``` -------------------------------- ### Initialize PDFNet and Setup Paths - Python Source: https://docs.apryse.com/core/samples/interactiveformstest/js Initializes the PDFNet SDK and sets up necessary paths for input and output files. Includes license key loading. ```python # Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved. # Consult LICENSE.txt regarding license information. #--------------------------------------------------------------------------------------- import site site.addsitedir("../../../PDFNetC/Lib") import sys from PDFNetPython import * import math sys.path.append("../../LicenseKey/PYTHON") from LicenseKey import * # Relative path to the folder containing the test files. input_path = "../../TestFiles/" output_path = "../../TestFiles/Output/" #--------------------------------------------------------------------------------------- # This sample illustrates basic PDFNet capabilities related to interactive # forms (also known as AcroForms). #--------------------------------------------------------------------------------------- # field_nums has to be greater than 0. ``` -------------------------------- ### Successful Apryse SDK Installation Output Source: https://docs.apryse.com/core/guides/get-started/python3?platform=linux This is an example of the expected output when the Apryse SDK is successfully installed via pip. It confirms the package collection and installation. ```bash Looking in indexes: https://pypi.org/simple, Collecting apryse-sdk Downloading apryse_sdk-.whl Installing collected packages: apryse-sdk Successfully installed apryse-sdk- ``` -------------------------------- ### Initialize PDFNet and Create Document - Go Source: https://docs.apryse.com/core/samples/unicodewritetest/go This snippet shows the basic setup for using PDFNet in Go, including document creation and element builder initialization. Ensure PDFNet is properly installed and licensed. ```go const ( // Use the PDFNet Go binding // For example: // "github.com/apryse/PDFNetGo/PDFNet" ) func main() { PDFNet.Initialize("YOUR_APRYSE_LICENSE_KEY") // Create a new PDF document doc, err := PDFNet.NewPDFDoc() if err != nil { // Handle error return } // Create an element builder and writer eb, err := doc.CreateElementBuilder() if err != nil { // Handle error return } writer, err := doc.CreateWriter() if err != nil { // Handle error return } // ... rest of the code ... // Save the document err = doc.Save("output.pdf", PDFNet.SDFDocSave_linearized) if err != nil { // Handle error return } doc.Close() } ``` -------------------------------- ### Example Byte-Range HTTP Header Source: https://docs.apryse.com/ios/guides/viewer/view-online-pdfs An example of an HTTP GET header requesting a specific range of bytes from a file. ```sh Range: bytes=1495454-1594723 ``` -------------------------------- ### High-Level Annotation API Example Source: https://docs.apryse.com/xamarin/samples/annotationtest Demonstrates using the high-level PDFNet API to read existing annotations, edit them, and create new annotations from scratch. The results are saved to a new PDF file. ```csharp // An example of using the high-level PDFNet API to read existing annotations, // to edit existing annotations, and to create new annotation from scratch. AnnotationHighLevelAPI(doc); doc.Save(Utils.CreateExternalFile("annotation_test2.pdf"), SDFDoc.SaveOptions.e_linearized); System.Console.WriteLine("Done. Results saved in annotation_test2.pdf"); ``` -------------------------------- ### Successful Apryse SDK Installation Output Source: https://docs.apryse.com/core/guides/get-started/python?platform=windows This is an example of the expected output after successfully installing the Apryse SDK using pip. ```bash Looking in indexes: https://pypi.org/simple, Collecting apryse-sdk Downloading apryse_sdk-.whl Installing collected packages: apryse-sdk Successfully installed apryse-sdk- ``` -------------------------------- ### Main Entry Point - C# Source: https://docs.apryse.com/core/samples/converttest/csharp Initializes the PDFNet SDK and calls conversion functions. Handles potential errors during conversion. ```csharp PDFNet.Initialize(PDFTronLicense.Key); bool err = false; err = ConvertToPdfFromFile(); if (err) { Console.WriteLine("ConvertFile failed"); } else { Console.WriteLine("ConvertFile succeeded"); } err = ConvertSpecificFormats(); if (err) { Console.WriteLine("ConvertSpecificFormats failed"); ``` -------------------------------- ### Apryse SDK Installation Success Output Source: https://docs.apryse.com/core/guides/get-started/python3?platform=mac This is an example of the expected output when the Apryse SDK is successfully installed via pip. ```Bash 1Looking in indexes: https://pypi.org/simple, 2Collecting apryse-sdk 3 Downloading apryse_sdk-.whl 4Installing collected packages: apryse-sdk 5Successfully installed apryse-sdk- ``` -------------------------------- ### Initialize Apryse SDK in Objective-C Source: https://docs.apryse.com/ios/guides/get-started/integration/cocoapods Call `[PTPDFNet Initialize:]` within the `application:willFinishLaunchingWithOptions:` method of your `AppDelegate.m` file. Replace 'Insert Commercial License Key Here After Purchase' with your actual license key. For trial purposes, any string will enable demo mode with watermarks. ```objectivec #import "AppDelegate.h" #import @implementation AppDelegate - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions{ [PTPDFNet Initialize:@"Insert Commercial License Key Here After Purchase"]; return true; } @end ``` -------------------------------- ### Initialize PDFNet and Setup Paths - Java Source: https://docs.apryse.com/core/samples/interactiveformstest/cpp Initializes the PDFNet SDK with a license key and defines the output path for generated files. This is a standard setup step for PDFNet applications. ```java PDFNet.initialize(PDFTronLicense.Key()); String output_path = "../../TestFiles/Output/"; ``` -------------------------------- ### Get Stamp Annotation Image Data (SDK v6.0+) Source: https://docs.apryse.com/web/guides/annotation/types/stampannotation This example demonstrates how to get the image data for a stamp annotation using an older SDK version. It follows a similar pattern to the v8.0+ example, retrieving the image data asynchronously for further use. ```javascript WebViewer(...) .then(instance => { const { annotManager, Annotations } = instance.Core; annotManager.on('annotationChanged', (annotations, action) => { if (action === 'delete') { annotations.forEach(annot => { if (annot instanceof Annotations.StampAnnotation) { const imageData = await annot.getImageData(); const image = new Image(); image.width = annot.Width; image.height = annot.Height; image.onload = function() { // Use image }; image.src = imageData; } }); } }); }); ``` -------------------------------- ### Initialize PDFNet with License Key (C#) Source: https://docs.apryse.com/core/faq/bad-license-key Demonstrates how to initialize the PDFNet SDK with a license key in C#. ```csharp pdftron.PDFNet.Initialize("YOUR APRYSE LICENSE KEY::Testing::123"); ``` -------------------------------- ### Install Docker on EC2 Instance Source: https://docs.apryse.com/web/guides/wv-server-aws-deployment Commands to install Docker, start the service, and grant user permissions on an Amazon Linux EC2 instance. ```bash sudo yum update -y sudo yum install -y docker sudo service docker start sudo usermod -aG docker ec2-user ``` -------------------------------- ### Initialize PDFNet with License Key (Java) Source: https://docs.apryse.com/core/faq/bad-license-key Provides an example of initializing the PDFNet SDK with a license key in Java. ```java PDFNet.initialize("YOUR APRYSE LICENSE KEY::Testing::123"); ```