I want to append a new Report to an existing Report/file

3 次查看(过去 30 天)
I have a program that outputs multiple PDF's of information. Right now it's just images, and I can easily append a new PDF image to an existing PDF image. However, it's not very professional looking, and I'd like to include additional information, like text. Thus, I'd like to change this process to using Reports.
Right now, it appears anytime I call the report function, it deletes/overwrites an already existing report if they have the same name. Is there anyway to append to an already existing (PDF) file? This is all in PDF's and needs to be in PDF (company standard). I've been trying to dig my way through all the report functions but...the documention is hard to follow. I've seen a suggestion to only call the report function once, leaving the file open and continuously writing to it. That's not an option for this analysis flow. It can take a while and people need to be able to pick up where they left, instead of starting from scratch.

采纳的回答

Ruchika Parag
Ruchika Parag 2025-7-23
Hi @plasmageek, appending to an existing PDF report using MATLAB Report Generator isn't directly supported—the Report object will overwrite the existing file if a report with the same name already exists. However, there are a couple of effective workarounds depending on your workflow:
1. Build the Report in a Single Session with the DOM or Report API
If possible, create the report in one MATLAB session and incrementally append content to it using the append method. For example:
import mlreportgen.report.*
import mlreportgen.dom.*
rpt = Report("MyReport", "pdf");
append(rpt, Paragraph("First part of the analysis"));
% Append more sections here as needed
close(rpt);
This works well if the full report is generated in one go. You can structure your code so that it appends intermediate results at different stages, but keeps the report session open until the final close() call.
2. Generate Separate PDFs and Merge Later
If your process is long or involves interruptions (e.g., needing to resume work), a common approach is to generate multiple smaller PDF files and merge them into one final document at the end. You can use the append_pdfs() function from the File Exchange to do this:
append_pdfs("FinalReport.pdf", "Part1.pdf", "Part2.pdf", "Part3.pdf");
This allows you to generate modular content in chunks and combine them into a single report, which is often more manageable for long analyses.
Each approach has trade-offs depending on whether you need live, incremental reporting or modular post-processing. Hope this helps!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Report Generator 的更多信息

标签

产品


版本

R2025a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by