is there any way to disable file filter options in save button in the toolbar of jasperreport viewer - jasper-reports

I would like to know is there any way to remove pdf,xls in save button option files of type different formats so that i dont want to generate reports in pdf singlesheet-xls.
Generally the default save button files of type option comes with all the formats -pdf,singlesheet xls,embedded images,jrxml,multiplesheet xls,csv and other formats.
what i want is to disable pdf and singlesheet xls.is there any way to disable certain formats in ireport

This example removes all save options apart from Single sheet XLS and PDF:
JRViewer viewer = ... ;//your viewer
JRSaveContributor[] contrbs = viewer.getSaveContributors();
for (JRSaveContributor saveContributor : contrbs)
{
if (!(saveContributor instanceof net.sf.jasperreports.view.save.JRSingleSheetXlsSaveContributor
|| saveContributor instanceof net.sf.jasperreports.view.save.JRPdfSaveContributor))
viewer.removeSaveContributor(saveContributor);
}

Related

AEM Forms (PDF Type) File Attachments

I am trying to implement file attachment to my AEM Form. The idea is to embed the attachment to the PDF; Upon submission of the PDF, the backend system will be able to extract the attached file from the PDF.
I can't seem to find any example on how I can go about doing it, which make me wonder is it a limitation. However, on adobe site below, it is actually stated "Support for file attachments" for all AEM form types.
https://helpx.adobe.com/aem-forms/6/introduction-aem-forms.html
Please advice! Thanks!
You can upload, preview, and submit attachments with HTML5 forms. By default, the attachment support is disabled. To enable the attachment support:
1- Create a custom profile with mutiselect string property mfAttachmentOptions.
2- In the custom profile, specify properties fileSizeLimit, multiSelect, and buttonText to configure options of the file attachment widget. As required, you can also specify more custom properties.
3- In the custom profile, use the following configurations:
multiSelect -> true or false (true by default)
fileSizeLimit -> value_in_mb (say 5) (2 MBs by default)
buttonText -> Button text for pop-up window ("Attach" by default)
accept -> file types to accept ("audio/, video/, image/, text/, .pdf" by default)
4- Use the metadata editor to select the custom profile that you have created above for HTML 5 forms.
5- Render your form template with custom profile and the attachments icon would appear on the forms toolbar.
6- Click the attachment icon, an attachment selection dialog box appears. Browse and select the attachment and click Attach.
When attachments are enabled, HTML5 form submits multipart data. The mutli-part submission data has two parts dataXml and attachments.
Reference: https://helpx.adobe.com/aem-forms/6-1/html5-forms/enabling-attachments-html5-form.html
Below is the code for "Add Attachment" button.
var oDoc = event.target;
var doccount = parseInt(colhead.attcount.rawValue);
colhead.attcount.rawValue = doccount + 1;
Trusted_ImportDataObject(oDoc, doccount);
var oAttachment = oDoc.getDataObject("attachment_" + doccount);
var DOsize = oAttachment.size;
var DOmimeType = oAttachment.MIMEType;
if (DOmimeType == null) DOmimeType = "reject";
if ((DOsize > 1100000) || (DOmimeType.indexOf("image/") != 0)) {
xfa.host.messageBox("Attachemtns must be an image and smaller than 1 Megabyte");
oDoc.removeDataObject("attachment_" + doccount);
} else {
var attachPath = oAttachment.path;
AttachFileName.rawValue = attachPath;
AttachMIMEType.rawValue = oAttachment.MIMEType;
AttachHref.rawValue = oAttachment.name;
}
Do note that Reader Extension is needed to enable file attachment. Else you will be getting this error:
NotAllowedError: Security settings prevent access to this property or method.
Doc.importDataObject:6:XFA:CTR[0]:Page6[0]:part6[0]:body[0]:attachitem[0]:AddAttachment[0]:click

Cannot retrieve the fields name from form PDF using pdftk

When I try to using
pdftk my.pdf dump_data_fields >result.txt
have empty data result
Your file my.pdf may not be compatible with pdftk. Convert the file first using the following command:
>pdftk my.pdf output my_converted.pdf
Then try,
>pdftk my_converted.pdf dump_data_fields > result.txt
I've taken this from the following http://www.fpdf.org/en/script/script93.php where the converting process is suggested when the fields won't write to the pdf file so converting before dumping the fields may not help.
If your pdf has fields you it should be fillable in your pdf viewer. If in isn't fillable then it would seem that it has no fields.
This is most likely because the pdf you are using doesn't have any data fields to dump! Use a tool like Adobe Acrobat to open the pdf, go to wherever you need to to Edit Fields, and add fields anywhere you need them to show up. Make sure they are named so you can utilize them by using the attributes[] call in pdftk.
I recommend using snake case (i.e. text box named 'first_name') and then you should have access to it using attributes[:first_name] = 'your text'.
Hope this helps, let me know if you have any other questions/issues.

Rich Text Content Fields with iTextSharp

I'm using iTextSharp to create pdf files on the fly for my users to save on their computers. Currently the way it works is that I had several pdf templates that iTextSharp opens, sets fields from the database and save on user computer.
I'm having real problems with adding rich content into the body field which the users enter using a Rich Text editor (NiceEdit). It contains really simple options such as bullets, bold, italic, font colors, sizes etc. which is all what they need. I tried all possible options out there but nothing seem to help.
PdfReader reader = new PdfReader(originalReport.ToString());
PdfStamper stamper = new PdfStamper(reader, new FileStream(report, FileMode.Create));
AcroFields fields = stamper.AcroFields;
fields.SetFieldProperty("body", "setfflags", PdfFormField.FF_RICHTEXT, null);
fields.SetFieldRichValue("body", bodyValue.ToString());
fields.GenerateAppearances = false;
I tried flattening the form but it doesn't display the field at all. If I didn't flatten the form then the field displays the content but with no format at all (even new lines are removed) and if I used the SetField option instead of the SetFieldRichValue I get a string of the html content
I also tried allowing the pdf template field to "Allow Rich Text" from acrobat pro but this gives an exception and halts the pdf :)
Also please note that since I'm using a template that depends on the type of the user, the SetField option is used, I don't create the document from scratch hence I don't use paragraphs which I can get if I used the HTMLWorker and simply add to a document
Any help please?

Crystal Report: export to excell generates "page break", column header is reapeated

Trying to export a report to excel, the generated document has kind of page break. The column header is repeated. The "page break" are in the same positition than if I generate a PDF report.
How can I remove this page break when exporting to excel? Is there some page size definition?
Have you tried ExportFormatType.ExcelRecord instead of ExportFormatType.Excel? The xls file will be created without formatting.
If actually the user is exporting report using ReportViewer Toolbar Export button you can:
Replace the CrystalReportViewer Control with the ReportExporter Control. It will export the report in the format you choose.
Or hide Export button from toolbar and put in the page buttons that exports programmatically
Call ExportToHttpResponse method
CrystalReportSource1.ReportDocument.ExportToHttpResponse(ExportFormatType.ExcelRecord, this.Response , false, "report.xls");
Call ExportToDisk method
reportDocument.ExportToDisk(ExportFormatType.ExcelRecord, "report.xls");
Export dataset to excel (Look at Ahmed answer)
You can choose the way that best fits your needs, but you must try if it works with the runtime you use either in development or in release server.
ExportFormatType.ExcelRecord means that is generated an xls file, without formatting. If you set ExportFormatType.Excel fields that are marked as "Can Grow" are merged with an otherwise blank row below them.

How to add content control in a Word 2007 document using OpenXML

I want to create a word 2007 document without using object model. So I would prefer to create it using open xml format. So far I have been able to create the document. Now I want to add a content control in it and map it to xml. Can anybody guide me regarding the same???
Anoop,
You said that you are able to creat the document using OpenXmlSdk. With that assumption, you can use the following code to create the content control to add to the Wordprocessing.Body element of your Document.
//praragraph to be added to the rich text content control
Run run = new Run(new Text("Insert any text Here") { Space = StaticTextConstants.Preserve });
Paragraph paragraph = new Paragraph(run);
SdtProperties sdtPr = new SdtProperties(
new Alias { Val = "MyContentCotrol" },
new Tag { Val = "_myContentControl" });
SdtContentBlock sdtCBlock = new SdtContentBlock(paragraph);
SdtBlock sdtBlock = new SdtBlock(sdtPr, sdtCBlock);
//add this content control to the body of the word document
WordprocessingDocument wDoc = WordprocessingDocument.Open(path, true); //path is where your word 2007 file is
Body mBody = wDoc.MainDocumentPart.Document.Body;
mBody.AppendChild(sdtBlock);
wDoc.MainDocumentPart.Document.Save();
wDoc.Dispose();
I hope this answers a part of your question. I did not understand what you ment by "Map it to XML". Did you mean to say you want to create CustomXmlBlock and add the ContentControl to it?
Have a look for the Word Content Control Toolkit on www.codeplex.com.
Here is a very brief explanation on how to do what you are attempting.
You need to have access to the developer tab on the Word ribbon. To get this working click on the Office (Round thingy) in the top left hand corner and Select Word Options at the bottom of the menu. On the first options page there is a checkbox to show the developer toolbar.
Use the developer toolbar to add the Content controls you want on the page. Click the properties button in the Content controls section of the developer bar and set the name and tag properties (I stick to naming the name and tag fields with the same name).
Save and close the word document.
Open the Content control toolkit and then open your document with the toolkit. Use the left hand pain to create some custom xml to link to your controls.
Now use the bind view to drag and drop the mappings between your custom xml and the custom controls that are displayed in the right panel of the toolkit.
You can use the openxml sdk 1.0 or 2.0 (still in ctp) to open your word document in code and access the custom xml file that is contained as part of the word document.
If you want to have a look at how your word document looks as xml. Make a copy of your word document and then rename it to say "a.zip". Double click on the zip file and then navigate the folder structure. The main content of the word document is held under the word folder in a file called "document.xml". The custom xml part of the document is held under the customXml folder and is generally found in the file named "item1.xml".
I hope this brief explanation get you up and running.