Git Product home page Git Product logo

Comments (2)

g-raffy avatar g-raffy commented on August 17, 2024

Here's what I found until now:

  • The bug seems to be revealed by the "hautbois 1" page, which is clearly different from other pages (it('s not an original track, it has been created by someone else, and has different properties: unlike the other pdf pages, it doesn't contain a /Group element)).
  • the bug disappears when the stamps are not added
  • the bug seems to be in pdftex, see [https://tex.stackexchange.com/questions/76273/multiple-pdfs-with-page-group-included-in-a-single-page-warning]

from pymusco.

g-raffy avatar g-raffy commented on August 17, 2024

Here's a test function that exhibits the bug:

def bug_shower_1(trigger_bug: bool):
    src_pdf_file_path = Path('/home/graffy/private/melting-notes/partitions/scans/888-bug.pdf')

    tmp_dir = Path('/home/graffy/private/dev/pymusco/tickets/ticket0008/tmp')

    scanned_image_file_paths = []
    with open(src_pdf_file_path, 'rb') as src_pdf_file:
        pdf_reader = PyPDF2.PdfReader(src_pdf_file)
        page_index = 0
        for page in pdf_reader.pages:
            print(f'============= page_index = {page_index}')
            # image_file_path = extract_pdf_page_main_image(page, image_dir=tmp_dir, image_name=('page%03d' % page_index))
            image_file_path = extract_pdf_page(page, image_dir=tmp_dir, image_name=f'page{page_index:03d}')
            print(image_file_path)
            # check_pdf_file(image_file_path)

            scanned_image_file_paths.append(image_file_path)
            page_index += 1

    # stamp_descs = stamp_descs if stamp_descs is not None else []

    orchestra = load_orchestra('/home/graffy/private/dev/pymusco/samples/harmony.orchestra')

    piece = load_piece_description(Path('/home/graffy/private/melting-notes/partitions/scans/888-bug.desc'), orchestra)

    dst_stub_pdf_file_path = Path('/home/graffy/private/dev/pymusco/tickets/ticket0008/stub.pdf')
    toc = piece.scan_toc

    if trigger_bug:
        stamp_descs = piece.stamp_descs
    else:
        stamp_descs = []

    images_to_pdf(StubContents(image_file_paths=scanned_image_file_paths, toc=toc, title='toto', stamp_descs=stamp_descs, page_info_line_y_pos=1.0), dst_stub_pdf_file_path)

    # check_pdf_file(dst_stub_pdf_file_path)

    dst_stub_copy_pdf_file_path = Path('/home/graffy/private/dev/pymusco/tickets/ticket0008/stub-copy.pdf')
    duplicate_pdf_file_001(dst_stub_pdf_file_path, dst_stub_copy_pdf_file_path)
    # check_pdf_file(dst_pdf_file_path)

from pymusco.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.