Print Tester (Local)
If you cannot physically print PDF reports or labels to validate the result, use the local PowerShell script (internal link) (localprint.ps1) to capture print jobs and verify what COSMO Mobile Solution sends.
What the Tester Does
When the tester is running, it receives print jobs and stores them in a local folder:
- Report printing jobs are saved as PDF files.
- Label printing jobs are saved as text files and preview PDFs.
This gives you a simple way to confirm that printing data is generated correctly.
This tester scenario is applicable when printing is configured with TCP/IP connection type and the printer type is Generic Printer or Label Printer.
Use the Tester
- Save
localprint.ps1to a folder on your Windows machine. - Open the script in a text editor and adjust values only if needed:
- File names for saved outputs.
- Label size settings for preview generation.
- Run the script in PowerShell.
- In COSMO Mobile Solution, set the target printer address to the computer where the script is running (port 9100).
- Start printing from the mobile application.
- Open the output folder configured in the script (default: MobilePrintResult) and review the output files.
Script Settings You Can Edit
The script contains a small Settings section that you can adjust before running it.
| Setting | What it controls | What you gain by changing it |
|---|---|---|
$pdfReportBaseName = "PDFReport" |
Prefix of saved report PDF files. | Use a naming style that fits your internal test process. |
$labelBaseName = "Label" |
Prefix of saved label files. | Keep label test outputs easy to identify. |
$outDir = Join-Path $PSScriptRoot "MobilePrintResult" |
Target folder for all captured files. | Save outputs to a preferred folder path. |
$dpmm = "8dpmm" |
Labelary print density for label preview rendering (available options: 6dpmm, 8dpmm, 12dpmm, 24dpmm). |
Match preview sharpness to your expected printer profile. |
$width = "4" and $height = "6" |
Label preview size in inches. | Generate previews that match your real label format. |
Change the Listening Port
By default, the script listens on port 9100.
If you want to use a different port:
- In COSMO Mobile Solution, set the same port in printer setup (IP:Port format).
- Open
localprint.ps1. - In the Settings section, change
$port = 9100to your preferred free port (for example,$port = 9200). - Save the script and run it again.
- If needed, allow the selected port in your local firewall.
The port in the script and the port in COSMO Mobile Solution must always match.
Result Files
The tester creates files with date and time stamps:
PDFReport_*.pdf: Report print jobs captured as PDFs.Label_*.zpl.txt: Raw label content captured from label print jobs.Label_*_label0.pdf,Label_*_label1.pdf, ...: Label preview PDFs.
Known PowerShell Issues:
If you have problems with the execution policy when running the script, proceed as follows:
Start the script from Command Prompt and use a per-run execution policy bypass:
powershell -ExecutionPolicy Bypass -File "C:\...\localprint.ps1"
You can run it in two ways:
- Provide the full script path (recommended).
- Navigate to the script folder in Command Prompt first, then run:
powershell -ExecutionPolicy Bypass -File .\localprint.ps1
See Also
Printer Setup and User Configuration
Print Setup in Global Page Customizations
Print Button Usage in Mobile Application
Print Configuration Examples
Feedback
Submit feedback for this page .