Jump to content
uniGUI Discussion Forums
Sherzod

A PDF Viewer Panel - No Browser Plugin required, pure JavaScript

Recommended Posts

Hi All!!

 

A PDF Viewer Panel - No Browser Plugin required, pure JavaScript

 

Source: http://www.sencha.com/forum/showthread.php?237361-A-PDF-Viewer-Panel-No-Browser-Plugin-required-pure-JavaScript

 

Demo: http://SunboX.github.com/ext_ux_pdf_panel/demo/

 

Github Project: https://github.com/SunboX/ext_ux_pdf_panel

 

 

How to use: 

 

TRY...

 

1. Download files:     

    http://sunbox.github.io/ext_ux_pdf_panel/lib/pdf.js/compatibility.js       --> copy to directory (/files/pdf/)

    sunbox.github.io/ext_ux_pdf_panel/lib/pdf.js/pdf.js       --> copy to directory (/files/pdf/)

   

    http://sunbox.github.io/ext_ux_pdf_panel/ux/util/PDF/TextLayerBuilder.css       --> copy to directory (/files/pdf/pdf/)

    http://sunbox.github.io/ext_ux_pdf_panel/ux/panel/PDF.js       --> copy to directory (/files/pdf/pdf/)

    http://sunbox.github.io/ext_ux_pdf_panel/ux/util/PDF/TextLayerBuilder.js       --> copy to directory (/files/pdf/pdf/)

 

2. Add CustomFiles in UniServerModule: 

files/pdf/compatibility.js
files/pdf/pdf.js
files/pdf/pdf/PDF.js
files/pdf/pdf/TextLayerBuilder.js
files/pdf/pdf/TextLayerBuilder.css

3. Paste into a form UniHTMLFrame1 and add UniHTMLFrame1.HTML...:

<div id="pdfviewer" align="center"></div>

4. 

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniSession.AddJS('if (Ext.get("pdfviewerpanel")) {Ext.get("pdfviewerpanel").remove()};');
  UniSession.AddJS('Ext.create(''Ext.ux.panel.PDF'', {' +
                   'id       : "pdfviewerpanel", ' +
                   'title    : ''PDF Panel'',' +
                   //'width    : ' + IntToStr(UniHTMLFrame1.Width) + ' ,' +
                   //'height   : ' + IntToStr(UniHTMLFrame1.Height) + ',' +
                   'width    : 489,' +
                   'height   : 633,' +
                   'pageScale: 0.75,' +
                   'src      : ''http://cdn.mozilla.net/pdfjs/tracemonkey.pdf'', ' +
                   'renderTo : "pdfviewer"' +
                   //'renderTo : Ext.getBody()' +
                   '});');
end;

Best regards.

 

Share this post


Link to post
Share on other sites
Hi

Thanks

Other method with pdf.js

DisplayPdf:=UniServerInstance.NewLocalCacheFile('pdf');

CopyFile(MyPdf,DisplayPdf,False);

S:=UniServerInstance.LocalCacheURL;

S:=S+ExtractFileName(DisplayPdf);

if copy(S,1,1)<>'/' then S:='/'+S;

S:=UniServerInstance.FilesFolderURL+'pdf.js/web/viewer.html?file='+S;

UniUrlFrame1.url:=S;

        

Share this post


Link to post
Share on other sites

Hello

Pdf.js  very cool product,

but FastReport pdf without embedded fonts and russian letters display incorrect.

Share this post


Link to post
Share on other sites

thanks for sharing,

That's perfect for integration into unigui, but I miss some basic things such as being able to print, or that the document is not paginated

 

i Attach a demo sample in xe2, all included.

Complile and run in debug mode. (or copy files debug/files to /release/files to run in release mode)

 

PdfViewer.rar

 

 

Share this post


Link to post
Share on other sites

×