Jump to content


Photo

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

PDF Viewer JavaScript

  • Please log in to reply
9 replies to this topic

#1 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 5177 posts

Posted 09 June 2014 - 11:21 AM

Hi All!!

 

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

 

Source: http://www.sencha.co...pure-JavaScript

 

Demo: http://SunboX.github...pdf_panel/demo/

 

Github Project: https://github.com/S...xt_ux_pdf_panel

 

 

How to use: 

 

TRY...

 

1. Download files:     

    http://sunbox.github...ompatibility.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...ayerBuilder.css       --> copy to directory (/files/pdf/pdf/)

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

    http://sunbox.github...LayerBuilder.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.

 


  • 0

#2 Stas

Stas

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 188 posts
  • LocationKiev Ukraine

Posted 09 June 2014 - 11:37 AM

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;
        

  • 0

#3 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 5177 posts

Posted 09 June 2014 - 11:52 AM

Thanks Stas.
 
I'm not very delved...

  • 0

#4 Stas

Stas

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 188 posts
  • LocationKiev Ukraine

Posted 09 June 2014 - 12:08 PM

Hello

Pdf.js  very cool product,

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


  • 0

#5 brunotoira

brunotoira

    Member

  • Members
  • PipPip
  • 41 posts

Posted 09 June 2014 - 09:12 PM

WOW!!!!!!!!!!!! THIS ROCKS !!! Thanks!!!


  • 0

#6 ganzqgy

ganzqgy

    Advanced Member

  • Members
  • PipPipPipPip
  • 143 posts

Posted 11 June 2014 - 08:10 AM

Double byte character support is not good.
IE does not support


  • 0

#7 docjones

docjones

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 101 posts

Posted 11 June 2014 - 03:10 PM

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)

 

Attached File  PdfViewer.rar   933.02KB   334 downloads

 

 


  • 0

#8 lema

lema

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 361 posts

Posted 11 June 2014 - 06:18 PM

Thanks for sharing !


  • 0

#9 aans

aans

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 30 January 2015 - 09:13 AM

its work in android tablet ?


  • 0

#10 mroustaei

mroustaei

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 28 April 2018 - 09:53 AM

hello docjones

i run program and click load then pdf opening download manager do not show pdf into panle 


  • 0





Also tagged with one or more of these keywords: PDF Viewer, JavaScript

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users