Jump to content

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.

 

Link to comment
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;

        
Link to comment
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

 

 

Link to comment
Share on other sites

  • 7 months later...
  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...