Generating PDF with Print button on .NET - itext

I have a requirement to dynamically generate a PDF document from HTML that includes a button that will trigger the PDF print dialog, when viewed in either a browser or Adobe Acrobar Reader, or any program that displays PDFs.
I currently use iTextSharp.XmlWriter, not sure if it is possible to achieve with that, or any other lib, like Pechkin?

Related

How to restrict your content in only one page in pdf using itext?

I'm trying to generate pdf using itext libs and I want to prevent page break. I want all my content in single page pdf only. How to achieve this?

IText Pdf - RadioBox(On/Off) not appearing for some pdf

In our application we are using Itext Pdf 5.5.3 library.
We have checked with some of the pdfs in which Checkboxes displayed correctly(check/uncheck) .
However there are some pdf with RadioBoxes and do not display radiobutton(on/off) correctly.
I also use this link to validate pdfs and java code
String[] values = form.getAppearanceStates("Checkbox");
return null values.
Also tried Itext RUPS and found that pdf which are working shows Form Field Names in RUPS Form Tab. And PDfs which are not working do not display form fields.
I tried generating pdf from word document and it doesn't display form fields in RUP , neither I can check/uncheck checkbox in Adobe Acrobat Reader.
What could be the solution to display radiobutton with check on / off ?
Edit -
I had created sample web application to reproduce the issue.
Please setup attached web application and let me know the fix for the issue.
Please download from this link
You have successfully discovered the difference between interactive PDF forms and "flat" PDF documents that look like a form to the human eye, but that aren't interactive forms.
To make the "flat" forms interactive, you need to open those flat documents in PDF editing software (e.g. Adobe Acrobat) and you need to add a form field manually.
You can ask Acrobat to guess where it should add fields, but Acrobat will be wrong in many cases for obvious reasons. You always need a human if you want it to be done correctly.
As for creating an interactive PDF from Word... Forget about it. Use OpenOffice or LibreOffice.

Printing the contents of a Form

I have a form with some comboboxes, a datagrid and an image. My ultimate goal here is: When the user clicks the save button on a menustrip, it will send this data to a printer (preferably to a PDF one) and print the file ready to be mailed to our clients. I tried the code provided by:
http://msdn.microsoft.com/en-us/library/aa287529%28VS.71%29.aspx
But it sent me to OneNote which then showed me an empty file. I also tried Printform and PrintDialog which didn't bring me much luck either. Any suggestions?
edit: I configured it to print to pdf although it now prints only half the form (cuts it in half of width), and if the datagrid is Scrollable it only prints the data that is showing on the screen. Like this:
You cannot print scrolled data using graphics object. even you cannot create your own design using graphics object. Also, you will get some problem in creating PDF and managing multiple pages. So, don't make it more complicated just use reporting library. You have two choices to print form data into pdf file.
Microsoft Reporinting
Crystal Report
But, I would like to prefer to use Crystal Report to Print any document. It is more flexible than Microsoft Reporting. You can export that document into PDF, WORD, EXCEL or Direct to Printer.

Is it possible to attach file while filling in Adobe Forms pdf?

I know that forms in .pdf made by Adobe Acrobat can act like questionnaire or application blank for filling input fileds and saving results, but is it possible in a way to add more interactiviry to them
- add file upload or attachment to resulting document?
It's kind of possible.
You'll need to add Javascript code to your documents. The code should show Browse For File dialog and import selected file to the document. Please have a look at Import Named File Attachment script (at the bottom of the page). I doubt that this solution will work in Adobe Reader or alternative PDF viewers, but Acrobat Professional should do the trick.
Another solution is given is this thread on Adobe forums:
...I figured out a roundabout way to attach files in adobe reader (not
the full blow adobe acrobat reader). Via Adobe Acrobat 9 Pro I
created a blank form with the "comment/mark up" tools enabled. Then I
merged that file with the other PDF form that was formatted with
fields, radial buttons etc. I had to create the blank form for the
attachments separately because if I tried to enable the "comment/mark
up' tool on the form with fields and radial buttons it disabled the
fields. ... The comment markup tool then allowed me to attach files
via the "attach file as a comment" option.

In iphone development, is it possible to evaluate a javascript string using a webView in which a PDF is loaded?

I have loaded a PDF into UIWebView. Now i want to search for strings in that pdf. So I used a string which contains JS steps(used to highlight that specific string) and evaluated it with the webView object like this. But no result was obtained .It was as if nothing had been done.
Dont the JS evaluation work on a pdf loaded into a webView? Is there anyother way to search for a string in a PDF loaded into webView?
Even if you could evaluate JS against a webview that is currently displaying a pdf, the pdf render has no exposed or documented APIs. If you have code that works on HTML then it is not working because the PDF is not exposing an HTML like dom. If you have code that works in the acrobat plugin on a desktop then it won't work because the phone uses a derivative of Apple's Webkit PDF plugin which does not export the same API as Acrobat (as far as I know it exports no API, and if it does it is undocumented). In any event, regardless of why you think your code should work, it won't.
If you want to find a string in a pdf you are going to need to write code to parse the PDF and find that string, and even then you will not be able to highlight the specific string in the webview based renderer.
If you want this sort of functionality you should should use Quartz to directly render your PDFs onto views. Apple provides documentation for how to do that.