This commit is contained in:
John Whitington 2021-09-26 16:24:19 +01:00
parent 0965d8ee54
commit c427f79d8b
4 changed files with 30 additions and 7 deletions

Binary file not shown.

View File

@ -338,7 +338,7 @@ int main (int argc, char ** argv)
\end{small} \end{small}
\end{cpdflib} \end{cpdflib}
\begin{cpdflib} \begin{pycpdflib}
\chapter*{Example Program in Python} \chapter*{Example Program in Python}
This program loads a file \texttt{hello.pdf} from disk and writes out a This program loads a file \texttt{hello.pdf} from disk and writes out a
@ -346,10 +346,33 @@ document with the original included three times.
\begin{small} \begin{small}
\begin{verbatim} \begin{verbatim}
(PYTHON EXAMPLE HERE) #Merge example
import pycpdflib
#DLL loading depends on your own platform. These are the author's settings.
if sys.platform.startswith('darwin'):
pycpdflib.loadDLL("/Users/john/repos/python-libcpdf/libpycpdf.so")
elif sys.platform.startswith('linux'):
pycpdflib.loadDLL("../libpycpdf.so")
elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
os.add_dll_directory("C:\\\\OCaml64/home/JohnWhitington/python-libcpdf/")
pycpdflib.loadDLL("libpycpdf.dll")
#We will take the input hello.pdf and repeat it three times
mergepdf = pycpdf.fromFile('hello.pdf', '')
#The list of PDFs to merge
pdfs = [mergepdf, mergepdf, mergepdf]
#Merge them
merged = pycpdflib.mergeSimple(pdfs)
#Write output
pycpdflib.toFile(merged, 'merged.pdf', False, False)
\end{verbatim} \end{verbatim}
\end{small} \end{small}
\end{cpdflib} \end{pycpdflib}
\pagestyle{plain} \pagestyle{plain}
\tableofcontents\clearpage\pagestyle{empty} \tableofcontents\clearpage\pagestyle{empty}

View File

@ -1,8 +1,8 @@
"""Pycpdf: a python interface to cpdf. """Pycpdflib: a python interface to cpdf.
Before using the library, you must load the libpycpdf and libcpdf DLLs. This is Before using the library, you must load the libpycpdf and libcpdf DLLs. This is
achieved with the pycpdf.loadDLL function, given the filename or full path of achieved with the pycpdflib.loadDLL function, given the filename or full path
the libpycpdf DLL. On Windows, you may have to call os.add_dll_directory of the libpycpdf DLL. On Windows, you may have to call os.add_dll_directory
first. On MacOS, you may need to give the full path, and you may need to first. On MacOS, you may need to give the full path, and you may need to
install libcpdf.so in a standard location /usr/local/lib/, or use the install libcpdf.so in a standard location /usr/local/lib/, or use the
install_name_tool command to tell libpycpdf.so where to find libcpdf.so. install_name_tool command to tell libpycpdf.so where to find libcpdf.so.

View File

@ -2,7 +2,7 @@ Loading the libpypcdf and libcpdf DLLs
-------------------------------------- --------------------------------------
Before using the library, you must load the ``libpycpdf`` and ``libcpdf`` DLLs. Before using the library, you must load the ``libpycpdf`` and ``libcpdf`` DLLs.
This is achieved with the ``pycpdf.loadDLL`` function, given the filename or This is achieved with the ``pycpdflib.loadDLL`` function, given the filename or
full path of the ``libpycpdf`` DLL. full path of the ``libpycpdf`` DLL.
On Windows, you may have to call ``os.add_dll_directory`` first. On MacOS, you On Windows, you may have to call ``os.add_dll_directory`` first. On MacOS, you