vips copy
command to image a PDF.export PREFIX=/usr/local/vips
export PKG_CONFIG_PATH = $PREFIX/lib/pkgconfig
exportLD_LIBRARY_PATH = $PREFIX/lib
export PATH=$PATH:$PREFIX/bin
WORKDIR=/usr/local/src
VIPS_URL=https://github.com/libvips/libvips/releases/download
PDFIUM_URL=https://github.com/bblanchon/pdfium-binaries/releases/download/chromium
PDFIUM_VERSION=5351
VIPS_VERSION= 8.13.2
# Install Related Libraries
yum install-y\
libpng-develop\
poppler-glib-develop\
glib2-develop\
libjpeg-develop\
expat-develop\
zlib-develop\
orc-develop\
lcms2-develop\
libexif-develop\
libgsf-develop
# pdftoppm
yum install-y poppler-utils
cd$WORKDIR
## install PDFIUM
mkdir pdfium-$PDFIUM_VERSION\
&cdpdfium-$PDFIUM_VERSION\
&wget$PDFIUM_URL/$PDFIUM_VERSION/pdfium-linux-x64.tgz
mkdir-p$PREFIX/lib/pkgconfig\
&cd$PREFIX\
&tar xf$WORKDIR/pdfium-$PDFIUM_VERSION/pdfium-linux.tgz\
&echo "prefix=$PREFIX">lib/pkgconfig/pdfium.pc\
&echo "exec_prefix=\${prefix}">lib/pkgconfig/pdfium.pc\
&echo "libdir=\${exec_prefix}/lib">lib/pkgconfig/pdfium.pc\
&echo "includedir=\${prefix}/include">lib/pkgconfig/pdfium.pc\
&echo "Name:pdfium" > lib/pkgconfig/pdfium.pc\
&echo "Description: pdfium" > lib/pkgconfig/pdfium.pc\
&echo "Version: $PDFIUM_VERSION" > lib/pkgconfig/pdfium.pc\
&echo "Requires:">lib/pkgconfig/pdfium.pc\
&echo "Libs:-L\${libdir}-lpdfium">lib/pkgconfig/pdfium.pc\
&echo "Cflags:-I\${includedir}">lib/pkgconfig/pdfium.pc
## install libvips
wget$VIPS_URL/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz\
&tar xf vips-$VIPS_VERSION.tar.gz\
&cd vips-$VIPS_VERSION\
&./configure -- prefix$PREFIX\
&make V = 0\
& make install
vips copy input.pdf [page=1,dpi=192] output_1_.jpg [Q=100]
You can compile libvips to view annotations when you image PDFs as follows:
Add the fourth line (sed-z~).
wget$VIPS_URL/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz\
&tar xf vips-$VIPS_VERSION.tar.gz\
&cd vips-$VIPS_VERSION\
&sed-z-i's/FPDF_RenderPageBitmap[^;]*;/FPDF_RenderPageBitmap(bitmap, pdf->page, 0, rect.width, rect.height, 0, 1);/'/libvips/foreign/pdfiumload.c\
&./configure -- prefix$PREFIX\
&make V = 0\
& make install
libvips specifies the option not to display annotations when running the FPDF_RenderPageBitmap function in PDFium. Above, the source code has been rewritten and compiled with the option to view annotations.
If you run the last argument of the FPDF_RenderPageBitmap function with RenderFlags.FPDF_ANNOT=1, you will see PDF annotations.
public static void FPDF_RenderPageBitmap(
IntPtr bitmap,
IntPtr page,
int start_x,
int start_y,
int size_x,
int size_y,
PageRotate rotation,
RenderFlags flags
)
https://pdfium.patagames.com/help/html/M_Patagames_Pdf_Pdfium_FPDF_RenderPageBitmap.htm
If you look at the libvips side code, the last argument is 0 and you specify the option not to display annotations. You can achieve your goal by changing the last argument to 1.
libvips/foreign/pdfiumload.c
FPDF_RenderPageBitmap(bitmap, pdf->page,
0,0, rect.width, rect.height,
0, 0 );
sed-z-i's/FPDF_RenderPageBitmap[^;]*;/FPDF_RenderPageBitmap(bitmap, pdf->page,0,0,rect.width,rect.height,0,1);/'/libvips/foreign/pdfiumload.c
The command above changes the last argument to 0→1 as follows:
FPDF_RenderPageBitmap(bitmap, pdf->page,
0,0, rect.width, rect.height,
0, 0 );
↓
FPDF_RenderPageBitmap (bitmap, pdf-> page, 0, 0, rect.width, rect.height, 0, 1);
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.