Replacing aspose JRPptExporterParameter.PPT_TEMPLATE_PRESENTATION in jasperreports 5.0 - jasper-reports

I am generating a ppt report using jasperreports and aspose library (ppt exporter from aspose). I'm trying to eliminate aspose from the project and use the ppt exporter from jasperreports 5.0. The problem is that at the moment the generated report needs an external .pot file which is added using aspose:
com.aspose.slides.jasperreports.JRPptExporter exporter = new com.aspose.slides.jasperreports.JRPptExporter();
......
exporter.setParameter(com.aspose.slides.jasperreports.JRPptExporterParameter.PPT_TEMPLATE_PRESENTATION, pptTemplate);
exporter.exportReport();
I didn't find any similar parameter in JRExporterParameter from jasperreports and I couldn't find any efficient solution yet. Is there any method of using an external .pot file? I was thinking about creating a second JasperPrint object from the .pot file and then exporting both JasperPrint objects setting JRExporterParameter.JASPER_PRINT_LIST

Not sure if that fits for you, but I've written a custom PPTX Exporter (only pptx, not binary ppt), which is based on Apache POI. The POI element can be initalized by your own template pptx (not yet implemented in my version).
https://code.google.com/p/pptx-shape-exporter/
Drop me a line, if this sounds interesting to you.

Related

How to get VDX format from VSDX using Visio 2013 or higher?

Starting from Microsoft Visio 2013 support for VSD documents has been ended. Our App has a requirement to convert VSDX to VDX using Visio 2013 but I couldn’t find a way to do.
I tried to use Visio interop DLL to open invisible Visio App and tried to use SaveAs to save my VSDX as VDX. Code compiles and runs without any error and I get a .VDX file as output. When I try to view that generated VDX file using Visio viewer it fails. It says
Microsoft viewer cannot complete this operation
Wasn’t it generated as a healthy file?
We need to move away from Visio 2010 to Visio 2019. We would need to find a way to support both VSDX and VDX formats until all our apps are migrated. I have used below POC to convert .vsdx to .vdx or to convert .vsd to .vdx both of which dint work when i tried to view using Visio viewer . -
There were few articles where suggested me to use below POC to convert .VSDX to .VDX or to convert a .VSD to .VDX , both of which dint work. So .VSD to .VDX is not possible at all unless i use a Visio 2010 editor ?
// Create Visio Application Object
Visio.Application vsdApp = new Visio.Application();
// Make Visio Application Invisible
vsdApp.Visible = false;
// Create a document object and load a diagram
Visio.Document vsdDoc = vsdApp.Documents.Open(dataDir + "Drawing1.vsd");
// Save the VDX diagram
vsdDoc.SaveAs(dataDir + "SaveDiagramToVDXwithVSTO_out.vdx");
Link referred - https://csharp.hotexamples.com/examples/Microsoft.Office.Interop.Visio/Application/-/php-application-class-examples.html
The "Save-As VDX" feature was really-really removed in Visio 2013. Even from the API. If you call .SaveAs passing name with .vdx extension what you actually get is .vsd binary file, just with extension .vdx. You can make sure of that by simply viewing the produced file in notepad - it's not xml.
When you try to load that file in the viewer, it tries to parse it as xml, but fails, because file is actually a binary file, thus you get this error.
If you need to support .vdx, stick to Visio 2010.

How to set Jasper to use XSSF?

In a existing system already use jasper 5.0 and as I know it use poi HSSF to generate xls data, but now as the application grow up, the report have a problem with a big count transaction to generate.
I have search for the solution and found POI with XSSF. Because jasper use POI HSSF too, I thinking about to use XSSF inside of JASPER.
Is that possible? and how I could do that? I need to use jasper because it's not possible for now to change the existing app.
To export jrxml generating ooxml XSSF, excel file xlxs
Use the net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter
Example:
JasperPrint jasperPrint = JasperFillManager.fillReport(report, paramMap, connection); //Example of how to get the jasper print
JRXlsxExporter exporter = new JRXlsxExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
File outputFile = new File("excelTest.xlsx");
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputFile));
SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
configuration.setOnePagePerSheet(false); //Set configuration as you like it!!
configuration.setDetectCellType(true);
configuration.setCollapseRowSpan(false);
exporter.setConfiguration(configuration);
exporter.exportReport();
Naturally you need related libraries (poi-ooxml.jar, poi-ooxml-schemas.jar, xmlbeans.jar) in your classpath, they are present in the distribution of jasper report.
The JRXlsxExporter is available since version 4.5 this is the jasper report 5.5.0 API. In version 4 parameters where set instead of properties please see jasperreports-export-to-xlsx-not-xls

Combine two TCPDF documents

I'm using TCPDF to create two separate reports in different parts of my website. I would like that, in the end of the first report, the second report should be loaded.
It's different than import a PDF file, because the second report is also generated by TCPDF. Is there a way to do this?
I assume from your question that what you ultimately want to provide is one PDF file that consists of the first PDF concatenated with the second PDF.
One quick and dirty solution is to utilize the pdftk command line PDF processor and call it from within your PHP code using the exec() function. The pdftk command has many features and concatenating files is only one of them, but it does an awesome job. Depending on your hosting situation, this may or may not be an option for you.
The other option would be to use FPDI to import the two PDF files and concatenate them within your PHP code and then send the concatenated version to the user.
More information on using PFDI here:
Merge existing PDF with dynamically generated PDF using TCPDF
Given that you're already using TCPDF, importing the pre-existing file that you want to concatenate with the one you've just created shouldn't be too difficult.
Just add FPDI to your project/composer from:
https://www.setasign.com/products/fpdi/downloads/
Can you still used tcpdf.
FPDI support all the methods of tcpdf, just used new FPDI() instead new tcpdf() the result will be the same in your report, after you create your report marge the files with the code from this page:
https://www.setasign.com/products/fpdi/about/
In a loop, once set the first file and after this set the second...
If you will need help i am here for you.

Open a file from crystal report export to stream function

How can i open a file directly from stream which is exported through crystal report export to stream function? I am using vs2010 and sap crystal report.
MemoryStream m = (MemoryStream)(PReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
FileStream f = new FileStream(purchaseCombo.SelectedItem.ToString(),FileMode.Create,System.IO.FileAccess.Write);
byte[] bytes = new byte[m.Length];
m.Read(bytes, 0, (int)m.Length);
f.Write(bytes, 0, bytes.Length);
f.Close();
m.Close();
It depends on the file that you are exporting. Since Crystal Reports can export a number of different file types and each of them has a specific program that can handle it, you will need to search for the exact file type that you're interested. For example with a quick search on the internet, I found that a stream of an html file can be directly previewed inside a WebBrowser component (in a WPF app) by using the NavigateToStream method. Maybe there are some 3rd party components that expose methods for directly opening files from memory.
Though, the easiest way would be to export a temporary file to disk instead of memory by using the ExportToDisk method and delete it after its usage, since many components read from paths rather than memory. Before exporting the file, you can use the GetTempFileName method which creates and names a temporary file.

Regarding external-document in FOP

I am creating pdf file through the XML, XSL and FOP. I want PDF file contents to display external file contents such as word document.
I know for displaying image in PDF we use but what tag we should to display file contents other than pdf file type.
There's a FOP extension that claims to be able to do this:
jeremias-maerki.ch/development/fop/index.html
Also see xmlgraphics.apache.org/fop/1.0/extensions.html#external-document
When I used in this way
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
content-type="pdf" src="C:\temp\reports\p2.pdf"/>
I am getting exception as
org.apache.fop.apps.FOPException: Error(Unknown location): No element mapping definition found for fox:external-document
Let me know the reason.
THanks in advance.
I'd say you're probably using an old Apache FOP version which doesn't have the fox:external-document extension, yet. Please upgrade to FOP 1.0 (or at least 0.95).
Change the namespace from:
http://xml.apache.org/fop/extensions
to
http://xmlgraphics.apache.org/fop/extensions