How to allow will add image using pdfjs? - javascript

I am trying to add an image on my canvas using pdfJS, but i am getting an error
"Invalid PDF structure"
Can pdfJS add images like pdfs?
My code:
https://gist.github.com/kamil161g/0a4c5b6eec3f42a3c13877110b6268b4

Welcome to StackOverflow, Kamil Gąsior.
In future questions, please add example source codes directly to your question, and don't link to it.
Assuming you are refering to this pdf.js: https://mozilla.github.io/pdf.js/
The page clearly states "A general-purpose, web standards-based platform for parsing and rendering PDFs.". This would imply: "no". This is also consistent with the error message you're getting.

Related

How to hide/not display PDF title in the toolbar

Is there any way to access metadata of PDF file I embedded using pdfobject.js? I would like to replace/change its title because it's not corresponding to its filename. example is the snip below. filename of that is 'D1000SPN.pdf' which is different from the title displaying.
I tried to search but found none. However, since I can't find a solution to that. I decided to just not display the PDF title on its toolbar anymore or hide it.
I'm a newbie so please bare with me.
sample image
Check the section https://pdfobject.com/#the-why
Specifically, where it says "What PDFObject doesn't do".
In a nutshell:
"PDFObject does not provide the ability to customize the look and feel of the PDF toolbar."
Why?
"PDFObject is not a rendering engine. PDFObject just writes an element to the page, and relies on the browser or browser plugins to render the PDF."
It continues elaborating...
"If you really need to customize the toolbar, try forking Mozilla's PDF.js and customizing it to suit your needs."
But maybe there is hope...
"Some of these browsers provide the ability to show or hide the toolbar, or a feature such as the search field, via PDF Open Parmeters".
See the image below:
I tried it on Chrome and worked for me.
Good luck.

(Moodle) I keep getting raw data when exporting .xlsx file containing HighCharts Images

This issue has baffled me, mainly because it makes no sense. I have some custom PHP code that I wrote on top of my LMS system (Moodle) to display some of its collected data in a HighCharts Table. What makes no sense is that I can almost GUARANTEE the code isn't broken because I checked older working versions of it and the same problem occurs. I never ran an update on Moodle in a long time so no known changes could have affected this.
Here are some weird things I found while troubleshooting:
Only this report is giving this issue.
Whenever I move this ENTIRE code to another PHP with a different name the issue doesn't occur.
Some more important details:
Uses the online version of highcharts.js scripts
The scripts I'm using are:
"https://code.highcharts.com/highcharts.js"
"https://code.highcharts.com/highcharts-more.js"
"https://code.highcharts.com/modules/exporting.js"
"https://code.highcharts.com/modules/export-data.js"
"https://code.highcharts.com/modules/accessibility.js
Please let me know if you've seen this issue before and what step you took to fix it. Also, I can't share the website this issue is on because the content password locked within my Organization.
CLICK HERE FOR IMAGE: This is what happens when I click the export button. The URL changes to something long and then outputs this.

Is it possible to print an HTMLdocument with a generic (text only) printer?

I have an HTML document with tables and inline CSS to align text, specify width and font weight.
I tried to print the html document with a generic printer (Bixolon srp-275ii) and printed all data without any format.
I wonder if it's possible to print the document in HTML format with a JS/JQuery pluggin or do I need to convert it to PDF?
Im currently experimenting with Electron and trying to create a POS desktop app with silent printing to the receipts.
Any help is welcome!
After a quick Google search I saw https://www.npmjs.com/package/html-to-text which looks like it probably could do what you want and it is in Javascript :)
I have not actually tried it myself, but I hope it works well for you.
For HTML document, you can try using tray, instruction is in their Github wiki: https://github.com/qzind/tray/wiki/2.0-Pixel-Printing#html-printing, but note that this still required you to install an additional plugin to the computer

PDF rendering only in presentation mode while using PDF.JS

I have been through with the provided documentation on PDF.js, I am able to render the buttons correctly, but there is something wrong, my pdf is not rendering and background of the page is also white.When I click on the presentation mode, pdf renders in the full page which is perfect. But not able to understand what possible be wrong with the render thing that it is not rendering on page load.
I am using
1.compatibility.js
2.l10n.js
3.pdf.js
4.debugger.js
5.viewer.js
6.metadata.js
7.bidi.js
The only warning which I got is
The provided value 'moz-chunked-arraybuffer' is not a valid enum value of type XMLHttpRequestResponseType.
I am currently not able to understand why most of the issues are still not solved,
Thanks in advance

get a reference to timestamp in an embedded kibana chart in html page

In the picture in the following link the black box labeled #timestamp lists a date and time (sorry you need a 10 reputation to post an image)
https://www.elastic.co/assets/bltde09cbafb09b7f08/Screen-Shot-2014-09-30-at-4.07.15-PM.png
I have a kibana 4 dashboard embedded in a webpage and I would like to get access to these timestamps. An ideal behavior would be when a node is clicked the time stamp is printed in the console.
I have already suppressed the same-origin policy.
Has anyone performed something similar? I would appreciate any solution or insight.
Try to grab it using jQuery's .contains selector:
$(':contains(#timestamp)').click(function(){
var info = $(this).parent().find(':contains(,)').html();
console.log(info);
});

Categories

Resources