Does anyone know a way of rotating an image (jpg or gif) in a TWebBrowser control (using Delphi)
Update
The file would be local.
Update 2
So I guess the question should be how do I rotate an image or pdf.
If you have control over the content return in the TWebBrowser it can be done via JavaScript.
Here is an example on JavaScript Image Rotation.
If you want to do it with a TImage there are several options listed in this Q/A.
I guess that you already use this approach to show the HTML content in your TWebBrowser.
Now, instead of JavaScript (as suggested by Robert), you use CSS in the generated HTML document.
I haven't tested this, but you should be able to rotate the image (and other HTML-elements) by using this CSS code (for IE-based browsers):
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
See details at MSDN
Well if it's on a website (in the TWebBrowser) then you can't rotate it. The best you can do is if the image is on your website you can use PHP/ASP/etc. to load the image, and produce a rotated version of it.
Related
I am trying to use html2canvas library, to save html that's dynamically generated and output to the page as image. If the HTML generated isn't too much, then the html2canvas would work just fine, however, if the html generated is really too big (when I try to print it, it's 70 pages), then the html2canvas will return a canvas object where canvas.toDataURL('image/png') returns data:; and that's it.
I found a post online suggesting to change the maxInt in the html2canvas.js file to be Number.MAX_VALUE, but that didn't work as well.
Is there a way to workaround this issue? I will need this image to eventually pass it to jspdf library to generate a pdf document.
First things first. If you are getting clipping it could be because you are trying to capture an image that is too large for the browser. See the FAQ on limits of canvas sizes:
https://html2canvas.hertzen.com/faq
If that's the case then you'll need to break up the image into smaller sub-images and write those out as separate pages to your PDF. You can't combine them into a single image because the browser won't let you.
If you are under that size then it could be because of a defect that affects alpha.12 where capturing document.body can clip content if you are using passing the option windowWidth. The workaround to that defect is just to capture something other than document.body and it'll work.
I am using VS2013Express to create a windows form based application which will display and eventually print Visio documents, rather than relying on the browser based Visio Viewer. Needless to say this is a very specific requirement, so really don't need anyone telling me to use the MS Visio Viewer!
So far, I can open the Visio document, display it using the AxVisioViewer.dll control. I can even print... to a degree.
The issue is that I can only print currently using a PrintFromScreen method which basically captures the image of the form as displayed on screen and creates a Raster BitMap of it.
I copy the BitMap image to a hidden panel on the form (to remove toolbars etc), then print the contents of the panel. Simple (ish)!
Here's a link to the page I used to create the panel and print the image.
What I want to be able to do is resize (Vector not Raster to retain scale) and centre the image as required to ensure the document prints properly.
You'll want to center the drawing in the control.
Check the following link.
https://msdn.microsoft.com/en-us/vba/visio-vba/articles/viewer-zoomtorect-method-visio-viewer
You may also check the zoom and pan methods.
I am trying to create pdf with a single label to print to a Brother PL-7 label printer.
I found jsPDF that is able to generate a PDF, however two problems.
I can't seem to specify the document to a custom size.
I am unsure of how to put the bar code I have in a canvas generated by jsBarcode into the PDF.
How can I create a single label size PDF document with a bar code included on it?
I had the same issue and found this fix on their github issues page in regards to the first problem:
https://github.com/MrRio/jsPDF/issues/372
worked for me perfectly once the that code was altered.
I know a lot less about how what exactly jsBarcode generates, but if it is generating a canvas file as you mentioned in your question, it can be converted into a png/jpeg and then be fed into jsPDF. See HTML5 canvas, convert canvas to PDF with jspdf.js.
Below is a thumbnail type image that is on a post from http://doctype.com/, if you haven't been on the site yet, it is similar to this site but for css/design stuff and when you post a question you can have it post a screenshot image as well for you of a website url.
Below is one of them I saw, do you think this is something done programmticly?
IF so how would you do this server side?
(source: doctype.com)
You can achieve this screenshot-in-a-note effect by having a template image of the curled-paperclipped-note (the curled border, the paper clip, the shadow) and a mask for where the screenshot of the site should fit inside the template. Once you get the screenshot you just rotate it slightly and compose it with the template.
To compose it programmatically you could use ImageMagick as sugested by cpharmston.
Here's an alternative of how to compose the two images with PIL and python.
If it is done programmatically, it likely uses an image processing library. GD and ImageMagick are two of the more popular ones.
Yes, you need to do it programmatically on the server. There are some flash plugins to do it, but I think server side is the way to go.
This is how I did it:
http://www.guangmingsoft.net/htmlsnapshot/html2image.htm
http://www.imagemagick.org/script/index.php
My program needs to output a (fairly complex) form to the printer, including several images. I’m currently doing this using Delphi (2006)’s Printer.Canvas, after selecting a PDF printer (PDF995). This works like a treat.
However, I’m now running into a problem: there’s one partially transparent image that needs to be placed on top of other elements (borders, background and such), with portions of that text still visible through parts of the image.
Doing this on a regular screen Canvas works fine with regular TBitmaps, by using the TransparentColor property. However, when I try to do this on a printer, it doesn’t always work; and when I try this on a PDF printer, it never works: the background turns black, or (the best result so far), turns white, but still overwrites anything underneath it.
I’ve tried achieving the same result by inserting a PNG image with alpha transparency (a.k.a. translucency) in a Word document, and then sending that to said PDF printer. The translucency disappears, but pixel transparency is maintained. So that, at least, should somehow be possible.
Anybody know how?
You mention you are using the TransparentColor property, so is it correct to say you don't really need alpha transparency and can get away with using binary transparency (transparency for each pixel is either off or on)?
If so, it might be possible to generate a Region from your bitmap.
You then use this region as a clipping region and draw the bitmap.
The PDF printer might be able to handle a clipping region correctly.
Here's an example of generating a region from a bitmap, it's used to make non-rectangular forms but the idea is the same:
http://www.delphi-central.com/BitmapShapedForm.aspx
Here is another example of setting a clipping region for your TCanvas:
http://www.efg2.com/Lab/OtherProjects/PrinterDemo2.htm
I don't think you can achieve partial transparency using a pdf printer. What you can do is get the VisPDF package. With it you can add a mask to the images contained in the pdf that you actually produce right in you're application. If this is not an option, you could combine all your background stuff in to one image. Drawing the alphachanneled thing on this image.
I also had this problem before, If I recall correctly, what I ended up doing was to create an off screen bitmap that I manipulated, then after I was done copied again and used the new bitmap copy on the canvas I was sending to the printer.
You may want to consider using a third-party PDF component in your application to render the canvas directly to PDF. I use this technique for specialized reporting (RTF, Radioemtric JPEGs, Tables, Text etc) in a commercial product I developed for Infrared Thermography. I am very happy with the performance and quality. The component I am using llPDFLib was just updated and I believe now supports full image transparency.
Best of luck. Printing images with an Alpha channel can be challenging at times in my experience.