Forked and rebased from https://github.com/majorsilence/CrystalCmd to meet custom needs.
1.6K
Forked and rebased from https://github.com/majorsilence/CrystalCmd to meet custom needs.
If you are looking for a production crystal reports server look into SAP Crystal Server.
CrystalCMD is a C#/dotnet and Java program that loads JSON files into Crystal Reports to produce PDFs. Initially an experimental proof of concept, it demonstrates generating Crystal Reports on Linux using Java and .NET framework (wine).
The main focus is the c#/dotnet implementation running within Windows/IIS and Linux/Wine.
Key Features:
CrystalCMD is developed with the following work flow:
Note that, when using the command line option, this is very slow and highly recommended to use the server option.
test server: c.majorsilence.com
Example running from base CrystalCmd folder.
curl https://c.majorsilence.com/status
curl -u "username:password" -F "[email protected]" -F "reporttemplate=@the_dataset_report.rpt" https://c.majorsilence.com/export --output testout.pdf
# test localhost
curl -u "username:password" -F "[email protected]" -F "reporttemplate=@the_dataset_report.rpt" http://127.0.0.1:4321/export --output testout.pdf
Majorsilence.CrystalCMD.postman_collection.json
Use this project to generate test data from c# program
See Crystal Reports, Developer for Visual Studio Downloads.
Download the Crystal Reports .net runtime from: https://origin.softwaredownloads.sap.com/public/site/index.html
Majorsilence.CrystalCmd.NetframeworkConsoleServer
See the dotnet/Readme.md file for more info..
flowchart TD
subgraph "Client Applications"
A[".NET Application"] --> C["Majorsilence.CrystalCMD.Client"]
B["Mac/Linux Application"] --> C
end
subgraph "Server Options"
D["Windows Service Majorsilence.CrystalCmd.NetframeworkConsoleServer"]
E["Linux Docker Container with Wine + .NET 4.8 + Crystal Reports 13.0.35"]
end
C --"1 - Send Crystal Report Template, 2. Send Data 3. Request PDF"--> F{CrystalCmd Service}
F --> D
F --> E
subgraph "Processing"
D --> G["Crystal Reports Engine"]
E --> G
G --> H["Generate PDF"]
end
H --"Return PDF"--> C
C --> I["Client receives PDF"]
classDef client fill:#d1f0ff,stroke:#333,stroke-width:1px
classDef server fill:#ffe6cc,stroke:#333,stroke-width:1px
classDef process fill:#e6ffcc,stroke:#333,stroke-width:1px
class A,B,C client
class D,E,F server
class G,H,I process
Basic info on the java version.
CrystalCmd supports running as a command line tool. Pass in path to report, data, and output fileand a pdf is generated.
java -jar CrystalCmd.jar -reportpath "/path/to/report.rpt" -datafile "/path/to/data.json" -outpath "/path/to/generated/file.pdf"
example 2
java -jar CrystalCmd.jar -reportpath "/home/peter/Projects/CrystalCmd/the_dataset_report.rpt" -datafile "/home/peter/Projects/CrystalCmd/test.json" -outpath "/home/peter/Projects/CrystalCmd/java/CrystalCmd/build/output.pdf"
CrystalCmd supports running in server mode. If you run it with no command line arguments it starts a web server listening on port 4321. There are two end points that can be called.
java -jar CrystalCmd.jar
Call the server.
curl -u "username:password" -F "reporttemplate=@the_dataset_report.rpt" -F "[email protected]" http://localhost:4321/export > myoutputfile.pdf
docker run -p 2005:4321 -t majorsilence/crystalcmd
Or run it as a daemon.
docker run -p 2005:4321 -d majorsilence/crystalcmd
Now check the status in your browser:
install
snap install ./java/CrystalCmd/build/CrystalCmd.snap --force-dangerous --classic
run
crystalcmd -reportpath "/home/peter/Projects/CrystalWrapper/the_dataset_report.rpt" -datafile "/home/peter/Projects/CrystalWrapper/test.json" -outpath "/home/peter/Projects/CrystalWrapper/Java/build/output.pdf"
sudo ./build_snap.sh
sudo apt-get install openjdk-11-jdk
Download eclipse java edition.
Setup eclipse with crystal references.
Import java/CrystalCmd folder as ecplise project (Eclipse -> File -> Open Projects from File System).
Download intelliJ community edition.
sudo apt-get install openjdk-11-jre
Package required libraries into generated JAR
output as "CrystalCmd.jar" in folder ./CrystalCmd/java/CrystalCmd/build
https://origin.softwaredownloads.sap.com/public/site/index.html
After some experimentation, a workaround was to create the fonts folder in the AdoptOpenJDK JRE (jre\lib\fonts) and copy a single font file from the Linux msttcorefonts mentioned above into the newly created fonts folder. My document uses all Arial font, but it doesn't seem to matter what font file is in the fonts folder. I copied Webdings.ttf. The file does have to be a real font file. I tried making a dummy text file and rename it to Webdings.ttf, but the NPE occurred with the dummy font file.
Once a real font is copied to jre\lib\fonts, The PDF is created just fine with the Arial font embedded. It seems that there just has to be a one real font at jre\lib\fonts to get started, and then crjava/AdoptOpenJDK will eventually use fontconfig to find the correct Windows font.
Copy a file from
Copy a file to C:\Users[UserName].jdks\openjdk-16.0.1\lib\fonts from C:\Windows\Fonts.
copy '/System/Library/Fonts' into '/Users/[UserName]]/Library/Java/JavaVirtualMachines/[JavaVersion]/Contents/Home/lib/fonts'
# try the ubuntu or fedora way first
# https://answers.sap.com/questions/676449/nullpointerexception-in-opentypefontmanager.html
apk add --no-cache msttcorefonts-installer && update-ms-fonts && fc-cache -f && ln -s /usr/share/fonts/truetype/msttcorefonts /usr/lib/jvm/default-jvm/jre/lib/fonts
apt install fonts-dejavu fontconfig msttcorefonts-installer && update-ms-fonts && fc-cache -f
ln -s /usr/share/fonts/truetype/msttcorefonts /usr/lib/jvm/java-1.11.0-openjdk-amd64/lib/fonts
dnf install fontconfig dejavu-sans-fonts dejavu-serif-fonts
Content type
Image
Digest
sha256:4863406ef…
Size
141.7 MB
Last updated
about 1 year ago
docker pull jesusdf/crystalcmd