I'm using Crystal Reports to generate report definition *.rpt files. I later create reports using those definition files from inside my application.
I have a special image called the logo that sits in my application's file directory. I'd like to reference this logo on my crystal report. The logo is always located a couple directories up from my report, but the root directory and the host computer can change between installations, so the file structure could look like this:
image: c:\files\logo.png
report: c:\files\reports\type1\myreport.rpt
or like this:
image: \\filehost\files\logo.png
report: \\filehost\\files\reports\type1\myreport.rpt
Does Crystal have a way to reference this image in a formula with a relative path? Does the .rpt file contain a reference to it's file location that I could build off of to grab this image?
Edit: #campagnolo_1 mentions that Crystal has a "File Path and Name" special field, but I don't see a way to use that in the image file location script.
Edit 2: #campagnolo_1 has provided a solution in the comments on his answer. Thanks campagnolo_1!
Crystal has a special field for the file path and name. You could use that to find out where the report file is located and extract the path if needed. Then you can use that to dynamically reference your image file. Here is a post with some step-by-step instructions.
I always stream my logos in as part of the underlying data that the report is bound against. I add the column to the dataset by doing something like this:
DataTable dt = GetYourDataTable();
dt.Columns.Add(new DataColumn("imagepath", typeof(string)));
dt.Columns.Add(new DataColumn("image", typeof(System.Byte[])));
ds.Tables.Add(dt);
And populate it with:
using (FileStream fs = new FileStream(szFilePath, FileMode.Open))
{
using (BinaryReader br = new BinaryReader(fs))
{
foreach (DataRow dr in _dtReportData.Rows)
{
dr["imagepath"] = szFilePath;
dr["image"] = br.ReadBytes((int)br.BaseStream.Length);
}
}
}
I know it's redundant to set EVERY ROW, but it does work, and the object can just be added to the report as a Blob.
The big advantage for you would be that the image location is arbitrary.. you only need to know it at data-retrieval time, not at report-rendering time.
Related
So I have a little silly problem. I have a groovy script that reads all files in a folder and then manipulates the files in such a way to output the file names for the user to select the correct one in the live template variable. My problem is that the auto suggestion list only displays 1 item and not multiple items to select from in the IDE.
Here is the live template setup:
This is the output:
This is what I want (without using enum()):
This is the piece of code:
groovyScript("import static groovy.io.FileType.FILES;def curPath = _editor.getVirtualFile().getPath().split('/src/')[0];def dir = new File(curPath+'/src/partials');def files = [];dir.traverse(type: FILES, maxDepth: 1) { files.add(it.toString().replace('/src/partials/','').replace(curPath,'').replace('.html','')) }; return files;",methodParameters())
Please help... Since google searches does not yield any proper answers.
As of IntelliJ IDEA 2018.3, the groovyScript() feature does not support generating a list of suggestions. It can only be used to calculate a single suggestion which is then inserted into the editor.
I am using File[] imageFile = PdfUtilities.convertPdf2Png(new File("MYPATH")) command to generate png from pdf , which is giving file name as "workingimage01","workingimage02"...."workingimage0n" and so on, is it possible to change this name setting by the time png's are generated. Thanks in advance.
I am trying this command for 10 pdf parallel, so it is overlapping. thats why i need to know is there a way or i am asking out of the box question.
The name is hard coded in the source. You can create an overloaded method that takes another parameter for the working files' name.
I am running into trouble with tons of paperwork. I want to have it digitalized in order to simplify search and therefore cut down a huge amount of time spent on looking though the paperwork.
It is rather simple, I want to scan documents, which share the same layout and rename it according to 3 areas within the document. In my case its a reference number, a Last name and the date listed on the document. It would be even better if it could move the files to folders named after an area in the document.
Here is an image, basically this but with hundreds of pdfs in batch.
http://i.imgur.com/8vwwyEb.png
I couldn't find any solution for days and yet the technology is there. Have you ever gotten across a problem like this and found a solution? I would really appreciate your help.
The closes thing I have found is a program called FileCenter, but you need to click a button for each scan. Using ocr on existing files require you to go through a 3 click menu for each file. I wonder if there is an easy batch program, where you just select the rectangles and it does the renaming part.
I will edit this OP if any solution can be found, for anyone googling.
You may do this with the commercial component ByteScout PDF Extractor SDK designed specifically for this purpose. It may extract text from a given region by coordinates with optional OCR (that also works in the selected extraction region) in a batch. Coordinates of the region to extract text from can be measured in the base document with PDF Multitool free utility (asssuming all your PDF files are using the same layout).
You may extract text from given regions in C# like using OCR (English language):
using System;
using System.IO;
using System.Text;
using Bytescout.PDFExtractor;
using System.Drawing;
using System.Diagnostics;
namespace Example
{
class Program
{
static void Main(string[] args)
{
// Create Bytescout.PDFExtractor.TextExtractor instance
TextExtractor extractor = new TextExtractor();
extractor.RegistrationName = "demo";
extractor.RegistrationKey = "demo";
// enable OCR auto mode, will use English by default
extractor.OCRMode = OCRMode.Auto;
string sourceFile = "sample.pdf";
// Load source PDF file
extractor.LoadDocumentFromFile(sourceFile);
// extract from given area (measured from base typical file using PDF Multitool utility), assuming we have a reference string there
extractor.SetExtractionArea(Rectangle.FromLTRB(10, 10, 100,100));
string extractedReference = extractor.GetTextFromPage(0).Trim();
extractor = null; // dispose the extractor and release the original file
// Copy the original file into the file with filename based on the original reference so it will be like "1234-sample.pdf"
string outputFile = extractedReference + "-" + sourceFile;
File.Copy(sourceFile, outputFile);
Console.WriteLine();
Console.WriteLine(inputFile + " has been copied to " + outputFile);
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
}
}
Disclosure: I'm connected with ByteScout
I want to fetch image from local path (i.e: C:/Users/myname/sample.jpg).
Already tried with image icon on left of the form and set the value from the above both but the thing is i need to set the image from external . Like property file or kettle file.
please help me on this.im using Pentaho Designer 5.3.0
thanks in advance
If you want to get the location of the image from a property file, you have to think about how to get that value and take it to the report, that you can do with a kettle transformation, that takes the value you want from the properties file and send it to a Report, in the pdi there is a step called Pentaho Reporting Ouput, which makes a call to the report, to this you will pass as parameter the location of the image that you want to be displayed (the name of the parameter in the pdi and in the Report designes must be the same), you can do the following:
Create a parameter, which will be of type string, this will be the parameter will receive the location of the image on the disk
Add an image field instead of an image, and pass the parameter you created as a value
After you can upload the image you want, just pass the physical address to the report from the pdi.
I hope I help you
I need to make a bunch of redirect pages as I've recently updated my web site which previously used .html files and now all the files are .aspx. I have a tab-delimited file containing a list of original filenames and the corresponding new filename.
It seems like there should be a language out there that I should be able to create a file using the first column for the filename and insert the second column as its content with some additional text for the 301 redirect.
Could someone point me in the right direction as to what language(s) would be able to accomplish this? Also, if you could also point out the name of the method/function I would be using so I know where to begin when creating the file.
I've needed to do this type of thing many times and am willing to learn a new language (Perl, Python, or whatever) to accomplish this, but I just need pointed in the right direction. I am using Windows XP to develop on.
Thank you for your time.
This can be done in a few lines of C# if you already are working with aspx you can process this in the codebehind on a dummy page.
System.IO.StreamReader myreader = new System.IO.StreamReader(Server.MapPath("~/Text.txt"));
while (!myreader.EndOfStream)
{
//9 is Ascii value of Tab bad idea to split if the second set of values might contain tabs but can reconstruct the data if inputString.length >2
string[] inputString = myreader.ReadLine().Split(char.ConvertFromUtf32(9).ToCharArray());
//construct the path to where you want to save the file, or if the filename is the full path all the better
System.IO.StreamWriter filemaker = new System.IO.StreamWriter(#"C:\" + inputString[0]);
filemaker.Write(inputString[1]);
filemaker.Close();
}