How to remove pages from a pdf?

9 ビュー (過去 30 日間)
Isaac Marín
Isaac Marín 2024 年 9 月 12 日
編集済み: Isaac Marín 2024 年 9 月 12 日
When using exportapp on a uifigure who contains uilabels with Tex interpreter, the pdf file contains white pages at the end and I want to delete them.
Here an example code:
File='example.pdf';
Path='D:\Downloads\';
f = uifigure;
lb=uilabel(f,"Text",'x^{2}','Interpreter','tex','Position',[50 50 100 100]);
pause(2)
exportapp(f,fullfile(Path,File))
delete(f)

採用された回答

Isaac Marín
Isaac Marín 2024 年 9 月 12 日
編集済み: Isaac Marín 2024 年 9 月 12 日
We can remove pages from a pdf using pdfbox
To delete all pages but the first one, example:
Pd=org.apache.pdfbox.pdmodel.PDDocument;
PDFile=java.io.File(fullfile(Path,File));
document=Pd.load(PDFile);
npages=document.getNumberOfPages
if npages>1
for i=npages:-1:2
document.removePage(i-1);
end
document.save(fullfile(Path,File));
end
document.close;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

タグ

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by