Available only in PRO Edition
Since 3.0
The widget is available in the Webix Pro edition.
PDFViewer is a tool for displaying the content of PDF files on the screen.
The viewer is recommended for use with the dedicated toolbar that contains buttons for paging and zooming. Viewer and toolbar are initialized in separate layout rows:
Thus, the default constructor of PDF viewer with toolbar looks as follows:
webix.ui({
rows:[
{ view:"pdfbar", id:"toolbar" },
{
view:"pdfviewer",
id:"pdf",
toolbar:"toolbar",
url:"binary->files/WebixDocs.pdf"
}
]
});
Configuration parameters are:
Toolbar is supplied with the following fully functional controls:
If you need, you can use the viewer and the toolbar separately, by using their public API methods.
sets the page to show in the viewer
Possible values are "prev", "next" or page number.
$$("toolbar").setMasterPage("prev");
// or
$$("toolbar").setMasterPage(3);
applies a new scale value to the viewer
parameters:
The possible values of the "scale" parameter coincide with the same parameter of the setScale() method.
$$("toolbar").setMasterScale(0.3);
// or
$$("toolbar").setMasterScale('page-actual');
sets the current page in the toolbar
parameters:
$$("toolbar").setPage(2);
sets a new value for the toolbar scale
parameters:
$$("toolbar").setScale(0.4);
// or
$$("toolbar").setScale('page-width');
sets values of toolbar controls, namely the number of pages in the document and the scale in use
parameters:
$$("toolbar").setValues(15,"auto-width");
//or
$$("toolbar").setValues(10,"page-actual");
applies zooming to the viewer (in or out); it is called on a toolbar button click ("+" or "-")
parameters:
$$("toolbar").zoom("in");
applies downloading to the viewer to get its contents as PDF file
$$("toolbar").download();
There are three possible ways of loading data to PDF viewer:
{
view:"pdfviewer",
url:"binary->files/data.pdf"
}
{ view:"pdfviewer", id:"pdf"},
...
$$("pdf").load("binary->files/data.pdf");
Related sample: PDF::File Loading
Binary proxy is used for loading the file, which allows getting its contents as ArrayBuffer.
{
view:"uploader",
width:200,
height:45,
value:"Choose a PDF file to upload",
accept:"application/pdf",
on:{
onBeforeFileAdd:function(upload){
$$("pdf").parse(upload.file);
return false;
}
}
}
Related sample: PDF File Uploading and Downloading
The dependencies which are necessary for working with PDF Viewer are generally taken from Webix CDN online catalog. If you need to view and download files via PDF Viewer offline, you should complete the following steps:
webix.env.cdn = "/local_folder";
Note that specifying the path to the local CDN repository has some peculiarities:
1) in case you set the path relative to the current page, it should be specified as:
webix.env.cdn = "../../../../local_folder";
2) the absolute path to the repository should be specified as follows:
webix.env.cdn = "http://localhost/local_folder";
Back to top