Auto print with MigraDoc / PdfSharp - pdfsharp

Porting some code from iTextSharp to PdfSharp. In iTextSharp we did this to make the print dialog automatically open when the pdf document is opened in a web browser:
pdfW.AddJavaScript(PdfAction.JavaScript("this.print(true);\r", pdfW));
where pdfW is a PdfWriter
I found this where one of the answers shows opening an existing file with PdfSharp and adding the "open action".
Generate a PDF that automatically prints
I would like to add the open action using MigraDoc to the pdf as its generated. I am using MigraDoc because its at a higher level than PdfSharp. (sections, paragraphs, etc) instead of drawing text and lines)
Also, the pdf is displayed to the user in a browser. Its being sent from an ASP.NET application where the response is the pdf file.

MigraDoc uses PDFsharp to generate the PDF file. You will have to use PDFsharp for special requirements like yours.
You can make the changes after rendering the PDF file with MigraDoc, but before saving it, so the file will be saved only once.
Use the PdfDocument property of the PdfDocumentRenderer class.

Related

Is it possible to convert an html page to a pdf with asp.net?

I want to generate pdf of my webpage. Is it possible? if not then what can be done to get a pdf form which has the data from the database.
Depending on what you need this for, you can create a PDF via the Print menu in Chrome (Save to PDF is a "printer").

Generate PDF file from HTML string in asp.net with vb

I want to generate PDF file from HTML string and that PDF file I have to attach in mail using asp.net. I try ghtmldoc.exe, it will generate corrupted pdf file.
I also use iTextsharp. It generate PDF without format though I don't use CSS in that HTML page. Only data in html file is converted in PDF.
I've always found Winnovative HTML to PDF converter very useful for doing things like this:
http://www.winnovative-software.com/Html-To-Pdf-Converter.aspx
You can either specify a URL to convert to PDF, or specify a HTML string to convert to PDF instead.
An open source solution, would be iTextSharp:
http://sourceforge.net/projects/itextsharp/
Exporting to pdf is really made simple by telerik. check this link. Telerik has a good look too. so if you are not late to change over to telerik, i suggest do that.

Display Word Document inside ASP.Net page

I want to display a word Document, which is sitting on my IIS. I want to display the whole document as is, inside a iFrame on my aspx page.
I know I can use MS Word Libs, but I cannot install Word on Server where application will be hosted, (Correct me if I am wrong: I cannot use just dlls without installing MS Word on Server).
How can I display the word document in my iFrame?
Probably the easiest way would be to include the Google Docs Viewer.
Other ways could be to use Aspose.Words (commercial) to convert Word to PDF and then use Aspose.Pdf.Kit to convert PDF to images and then display the images online.
PowerTools for Open XML contains an open source, free implementation of a conversion from DOCX to HTML formatted with CSS. The module HtmlConverter.cs supports all paragraph, character, and table styles, fonts and text formatting, numbered and bulleted lists, images, and more. See http://bit.ly/1bclyg9

Allowing a user to sign pdf file in asp.net

i have a pdf file and want to allow user to upload a gif file of their signature and display the signature in my pdf file...
pls follow the link
http://support.persits.com/pdf/demo_fill.aspx
http://www.asppdf.com/livedemo.html -> template fill out
You can use iTextSharp to insert an image in a PDF. See the example: iTextSharp - Working with images.

Using PDF In .Net App

Can someone point me to some code/tutorial on how to upload pdf files and store them, then moreover how to use a pdf reader to display the file as read only in an asp.net application.
Is there a PDF reader already in the visual studio toolbox?
The approach I would use in this situation is to upload the PDF as you would any other file, then use a tool like GhostScript to convert the PDF pages into image files that you can show in ASP .Net.
Here's a tutorial doing that in C# http://www.codeproject.com/KB/cs/GhostScriptUseWithCSharp.aspx
Adobe provides (on acrobat.com) a free service which provides you with the ability to upload pdf (and also other types like doc...) and then embed a nice flash interface for displaying the files on your page.
It's pretty helpful as you can store some 5 gigs of files here.
But if you want to let the users upload their own files then this won't help you.
PDF is a final format file, ie its is read-only for the most part and can be embedded into the page via the <object> tag, except if you mean downloadable by the user.
Displaying PDF is generally done by rasterising to an image format for display (ie as an image on the page or via a richer interface (with zooming etc) through flash/silverlight etc.
You can use [GhostScript][1] to interpret PDF files and convert them to an image.
[1]: http://www.GhostScript .com
Uploading a PDF is just like any other file. Use the ASP.NET file uploader control:
http://www.codeproject.com/KB/aspnet/fileupload.aspx
In order to view the PDF in an ASP.NET application, you could either depend on Acrobat being there or use a PDF Viewer control.
The company I work for, Atalasoft, sells a PDF Reader add-on to our web viewer controls. You can learn more here: http://www.atalasoft.com/products/dotimage/pdf-reader

Resources