
click on multiple links and save as pdf
1 次查看(过去 30 天)
显示 更早的评论
I have 40 links imported in an excel sheet. Each link,when clicked, will lead to (Print as file) window for the page.
Is there anyway to open the multiple link, save the page as PDF with specific format (Year_Month_date) with one click ?
Regards
0 个评论
回答(1 个)
Purvaja
2025-9-5
Hi @Jabbar Khan
I have come together with a concise solution using MATLAB and headless Chrome, which you can run from MATLAB to automate the entire workflow. I have made a dummy excel sheet ("dummy_links.xlsx") with links of random websites. After running the below MATLAB script, we will have a folder called "PDFs" which will save all these links sequentially with name in the date format ("yyyy-mm-dd"). Each PDF is saved with sequential date as (e.g., 2025_09_01, 2025_09_02, …) so the filenames follow a daily sequence.
% Read links from Excel
T = readtable('dummy_links.xlsx');
urls = T.Links;
startDate = datetime(2025,9,1);
outDir = fullfile(pwd, 'PDFs');
if ~exist(outDir, 'dir')
mkdir(outDir);
end
% Path to Chrome
chromePath = '"..\chrome.exe"';
% Loop through each link
for i = 1:numel(urls)
url = urls{i};
fileDate = startDate + caldays(i-1);
dateStr = datestr(fileDate, 'yyyy_mm_dd');
fileName = sprintf('%s.pdf', dateStr);
outFile = fullfile(outDir, fileName)
cmd = sprintf('%s --headless --disable-gpu --print-to-pdf="%s" "%s"', ...
chromePath, outFile, url);
status = system(cmd);
if status == 0
fprintf('Saved PDF: %s\n', outFile);
else
warning('Failed for URL: %s\n', url);
end
end
This will create a folder named "PDFs" in the same folder and should look like:

Hope this helps you!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!