Knowledge Base - How to build your first PDF reader for Windows UWP - v1.20

Download the PDF version of this guide.

Before you start

Check your Visual Studio. Recommend release is:

  • Microsoft Visual Studio Community 2019
  • Version 16.8.6

How to include RadaeePDF SDK in your project

Copy following folders from downloaded demo project to your own project root path:

  • /bin
  • /lib
  • /RDPDFLIb

Follow below steps:

  • From VisualStudio. Right click on “Solution ‘[your_solution_name]” in Solution Explorer, select “Add”->”Existing project...” in the pop-up menu.
  • Locate “RDPDFLIb/RDPDFLIb.vcxproj” folder in the pop-up file picker.
  • Expand your application project in solution explorer, right click on “Reference”. Select “Add reference” in pop-up menu
  • Select “Projects” from the list on the left of the pop-up window. And check RDPDFLIb in the project list. Close the window by clicking on the “OK” button.
  • Copy /[demo_project_root_path]/PDFViewerSDK_Win10/comm/PDFReader.cs to your application project code path. 
  • Change the name space of PDFReader class as you wish.
  • From VisualStudio. Right click on “[your_application_name]’” in Solution Explorer, select “Add”->”Existing item..” in pop-up menu
  • Locate “PDFReader.cs” you just copied to your application project in the pop-up file picker.
  • Rebuild the solution. If any error about the UWP SDK version arises in this step. Right click on “Solution ‘[your_solution_name]’” in Solution Explorer, select ”Retarget solution”, and set the min SDK version to whichever you have installed for Visual Studio.

How to open your first PDF file

Before you can use most APIs from Radaee Core Lib, you have to activate it with your license. To do so, call the following method before everything starts.

using com.radaee.reader;

......

RDPDFLib.pdf.PDFGlobal.ActiveLicense(2, "[Company_name]", "[Mail]", "[License]");

In any .xaml file which you want to display the PDF file content.

Prepare a RelativePanel as a PDF document content container.

<RelativePanel Name="[Your_Container_Name]" />

Select a PDF document file from your local drive by using FileOpenPicker

FileOpenPicker filePicker;
filePicker = new FileOpenPicker();
filePicker.ViewMode = PickerViewMode.List;
filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
filePicker.FileTypeFilter.Add(".PDF");
filePicker.FileTypeFilter.Add(".pdf");
StorageFile file = await filePicker.PickSingleFileAsync();
if (file != null){
     // Application now has read/write access to the picked file
IRandomAccessStream stream = await
file.OpenAsync(FileAccessMode.ReadWrite);
if (stream != null)
{
pdf_open(stream, "");
}
}

Open PDF document file:

private void pdf_open(IRandomAccessStream stream, String password){
PDFDoc doc = new PDFDoc();
    PDF_ERROR err = doc.Open(stream, password);
switch (err) {
case PDF_ERROR.err_open:
break;
case PDF_ERROR.err_invalid_para:
break;
case PDF_ERROR.err_encrypt:
break;
case PDF_ERROR.err_bad_file:
break;
case PDF_ERROR.err_password:
break;
case PDF_ERROR.err_ok:
show_PDF(stream, doc);
break;
default:
break;
}
}

Show PDF document content in container:

private void show_PDF(IRandomAccessStream stream, PDFDoc doc){
PDFReader reader = new PDFReader();
reader.PDFOpen(“[Your_Container_Name]”, doc, 
PDF_LAYOUT_MODE.layout_vert, null);
}

 

Applies To

RadaeePDF SDK for Windows 10

Details

Created : 2021-04-13 18:18:09, Last Modified : 2021-04-13 18:19:26

Order history

Login to handle your order history.