Printing the contents of a Form - forms

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.

Related

Birt eclipse duplex printing

I've been searching for an answer to this question. How can I print duplex or create double-sided PDF using BIRT + eclipse? I generate documents that contain multiple reports, and often the reports are multi-page. How can I force the header pages to always be "page 1" and avoid the next report from flowing onto the back of the previous report?
This isn't a BIRT topic.
When you say you print from BIRT, that's technically not the case. You create a PDF file with BIRT and print that file somehow.
Unfortunately the PDF file format does not support instructions to do a physical page break at a given logical page break.
So, unless you know at generation time if the resulting file will be printed duplex or not, there is no way to control this.
If you know that the file will be printed duplex in most cases, you might insert blank pages at certain places (maybe with a text "this page is intentionally left blank"), but this results in wasted pages if the file is printed single-sided.
Anyway, this still leaves you with two tasks:
1) Use a different Master Page when a new section of the report starts.
2) Finding out where to insert blank pages.
The first task is actually quite simple.
In BIRT, you can have different master pages (say, "first page" and "following page").
You can choose the master page to use in the properties of layout elements in BIRT.
Give it a try!
The second task is outside the scope of BIRT, you'll need some kind of PDF post-processing here. The idea is as follows:
Use BIRT to create a PDF file.
Use BIRT's TOC entry property to create a PDF TOC (also called Outline). This is the document structure shown on the left side if you open the file in Adobe Reader.
Use a PDF post processor (e.g. based on iText or whatever) to read the TOC entries.
Each entry has information about the page where it points to.
Now, if you want to print duplex and the entry starts on a even page (1-based), insert a blank page before this page.
It is possible, but will take at least a few hours of Java programming (or several days, depending on your experience with your chosen PDF processing tool).

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.

PDF to Jasper XML

I have a PDF file (softcopy) which was created using iText. Now my company decided to use JasperReports for new release. I need to use that PDF file (softcopy) and need to design JasperReports template and need to populate data.
Do we have any plugin in JasperReports that can convert from PDF to JasperReports JRXML or what do I need to do? Any suggestions?
A PDF is a description of how to render a document on a page. Things
like "draw a vertical line here", "write 'foo bar baz' here in
Courier". It does not contain any information about the format or
organisation of the stuff it is rendering. You won't be able to tell
that you're looking at a table, or a list of bullet points, or a
paragraph, or anything like that.
The PDF format does contain information on a page-by-page basis.
Therefore, page breaks are the one piece of format/organisation
information that you can find.
If you want anything more than a raw stream of completely unformatted,
disorganised text, one per page, you are out of luck. It's virtually
impossible.
from javaranch
You can use http://xmlprinter.com/ and then use a xslt to transform the resulted xml to the desired jrxml.
I'm working in it. If I finish it, i will post the result on github or any other public and open place.
Good Luck

Converting large amounts of text and dynamic data into PDF

I have a three page Word document that needs to be converted into PDF. This Word document was given to me as a template to show me what the PDF output should look like. I tried converting this document into PDF, created a PDF form and used iTextSharp to open the form, populate it with data and return it back to the client. This is all great but due to large amounts of data stored, the placeholders were insufficient and the text would be truncated or hidden.
My second attempt was to create an MVC 2 View without master page, pass the model to the view, take the HTML representation of the View, pass it over to iTextSharp and render the PDF. The problem here was that iTextSharp failed on some tags (one of them was <hr> tag). I managed to get rid of the problematic tag, but then tables were not rendered properly. Namely, the border attribute was ignored so I ended up with borderless tables. That attempt failed.
I need a suggestion or advice on the most efficient way to create a PDF document in MVC 2 which would be maintainable in the long run. I really don't want my actions to be 200+ lines long. Working directly with the Word document is not the best solution as I have never worked with VSTO so I don't quite know what it would look like to open Word and manipulate text inside of it and add dynamic data and then convert that dynamically into PDF.
Any suggestion is highly welcome.
Best regards!
One thing that I've done in the past is to save the Word file as a DOCX and unzip it since DOCX is just a renamed zip file. Within the archive open up /word/document.xml and you'll see your document. There's a lot of weird XML tags in there but overall you should get a pretty good idea of where your content is. Then just add placeholder text like {FIRST_NAME}, save the file and re-zip.
Then from code you can just perform the same steps, unzipping with something like SharpZipLib or DotNetZip, swapping placeholder copy, re-zipping and then using very simple Word automation to Save-As a PDF.
The other route is to fully utilize iTextSharp and actually write Paragraphs and PdfPTable and everything else. It takes a lot longer to setup but would give you the most control.
Q: you say "... but due to large amounts of data stored, the placeholders were insufficient and the text would be truncated or hidden"
How do you end up having to much data ? If the word template can "hold" the data in 3 pages, they should fit in 3 PDF pages.
I used to use iTextSharp to create my PDF's, but I also almost always ended up building the PDF document from scratch myself.(not really a <200 line solution) Have you considerate another library, I recently switched to MigraDoc's PDFSharp.Way simpler to use then iText, lotsa examples / docus
Just my two cents
Word documents object model is quite easy to understand. It will either contain series of Paragraphs or Tables. Using the Open XML SDK, you can iterate through each paragraph/table in the word document and retrieve it's content and styles. Then you can generate PDF document on the fly using those retrieved information. This will work under MVC too.
But if your word document contains complex elements, then it will take some more time for you to implement based on this approach. Also, this approach would only work with (Word 2007 and 2010) files.
Also, HTML to PDF options currently available in the ITextSharp library would work with only known set of tags, as far as I know.
Another suggestion is to make use of commercially available .NET components. There are lot of good solution available. For ex: Syncfusion

Printing GWT Cell Table

As part of a recent project, I have created a Cell Table that holds a few million rows of data. This data can be exported to CSV, filtered, and a few other basic functions. The last bit of functionality that I want to add, is the ability to print out the contents of the Cell Table to a local printer. I've done some research online (Google Groups and all the intro GWT material), but as far as I can tell there is no method to print a widget's contents -- specifically a Cell Table. Does anyone have an idea of how to go about setting something like this up (obviously I expect no code -- a description would be great!)?
There's an idea on how to print GWT widgets in this thread. The author of that post also placed his Print class in a Google Code project.
You can't directly use a printer interface from js code.
http://javascript.about.com/od/events/a/print.htm
Several webs have a button like "print version" which generates an HTML page with plain custom style.
example - http://www.alistapart.com/articles/goingtoprint/
You can also easily generate pdf versions in either client or server. PDF is quite a good way to let user print a document.
more info - https://stackoverflow.com/questions/1523851/gwt-printing-to-pdf