Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature]Is possible to combine all subpages into one pdf? #19

Open
PEMessage opened this issue Feb 9, 2021 · 4 comments
Open

[feature]Is possible to combine all subpages into one pdf? #19

PEMessage opened this issue Feb 9, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@PEMessage
Copy link

Just like a pdf book

@ganeshh123
Copy link
Owner

Not at the moment, there are ways to do this, from other programs like Adobe Acrobat. An older version of this tool, using markdown export has a book function, but it doesn't work well.
https://github.com/ganeshh123/notion-pdf-export/releases/tag/1.1.0

@PEMessage
Copy link
Author

Thanks. By the way, any plan for emoji support?

@ganeshh123
Copy link
Owner

Depends on how this goes:
wkhtmltopdf/wkhtmltopdf#2913
The conversion is done using another program

@ganeshh123 ganeshh123 added the enhancement New feature or request label Apr 11, 2021
@Rickyyy-zh
Copy link

Rickyyy-zh commented Aug 11, 2021

Just like a pdf book

A simple script to merge all pages into one pdf after all subpages are exported.

import sys
from PyPDF2 import PdfFileMerger
import os
import importlib
importlib.reload(sys)

def GetFileList(dir, fileList):
    newDir = dir

    if os.path.isfile(dir):
        fileList.append(dir.encode('gbk').decode('gbk'))
    elif os.path.isdir(dir):
        #print(os.listdir(dir))
        for s in os.listdir(dir):
            newDir=os.path.join(dir,s)
            #print(newDir)
            GetFileList(newDir, fileList)

    return fileList

def main(dir):
    list_file = []
    GetFileList(dir, list_file)
    merger = PdfFileMerger()

    for i in reversed(range(len(list_file))):
        print(list_file[i])
        pdf_input = open(list_file[i],'rb')
        merger.append(pdf_input)

    outfile_path = dir+'/output.pdf'            #output pdf file name
    pdf_out = open(outfile_path, 'wb')
    merger.write(pdf_out)

if __name__ == "__main__":
    documents_dir = 'C:/Users/xxx/Desktop/notion tool/pdfs'  #input your pdfs path, without '/' in the end, like: 'C:/Users/xxxx/Desktop/notion tool/pdfs'
    main(documents_dir)

Used https://github.com/mstamy2/PyPDF2
by comment /PyPDF2/pdf.py , line 1512,1513 to aviod the error " PyPDF2.utils.PdfReadError: Unexpected destination '/__WKANCHOR_2' "

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants