def create_merge(self):
        merge = Merge(documents=[
            Document(doc_data=self.test_files.pdf_data),
            Document(doc_data=self.test_files.pdf_data_2)
        ],
                      merge_action=MergeAction())

        return merge
예제 #2
0
    def create_add_barcode(self):
        add_barcode = AddBarcode(
            document=Document(
                doc_data=self.test_files.pdf_data
            ),
            add_barcode_action=AddBarcodeAction(
                barcode_type='qrCode',
                value='welcome to pdf4me',
                height=100,
                width=100,
                align_x='center',
                align_y='middle',
                margin_x=0,
                margin_y=0,
                page_sequence='1',
                rotate='30',
                barcode_color=BarcodeColor(
                    red=0,
                    green=0,
                    blue=0,
                    alpha=100,
                ),
                background_color=BarcodeColor(
                    red=1,
                    green=1,
                    blue=1,
                    alpha=100,
                ),
            )
        )

        return add_barcode
    def create_create_images(self):
        create_images = CreateImages(
            document=Document(doc_data=self.test_files.pdf_data),
            image_action=ImageAction(
                width_pixel=4000,
                page_selection=PageSelection(page_nrs=[1]),
                image_extension='jpg'))

        return create_images
    def create_sign_pdf(self):
        sign_pdf = SignPdf(
            document=Document(
                doc_data=self.test_files.pdf_data
            ),
            sign_action=SignAction(

            )
        )

        return sign_pdf
    def create_extract(self):
        extract = Extract(
            document=Document(
                doc_data=self.test_files.pdf_data
            ),
            extract_action=ExtractAction(
                extract_pages=[1, 4]
            )
        )

        return extract
    def test_merge_documents_less_than_2_throws_exception(self):
        # prepare args
        merge = self.create_merge()
        merge.documents = [Document(doc_data=self.test_files.pdf_data)]

        with assert_raises(Pdf4meClientException) as e:
            self.merge_client.merge(merge=merge)

        assert_equal(
            e.exception.msg,
            'The merge documents must contain at least two documents.')
예제 #7
0
    def create_read_barcode(self):
        read_barcodes = ReadBarcodes(
            document=Document(
                doc_data=self.test_files.pdf_barcode_data
            ),
            read_barcode_action=ReadBarcodeAction(
                barcode_types=['all']
            )
        )

        return read_barcodes
    def create_repair(self):
        repair = Repair(
            document=Document(
                doc_data=self.test_files.pdf_data
            ),
            repair_action=RepairAction(

            )
        )

        return repair
    def create_validate(self):
        validate = Validate(
            document=Document(
                doc_data=self.test_files.pdf_data
            ),
            validate_action=ValidateAction(
                pdf_conformance='pdfA2u'
            )
        )

        return validate
    def create_create_pdfA(self):
        create_pdfA = CreatePdfA(
            document=Document(
                doc_data=self.test_files.pdf_data
            ),
            pdf_a_action=PdfAAction(
                compliance='pdfA2u'
            )
        )

        return create_pdfA
예제 #11
0
    def create_optimize(self):
        optimize = Optimize(
            document=Document(
                doc_data=self.test_files.pdf_data
            ),
            optimize_action=OptimizeAction(
                use_profile=True,
                profile='default'
            )
        )

        return optimize
예제 #12
0
    def create_split_by_barcode_req(self):
        split_by_barcode = SplitByBarcodeReq(
            document=Document(
                doc_data=self.test_files.pdf_barcode_data
            ),
            split_by_barcode_action=SplitByBarcodeAction(
                barcode_string='ara',
                barcode_filter='contains',
                barcode_type='any',
                split_barcode_page='after',
            )
        )

        return split_by_barcode
    def create_protect(self):
        protect = Protect(
            document=Document(
                doc_data=self.test_files.pdf_data
            ),
            protect_action=ProtectAction(
                user_password='******',
                owner_password='******',
                # unlock=None,
                # permissions=None
            )
        )

        return protect
    def create_extract_resource(self):
        extract_resource = ExtractResources(
            document=Document(
                doc_data=self.test_files.pdf_data
            ),
            extract_resources_action=ExtractResourcesAction(
                extract_fonts=1,
                extract_images=1,
                list_fonts=1,
                list_images=1,
                outlines=1,
                xmp_metadata=1
            )
        )

        return extract_resource
    def create_rotate(self):
        rotate = Rotate(
            document=Document(
                doc_data=self.test_files.pdf_data
            ),
            rotate_action=RotateAction(
                rotation_list=[
                    PdfRotate(
                        page_nr=2,
                        rotation_type='clockwise'
                    )
                ]
            )
        )

        return rotate
    def create_stamp(self):
        stamp = Stamp(
            document=Document(
                doc_data=self.test_files.pdf_data
            ),
            stamp_action=StampAction(
                text=Text(
                    value='EXAMPLE TEXT'
                ),
                alpha=1.0,
                page_sequence='all',
                align_x='center',
                align_y='middle'
            )
        )

        return stamp
예제 #17
0
    def create_convert_to_pdf(self, file, file_name):
        convert_to_pdf = ConvertToPdf(
            document=Document(doc_data=file, name=file_name),
            convert_to_pdf_action=ConvertToPdfAction())

        return convert_to_pdf
    def create_split(self):
        split = Split(document=Document(doc_data=self.test_files.pdf_data),
                      split_action=SplitAction(split_after_page=2))

        return split