-
Notifications
You must be signed in to change notification settings - Fork 0
Add a basic example and implementation in Delphi #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e36840e
git: Ignore build and output files (pdf, docx, zip)
NickVolynkin 6439ff8
delphi: Add an example application
NickVolynkin 1027dd3
repo: Define repository description and tags
NickVolynkin a38522b
readme: Describe the example: test, implement, links to read
NickVolynkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # GitHub Repository metadata | ||
| url: vcl-reports-non-interactive-export | ||
| website: https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports | ||
| description: Generate DevExpress VCL Reports in backend and service applications. | ||
| tags: [vcl, pdf, reports, backend, service, cli, console] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| program PDFReportGenerator; | ||
|
|
||
| {$APPTYPE CONSOLE} | ||
|
|
||
| {$R *.res} | ||
|
|
||
| uses | ||
| System.SysUtils, System.Classes, System.StrUtils, dxBackend, dxBackend.Bundled, | ||
| dxBackend.ConnectionString.SQL, dxReport, dxReport.Parameters; | ||
| var | ||
| AOrderID: string; | ||
|
|
||
| // Export a report to a PDF file in non-interactive mode: | ||
| // without showing the report in the Report Designer or Report Viewer, or otherwise using UI. | ||
| // Parameters: | ||
| // AOrderID: order ID to use in report data, for example, '11077' | ||
| procedure ExportReportToPdf(const AOrderID: string); | ||
| var | ||
| AConnection: TdxBackendDatabaseSQLConnection; | ||
| AReport: TdxReport; | ||
| AStream: TMemoryStream; | ||
| AOutputFileName: string; | ||
|
|
||
| begin | ||
| // Step 1: Create a report instance and load the report layout | ||
| AReport := TdxReport.Create(nil); | ||
| try | ||
| // Set an internal report name (does not affect the exported PDF content and file name) | ||
| AReport.ReportName := 'OrderReport'; | ||
| // Load the report layout from the specified file | ||
| AReport.Layout.LoadFromFile('Order.repx'); | ||
|
|
||
| // Step 2: Create a database connection | ||
| AConnection := TdxBackendDatabaseSQLConnection.Create(nil); | ||
| try | ||
| // Assign a database name matching the name specified in the report layout | ||
| AConnection.DisplayName := 'NWindConnectionString'; | ||
| // Assign a connection string required to use the local SQLite database | ||
| AConnection.ConnectionString := 'XpoProvider=SQLite; Data Source=nwind.db; Mode=ReadOnly'; | ||
|
|
||
| // Step 3: Define Report Parameter Values | ||
| AReport.LoadParametersFromReport; | ||
| // Set the "OrderIdParameter" value in the report layout | ||
| AReport.Parameters['OrderIdParameter'].Value := AOrderID; | ||
|
|
||
| // Step 4: Export a report to PDF | ||
| AStream := TMemoryStream.Create; | ||
| try | ||
| // Export a report to a memory stream in the PDF format | ||
| AReport.ExportToPDF(AStream); | ||
| // Save memory stream content to a file | ||
| AOutputFileName := 'Order_' + AOrderID + '.pdf'; | ||
| AStream.SaveToFile(AOutputFileName); | ||
| Writeln('Report saved to: ', AOutputFileName); | ||
| finally | ||
| AStream.Free; | ||
| end; | ||
| finally | ||
| AConnection.Free; | ||
| end; | ||
| finally | ||
| AReport.Free; | ||
| end; | ||
| end; | ||
|
|
||
| // The helper application entry point that parses command-line parameters and calls the export procedure | ||
| begin | ||
| if ParamCount < 1 then | ||
| begin | ||
| Writeln('Error: OrderID parameter is required. For example: PDFReportGenerator.exe 11077'); | ||
| Halt(1); // Exit with error code 1 | ||
| end; | ||
|
|
||
| AOrderID := ParamStr(1); // Read the first parameter as OrderID | ||
| ExportReportToPdf(AOrderID); | ||
| end. | ||
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.