Basically I want to go from here (available as an ArrayBuffer):
to here: (also available as an ArrayBuffer)+
So it's
ArrayBuffer -> Image -> Image with overlay -> ArrayBuffer
in javascript only without showing anything to the user.
If possible, I want to generate that table using html (still without showing anything to the user).
I had that idea of displaying an invisible Chrome Appwindow to render the page with the image as its background just to export it using the html2canvas library.
However, there has to be a better approach to this ...
Does anyone have an idea of how to implement such a functionality?
Related
I am currently having trouble getting started with writing an extension that shifts the viewer to a pdf view. More or less, the extension button in mind, when clicked/activated, makes the viewer look like the first image here, and when it is clicked again/deactivated, it reverts back to the regular 3D viewer.
I tried looking into the code in the above link but I don't understand where the modelDocument object came from. I am using the Forge Viewer completely offline, so I am not dealing with any URNs, authentication mechanisms, etc. I already wrote extensions that can change the 3D model in the browser in some way, but this new extension is different.
Thank you in advance!
The viewer can only load multiple models at a time but they have to be both 2D or both 3D, you cannot load a 2D model in the same instance if you loaded a 3D model.
You could simply instantiate a 2nd viewer that will load the pdf view, either overlay a div, or navigate to another page or display it side by side like in my demo. That's really up to you.
If you use the viewer offline, then I'm assuming you somehow downloaded the viewable resources that correspond to the translated pdf, in which case you can simply load a 2D model the same way you load the 3D one, using viewer.loadModel('path/to/your/.f2d/resource').
Hope that helps
Is there a way to implement functionality so that a user can Right click a subsection of an Html page (say a DIV or other container element) so that that part can be saved as an image/pdf (using javascript)?
Alternatively (ideally) can this be done on the server side in ASP.NET?
The use case for this is the following:
I have some complex web pages generated in asp.NET and using the javscript Flot library for the graphs. I would like to reuse part of the html page to generate PDF reports or at least image snapshots which can easily be inserted into reports. I have looked around and it seems there is a tool wkhmltopdf which converts the entire page to PDF, however there are 2 issues:
This tool needs to be run separately, which is not friendly for end users
The tool extracts everything on the page, e.g. menus headers , footers etc.
For the second problem I could generate web pages without the headers/footers and menus, and then use the tool, but this does not solve problem 1. Ideally I would like to generate the report weekly and automatically so the user only needs to download it.
For this purpose what is really needed is some way to store as pdf or image a DIV (or other element) referenced by id. This way I would not need to write separate code to generate the reports. I realize there will be a loss of quality converting html to PDF, but for our purposes, this is not that important.
IECapt# is a new and experimental version of IECapt written in C# to render a web page into a BMP, JPEG or PNG image file.
see http://iecapt.sourceforge.net/
You will have to make some calculations, if you want to crop the captured image to your requirements, or give the tool the html u actually want as an image,instead of the whole page.
Hope this helps.
In case this can help others, I finally settled for the iTextSharp library which is very powerful and also handles svg. It does not do the general html5 to pdf dump but with a bit of code I can do most of what I need.
main website is:
http://itextpdf.com/
download:
http://sourceforge.net/projects/itextsharp/
I want a frame with a PDF document. The main document will use javascript to tell the PDF document what page to display and zoom level. Can this be done? If so, how or could you point me to documentation on it. Thanks.
You can't/shouldn't do it in a frame, but you can create an <object> on your page that is controllable using the JavaScript API.
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf
Not easily. It all depends on what's being used to display the PDF in the browser. Not all browsers have built-in PDF viewers, and then there's many different external viewers (e.g. Acrobat, Fox-It, etc...) as well. As far as I know, there's
You can try hacking up the URL like this:
http://example.com/somedocument.pdf#page=5
but this may work in Acrobat only, as documented here: http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf
Do you need a PDF reader to be loaded and running? If not, you could write a back end script/program to render a specified page as an image (GIF, PNG, etc.) at a particular zoom level. Then your main page could load an image with something like:
<img src="render_pdf?page=4&zoom=150">
The src value could be controlled with javascript to make it dynamic.
To convert from PDF to an image in your render_pdf script, you can use ghostscript, or an image specific library like ImageMagick or GD, depending on what backend technology you are using.
Have a look at jsPDF - it may not output a .pdf onscreen in IE6 and IE7 due to limitations with datauri's, but its a good start. I dont see why this couldnt be built up in an iframe either.
As Jordan pointed out, you should use the <object> tag to embed the PDF. Then, in the PDF itself, you need to embed Javascript to handle the messages you pass in, such as:
if(!this.hostContainer.messageHandler) this.hostContainer.messageHandler = new Object();
this.hostContainer.messageHandler.onMessage = handleMessage;
function handleMessage(msg) {
// do stuff here
}
Finally, in your HTML JS, you pass messages in with:
document.getElementById('yourpdfobject').postMessage('some message or array');
I have created a graphics using jquery. and i want to convert this web page to pdf or an image. Which one is simpler? but when I convert this page to pdf that graphic will not shows. can any help me to solve this problem??? please refer some code.
JavaScript is interpreted by the browser, not by the HTML -> PDF application. I'd recommend using wkhtmltopdf, as it uses Webkit to render, so maybe that would fix your problem.
To try to render the page that includes JavaScript, fire up Google Chrome (or another browser with a DOM Inspector of sorts), open your webpage, right click and select Inspect Element, right click , click Edit as HTML, and copy & paste the HTML into a new text document, save it, and use that instead to convert to a graphics.
You have to go through a complicated process like this because that application that your are using renders only HTML + CSS, and doesn't even parse the JS. The DOM inspector shows the HTML pages as it currently looks, not when it was loaded.
I hope I didn't make it too complicated...
Is there anyway to take take a "screenshot", "save" or "capture" the active SWF element on a page as an image? I'd like for users to be able to simply click a button on my page, instead of having to need to manually take a screenshot of the entire page and then crop the image to show only the SWF element.
I found a Jquery method, although I am unsure if it could work with SWF files. It basically captures an area of an Image element on the page and allows you to save that as a separate image. What I would need however, is to capture the SWF as the image instead. Note: I do not have access to the SWF code so I cannot achieve this using Actionscript or anything like that -it has to be purely done with PHP and Javascript.
Thanks for any ideas :)
I don't think that there is a way to do this from Javascript, but if you host those swf files on your own server you could create a wrapper swf which loads the swfs you want to screenshot dynamically and then draws them into a BitmapData object.
The snapshot process inside of the swf can be triggered from Javascript via ExternalInterface, after that you can either serialize the raw pixels or use a PNG or JPEG encoder inside the wrapper swf to convert the bitmapdata to a image file and then send that data back to Javascript via ExternalInterface. Or you use the FileReference class in the swf to save the image file directly on the user's hard drive - one caveat in this is though that in order to trigger the save process the user will have to click a button inside the swf (that's a security feature).
There is one more prerequisite and that is that the swfs that you load into the wrapper have to be hosted on the same domain as the wrapper swf, otherwise the security sandboy will not allow to take a bitmap snapshot of it.
Look at ByteArray.getPixels(0,0,stage.stageWidth,stage.stageHeight) or var b;BitMap = BitMapData(stageW,stageH).draw(stage), depending on your needs. Note that the above two lines are not proper code, just the correct object and function names written in shorthand and from my head.