TeX - LaTeX Asked on July 2, 2021
In the mid document i want to insert a pdf page into a custom page size. The pdf page size is 432pt x 177pt
and want to fit it in the center of a page 300pt x 300pt
documentclass{article}
usepackage{pdfpages}
usepackage{geometry}
begin{document}
...
eject
pdfpagewidth=300pt pdfpageheight=300pt
newgeometry{layoutwidth = 300pt,layoutheight = 300pt,left=0mm,right=0mm,top=0mm, bottom=0mm}
includepdfmerge[]{/home/simha/latex/test.pdf, 494}
...
end{document}
The output of this (the page size is 300pt x 300pt as i wanted but the pdf is gone sideways. I want it to be fit in the center
If i try to use fitpaper
option in pdfpages
documentclass{article}
usepackage{pdfpages}
usepackage{geometry}
begin{document}
eject
pdfpagewidth=300pt pdfpageheight=300pt
newgeometry{layoutwidth = 300pt,layoutheight = 300pt,left=0mm,right=0mm,top=0mm, bottom=0mm}
includepdfmerge[fitpaper]{/home/simha/latex/test.pdf, 494}
end{document}
the output i get is (the page size is not 300pt x 300pt but the size of the pdf page size is "432pt x 177pt" which is not i want
I am stuck up here. I want to inser a pdf page into a size i want in the mid of the document.
If you intend to fit the PDF image to the page, you can use the following.
documentclass{article}
usepackage[showframe]{geometry}
usepackage{graphicx}
usepackage{lipsum}% MWE only
begin{document}
lipsum[1-6]
eject
pdfpagewidth=300pt pdfpageheight=300pt
newgeometry{margin=0mm}
noindentincludegraphics[width=300pt,height=300pt,page=1]{example-image}
eject
pdfpagewidth=paperwidth
pdfpageheight=paperheight
restoregeometry
lipsum[1-6]
end{document}
If you intent to crop and center, you can use this version. Note, trying to scale and crop in one step is not a good idea. If the image is already 432pt by 177pt, you can skip the scaling step.
documentclass{article}
usepackage[showframe]{geometry}
usepackage{adjustbox}
usepackage{lipsum}% MWE only
begin{document}
lipsum[1-6]
eject
pdfpagewidth=300pt pdfpageheight=300pt
newgeometry{margin=0mm}
noindentbegin{minipage}[c][300pt][c]{300pt}% vertically center
adjustbox{clip,trim=66 0 66 0}{includegraphics[width=432pt,height=177pt,page=1]{example-image}}
end{minipage}
eject
pdfpagewidth=paperwidth
pdfpageheight=paperheight
restoregeometry
lipsum[1-6]
end{document}
This version doesn't need a minipage.
documentclass{article}
usepackage[showframe]{geometry}
usepackage{graphicx}
usepackage{lipsum}% MWE only
begin{document}
lipsum[1-6]
eject
pdfpagewidth=300pt pdfpageheight=300pt
newgeometry{top=0pt,left=0pt,textwidth=300pt,textheight=300pt,noheadfoot}
nullvfill% or vspace*{fill}
noindent
makebox[textwidth]{includegraphics[width=432pt,height=177pt,page=1]{example-image}}
vfillnull
eject
pdfpagewidth=paperwidth
pdfpageheight=paperheight
restoregeometry
lipsum[1-6]
end{document}
Correct answer by John Kormylo on July 2, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP