0

I am opening a PDF in fancybox3 using a base64 string. It opens the PDF but the actual pages appear very very tiny. If I zoom-in a few times then they appear fine. Is there a way to set the zoom to 100% within the open function?

   $.fancybox.open({
                content: '<iframe width="80%" height="90%" src="data:application/pdf;base64,' + data + '" />',             
                width: 800,
                type: "html",
            });
alwaysVBNET
  • 3,150
  • 8
  • 32
  • 65

1 Answers1

0

First, the more correct fancybox usage would be something like this:

$.fancybox.open({
  type : 'iframe',
  src  : "data:application/pdf;base64,' + data + '",
  iframe : {
    css : {
      width: '80%',
      height: '80%'
    }
  }
});

(and you could also use iframe/attr to add custom properties for iframe tag)

2nd, I am not sure it is possible to change zoom level for generated pdf document. Maybe try avoiding using base64, then you would be able to set custom parameters - Zoom to fit: PDF Embedded in HTML

Janis
  • 8,593
  • 1
  • 21
  • 27
  • It still appears as if it's 1 pixel document – alwaysVBNET Aug 02 '18 at 10:17
  • Works fine for me, can you show some demo? https://codepen.io/anon/pen/JBvKBm?editors=1010 – Janis Aug 02 '18 at 11:01
  • I posted my base64 on your fiddle but I can't see the PDF. I can only see white. Same as with your base64 – alwaysVBNET Aug 02 '18 at 11:55
  • Well, it works on ff, but I guess you need some pdf reader on your pc to make it work on other browsers. This is why I always recommend using https://mozilla.github.io/pdf.js/ to display pdf files. – Janis Aug 02 '18 at 13:41