Adjusting Print Page in ASP.NET - asp.net

I have some printed form on paper and want to create a web page (result of a report) and put those pre-printed pages in printer and print web page for fill the blanks on paper.
What is the best way to adjust the location of contents in the web page to work with any printer correctly?
thnx for your help

If you're just generating a regular html webpage to print, you're going to have a very hard time getting it consistent across multiple computers (or browsers, or printers). There are lots of browser settings that affect how the webpage is printed...like margins, header/footer text, etc. and these aren't things you can control from the html page.
You would need to generate a formatted file so there is less room for interpretation by the computer/browser/printer. Something like a PDF where you can create more consistent output.
I had a similar requirement for an app a while back. The requirements for that project were such that we generated a MS Word document prefilled with content (text, tables, etc.), then the user opens that generated file and prints it or saves it. I would think a PDF would be desirable in most cases though.

Related

Reading a PDF back from an iFrame?

I have a PDF document that is getting generated on the fly, and rendered on the fly to an iFrame within a radwindow. Basically the document is already largely prepopulated, however the user will still have a chunk of information that they are required to enter. I've found a good amount of information about sending a pdf TO an iframe, but not much information about going the other way. I have a button within the radwindow that can access the iframe object, however I'm somewhat lost as to where to go from there.
EDIT: The PDF is an editable form. I'm trying to pull back the entire PDF document as is, after the client side makes their entries to the form.
I think you'll need to send the file to the user so they can edit it locally and instruct them to upload it.
The content-disposition header with value attachment can help with the first task and you can use RadAsyncUpload to upload it: http://demos.telerik.com/aspnet-ajax/asyncupload/examples/overview/defaultcs.aspx.
I am not aware of ways to tap into the PDF viewer plugin the browsers use to show the PDF. Perhaps there is API from Adobe or some other third party plugin but that would rely on them and is out of your control.
Perhaps the JS PDF viewer from FireFox has something: https://mozillalabs.com/en-US/pdfjs/ but I don't know how stable and usable it is.
As per what was described in the comments, I ended up using postbacks through the PDF's themselves along with 1 pixel fields to store data required to identify the documents. It's a little hacky, but functional. I'm leaving this as an actual answer as this is as close to a real solution to the problem I originally had. This has been up and running for close to 4 years in this manner, and thus far hasn't caused any issues.

Export Catalog with images to PDF (using asp.net)

I'm working on a project that needs to export a serie of pages to a single PDF, it will have different pages, will be something like a PDF catalog.
In the past I already worked with reporting services using .rdl files to create the templates and export to PDF reports, invoices, etc. However this time it is a bit different, it will have different pages.
Cover
Big image (full page)
Index
Catalog (with images 2 or 3 images per line with descriptions in the bottom of each image) with a special header
Catalog same as 4 but the header will be different
will repeat 4-5 as many times as categories
Big image (full page)
Another image or other content
Back cover
Since it is not a typical Header/Report(body)/Footer thing I'm not sure what is the best way to go, I know there are a lot of ways of doing it but before I start I better see what options are there and what is the best way to do it.
Thanks in advance

asp.net-Online printing of the form

I am developing an online application in which I need to take a printout of the data entered in the form,but on that printed page,at right corner I am getting my page url (e.g. http://www.growmoney.com/print.aspx) printed.
I don't want it to be printed on the printout.
Is there any solution for this?
The address, date, time etc is typically added by the browser itself and can be configured by the user. How this is configured differs from browser to browser, instructions can easily be found. However, to my knowledge there is no way for an html page to influence those settings. Instead you could generate e.g. a PDF file of the form and let the user print that. This should give a more predictable print out. Alternatively you could explain to the user how to change the settings to not print the header and footer.
See also Disabling browser print options (headers, footers, margins) from page?

Generating PDF documents in ASP.NET [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Directly convert .aspx to .pdf
Is there any way to generate PDF document from asp.net directly from the page output. My requirement is, when user visits a page on my website, there should be a provision to get the same page / report in PDF format. Using iTextSharp, we need to built layout logic agin to generate PDF. If there are any changes in page output in future, I again need to work on logic to generate PDF. Instead I want to generate PDF directly from the page output just by setting "Response.ContentType" property.
One strategy I use is to develop reports using SQL Server Reporting Services. SSRS reports support export to PDF out of the box.
If you use SSRS 2008, you can even assign arbitrary HTML to a text box and the reporting engine will interpret it fairly well. This allows you to retrieve a snippet of HTML from any page, and present it in a report that will export to PDF without having to manually generate PDF document elements with iTextSharp.
If you go the SSRS 2008 route, check out this thread: http://forums.asp.net/t/1443965.aspx
I hope this helps.
Happy Coding!
You can set a button on your page that, if clicked, starts rendering a HTML page to PDF - only that the page you're asking it to render is exactly the page the user has clicked the button on. Once you got the PDF you can just send it in the normal way.
This of course requires a program that can render arbitrary HTML pages to pdf. You might want to check out ABCpdf which has always worked for me like a charm, but it's not free.
http://princexml.com/
They offer an application that converts html to pdf.
We use ActivePDF WebGrabber - which is designed to do exactly what you described. http://www.activepdf.com/products/serverproducts/webgrabber/

Relative Links in PDF

Need some advice on what course of action to take next.
Have written an ASP.Net application. Part of the application deals with being able to view PDFs. The initial PDF viewed acts as an index to access other PDF documents. You click a link in the Index PDF and it jumps to another PDF file. Legal documents, agreements, etc.
This scenario works on some computers and on others it doesn't. I managed to figure out what the problem was. On some of the computers the initial Index PDF was being hosted within the browser and on some other computers it was actually jumping out of the browser and directly into Adobe Acrobat. As soon as the PDF jumps out of the browser and into Acrobat the relative links in the Index PDF stop working because it is hosted client side via Acrobat but the additional PDFs it is trying to access are on the server.
I figured out why some computers stay in browser and why some jump out. There is an option within Acrobat itself that determines this behavior. It is under Edit--> Preferences ----> Display PDF in Browser.
I am in a jam because I am not in control of the PDF documents themselves and how they are written, and I obviously have no control over the options selected in Acrobat on each and every computer. My problem is also compounded by the fact that our firm has just recently purchased a new PDF reader called Nuance that will be pushed out firm wide soon and I don't think it even has the option to have PDFs hosted in browser.
I can get what I need to work if I create the index in HTML, but the problem is I don't write the Indexes and the people who do are not trained in HTML. I can get the people who write the indexes to change from relative links to absolute links, but then I run into the problem of what if we change where we are hosting the PDF files? All the links will break again? I think we are stuck with relative URLs, but how can I make it work?
I am thinking about maybe hosting the PDFs within Silverlight?
Looking for any thoughts or ideas?
Thanks.
Silverlight isn't going to help you here.
The solution really is in finding a better way to create the index document. Just how sophisticated is the index document content anyway?
If you don't want to have to train the authors of these indexes in HTML then can you provide them with a simple tool that they can use to describe the content. You could then have code server side to generate the HTML (even PDF) dynamically.
What you need is a simple redirector ASPX page whose URLs you can use in the PDF documents. Put the paths of the PDFs in a database. Give an ID for each PDF. The ASPX page should accept the ID as a parameter, do a lookup on the database, and response.redirect to the current location of the PDF. You can use URLs based on this ASPX page in the PDFs. If you keep database up to date, then the links in the PDF documents will always lead to the correct location.
In the Database
http://someserver/somepath/abc.pdf
ttp://anotherserver/apath/sdf.pdf
Links in the PDF documents
http://yoursite.com/pdf_redirect.aspx?id=1
http://yoursite.com/pdf_redirect.aspx?id=2

Resources