Dear,
I recently had to process a bunch of measurement data and plot them as several diagramms.
Doing so I sometimes like to create a log file (ascii) that holds some additional informations.
Now it is convenient to save all results into a single multipage PDF-file.
For graphics this is relatively easy thanks to the multipage pdf toolbox and pdfconcat / xsapp2pdf. (Thank you Stéphane)
The quesion I had: How to add the log-file data to the PDF-file?
Under Windows:
A workaround can be using host() together with powershell and the virtual printer "Microsoft Print to PDF"
Below an example:
IN_DIR = "D:\"
IN_FILE = "mytext.txt"
IN_PATH = IN_DIR + IN_FILE;
// print something to the txt file
fd = mopen(IN_PATH, 'wt');
mfprintf(fd, "hello world");
mclose(fd);
// name of virtual printer
printerName = "Microsoft Print to PDF";
// buid the powershell command
dq = ascii(34); // to save some double quote typing
formatString = "powershell -Command " + dq + "Get-Content ''%s'' | Out-Printer -Name ''%s'' " + dq
// concatenate the command string for host()
command = sprintf(formatString, IN_PATH, printerName);
printf("Command: %s\n", command);
// execute command via host()
status = host(command);
A popup window shows up , defining the PDF folder and name.
Now diagrams can be added to this PDF-file such as:
plot2d();
xsapp2pdf(0,IN_DIR + "path-to-pdf-file");
The process still requires some manual input:
1.: defining the PDF-file location and name (popup window)
2.: xsapp2pdf does not know the the path to the PDF-file as a return value (or so) from the popup window.
Best Regards,
Philipp