Hide or insert image (logo) in pdf using iTextSharp - asp.net

We print pdf provided by the company and merged it with data from our C# ASP.Net 3.5 Web application using iTextSharp. This works well but we have been asked to either print the form with or without the company logo depending on the user preference.
Should I use a pdf with the logo and hide it or use a pdf without the logo and add the logo to it?
I have found numerous way to add a logo to a pdf but nothing on hiding images. Because the logo could be having different size and be in a different location I would prefer to hide it when needed instead of adding it. Can we hide images from pdf without removing it? What would be easier?
Or should we just use 2 versions of each forms, one with the logo and another without?
UPDATE: In a nutshell I just want to have your opinion to what way would be best. Use a form without a logo and add it when needed or use a form with the logo and hide it when needed. Thanks
FINAL UPDATE: Some people gave good answer but I see no way to accept their answer. Can someone help me?

Because no one answered my question I selected one of the comment as "the" answer. Thanks mkl!
You can store data private to your application in PDFs, e.g. logo size and location in the case at hand (cf. this answer on PieceInfo structures). I would, therefore, recommend that you create the PDFs without the logo but store the size and location for a logo in such a PieceInfo dictionary. If adding a logo is required later-on, use that information to properly place the logo

Related

Inserting text below image on download

I have a collection of images that a client can download should they desire. However, the boss came to me with a requirement to try and add text at the bottom of image. Unfortunately due to space constraints on the server, I can't simply use Javascript to add the information to the bottom of the page when it is uploaded.
Ideally the format should two rows with two cells each. Any help on this would be appreciated.
I believe this is what you are looking for.
http://mvark.blogspot.com/2004/12/code-programmatically-add-text-to.html

Resizing the Tumblr Like button?

I am using a Tumblr like button provided by ThinkingStiff on like-button.tumblr.com and am having some problems.
I don't know if this is the right place to ask this question, but I couldn't contact ThinkingStiff through his like-button tumblr so this seemed like my best shot. First of all, I'd like to thank him for his codes on how to add a Like and Reblog button to any theme. I am using them on my blog over at shelteryou.tumblr.com and they are working wonderfully. However, as you can probably tell, the like button is a bit too big for my theme. I was wondering if there was a way to shrink it down to a more suitable size? Thank you in advance!
They use a background-image, so if you want to have a different size, you'd have to change the image resolution (or create a new image) in your favorite image editor. Then upload it to Tumblr (they provide a upload service for theme files only) or make a data URI out of it.
Then change the URL in background-image: url(…) to the new one (the first for the grey image, the second for the red one).
If you need the current images (so you can save them), copy/paste the two data URIs (everything inside the brackets) to your browser address bar.

how to merge two images into one with asp.net

I am working on an asp.net project. I am searching for a solution such that after a background image of a div is chosen. The user selects another image and coordinate. Then, this image will be merged on the background image with the defined coordinate.
Thanks in advance.
If you wish to combine two images,firstly you must upload them into server via ajax requests.
Read this article : combining images
After you combine them,let the user download the new one.
Also if you're looking for an editor to do so,I suggest to place them on html5 canvas.
Best Regards
Your post is quite general, but look in to System.Drawing and using an AJAX call to post both images (as well as the coordinates chosen) and then return the combined image which can then be displayed.
Without more specifics that's really all I can offer.

How to render Html to image format? [duplicate]

I'm generating a coupon based on dynamic input and a cropped image, and I'm displaying the coupon using ntml and css right now, the problem is, printing this has become an issue because of how backgrounds disappear when printing and other problems, so I think the best solution would be to be able to generate an image based on the html, or set up some kind of template that takes in strings and an image, and generates an image using the image fed in as a background and puts the coupon information on top.
Is there anything that does this already?
This is for an ASP.NET 3.5 C# website!
Thanks in advance.
edit: It'd be great if the output could be based on the HTML input, as the coupon is designed by manipulating the DOM using jQuery and dragging stuff around, it all works fine, it's just when it comes to the printing (to paper) it has z-indexing issues.
What you can do is create an aspx page that changes the response type to be in the format you want and then put the image into the stream. I created a barcode generator that does a similar thing. Excluding all the formalities of generating the image, you'll Page_Load will look something like this:
Bitmap FinalBitmap = new Bitmap();
MemoryStream msStream = new MemoryStream();
strInputParameter == Request.Params("MagicParm").ToString()
// Magic code goes here to generate your bitmap image.
FinalBitmap.Save(msStream, ImageFormat.Png);
Response.Clear();
Response.ContentType = "image/png";
msStream.WriteTo(Response.OutputStream);
if ((FinalBitmap != null)) FinalBitmap.Dispose();
and that's it! Then all you have to do in your image is set the URL to be something like RenderImage.aspx?MagicParm=WooHoo or whatever you need. That way you can have it render whatever you want to specify.
You can render html to a bitmap using the WebBrowser control in either a winforms or console application.
An example of this can be found here: http://www.wincustomize.com/articles.aspx?aid=136426&c=1
The above example can be modified to run in ASP.Net by creating a new STAThread and performing an Application.Run on it to start a new message loop.
PHP/Ruby Alternative
If you have accessed this question and are actually looking for soething that will work without Windows, you can try the KHTML library: http://wiki.goatpr0n.de/projects/khtmld
The website has a ridiculous name I admit, but I can assure you it is genuine. Other related pages are: the sourceforge page http://khtml2png.sourceforge.net/
Try PDFSharp...it's not exactly a "take this HTML and make a PDF" but with a small amout of fiddling you can easily make a PDF out of the info you are using to make the HTML.
MARKUP ONLY ALTERNATE SOLUTION
Use SVG and XSLT to transform the html data into an image that can be rendered/saved/etc.
I'll admit that at first it was tedious getting this to work because of all of the coordinates, but well worth the effort once it is running.
There is a very powerful image creation library called GD which I often use with PHP.
I am led to believe there is a wrapper for this library that ASP programmers can use. Try this
Unless the "other problems" are pretty severe, couldn't you just instruct your users to turn on Background Images when printing?
In any case, I'd default to serving a PDF rather than an image, doubly so since it is intended for print.
Just set up your css properly, so that you have a css file targeted at the print medium. It is pretty easy to guarantee that the coupon will always be legible, without worrying about whether they have bg images on or not. Needlesly moving to an image doesn't make any sense, unless there is some reason you don't want it to be machine readable.
I haven't tried to myself, but you should be able to render HTML into an image by using the WebBrowser control and the DrawToBitmap() method inherited from the base Control class.
UPDATE: I tried this myself and there are some caveats. The WebBrowser control doesn't seem to render the web page until the control is show, so the WebBrowser needs to be in a Form and the Form must be shown for the HTML to be rendered and the DocumentCompleted event to be raised.

How to create Multiple images with hyperlinks

I have a psd image with me. This image has been created combining multiple images. I want that each of this multiple images must have a seperate alt tag and a hyperlink. When the user clicks on it, he/she should be taken to the that url.
How can I do it. Please suggest me all options like open source or online tools etc.
Take a look here: Medialab's SiteGrinder. This is a PS plugin which transforms your PSD into a working webpage, I use it for prototyping and to figure out px distances and such, there are services out there too, but have a look at this tutorial too.
Hope they help.

Resources