{"id":23338415,"url":"https://github.com/abhirockzz/fn-img2pdf","last_synced_at":"2025-04-07T13:43:49.292Z","repository":{"id":79124951,"uuid":"179223784","full_name":"abhirockzz/fn-img2pdf","owner":"abhirockzz","description":"Serverless function for converting image to PDF","archived":false,"fork":false,"pushed_at":"2019-04-03T06:29:16.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T16:32:52.148Z","etag":null,"topics":["faas","fnproject","object-storage","oci-events","oracle-cloud-infrastructure","oracle-functions","orafunc-events","orafunc-la","serverless"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abhirockzz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-03T06:22:33.000Z","updated_at":"2019-11-07T01:44:02.000Z","dependencies_parsed_at":"2023-03-12T06:43:18.997Z","dependency_job_id":null,"html_url":"https://github.com/abhirockzz/fn-img2pdf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Ffn-img2pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Ffn-img2pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Ffn-img2pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Ffn-img2pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhirockzz","download_url":"https://codeload.github.com/abhirockzz/fn-img2pdf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247666003,"owners_count":20975785,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["faas","fnproject","object-storage","oci-events","oracle-cloud-infrastructure","oracle-functions","orafunc-events","orafunc-la","serverless"],"created_at":"2024-12-21T03:13:52.643Z","updated_at":"2025-04-07T13:43:49.273Z","avatar_url":"https://github.com/abhirockzz.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Event driven function for converting images to PDF\n\nThis event driven function converts images files (jpeg, png etc.) to PDF. Once you drop the image into an Oracle Cloud Infrastructure Object Storage Bucket and configure the appropriate trigger rule, the function will convert it into PDF and store the converted file (with a `.pdf` extension) in an output bucket specified by the user \n\n- The function written in Java and uses [Apache PDFBox](https://pdfbox.apache.org/) for file conversion.\n- Uses the [OCI Java SDK](https://github.com/oracle/oci-java-sdk) to execute Object Storage read and write operations\n- A custom `Dockerfile` is used to build the function\n\n## Pre-requisites\n\n- [Create input and output buckets in Oracle Cloud Infrastructure Object Storage](https://docs.cloud.oracle.com/iaas/Content/Object/Tasks/managingbuckets.htm#usingconsole)\n- Collect the following information for you OCI tenancy (you'll need these in subsequent steps) - Tenancy OCID, User OCID of a user in the tenancy, OCI private key, OCI public key passphrase, OCI region\n- Clone this repository\n- Change into the correct directory - `cd fn-img2pdf` \n- Copy your OCI private key to folder. If you don't already have one, [please follow the documentation](https://docs.cloud.oracle.com/iaas/Content/API/Concepts/apisigningkey.htm#How)\n\n### Switch to correct context\n\n- `fn use context \u003cyour context name\u003e`\n- Check using `fn ls apps`\n\n## Create application\n\n`fn create app img2pdf --annotation oracle.com/oci/subnetIds='SUBNET_OCIDs' --config TENANT=\u003cTENANT_OCID\u003e --config USER=\u003cUSER_OCID\u003e --config FINGERPRINT=\u003cPUBLIC_KEY_FINGERPRINT\u003e --config PASSPHRASE=\u003cPRIVATE_KEY_PASSPHRASE\u003e --config REGION=\u003cOCI_REGION\u003e --config OUTPUT_BUCKET=\u003cSTORAGE_OUTPUT_BUCKET_NAME\u003e`\n\n\u003e The OCI user credentials you provide should have read and write access to the specified Object Storage bucket)\n\nThe function logic uses the following image file types/extensions by default - `jpeg`,`jpg`, `png`. If you want override it (e.g. you only want to support `gif` and `jpg` types), please add `VALID_FILE_TYPES` configuration to the `fn create` e.g. `--config VALID_FILE_TYPES=jpg,gif`.\n\ne.g.\n\n`fn create app img2pdf --annotation oracle.com/oci/subnetIds='[\"ocid1.subnet.oc1.phx.aaaaaaaaghmsma7mpqhqdhbgnby25u2zo4wqlrrcskvu7jg56dryxtfoobar\"]' --config TENANT=ocid1.tenancy.oc1..aaaaaaaaydrjm77otncda2xn7qtv7l3hqnd3zxn2u6siwdhniibwfvfoobar --config USER=ocid1.user.oc1..aaaaaaaavz5efq7jwjjipbvm536plgylg7rfr53obvtghpi2vbg3qyfoobar --config FINGERPRINT=41:82:5f:44:ca:a1:2e:58:d2:63:6a:af:52:42:42:42 --config PASSPHRASE=4242 --config REGION=us-phoenix-1 --config OUTPUT_BUCKET=pdf-output-bucket`\n\n### Check deployed application\n\n`fn inspect app img2pdf`\n\n## Deploy the application\n\n`fn -v deploy --app img2pdf --build-arg PRIVATE_KEY_NAME=\u003cprivate_key_name\u003e` \n\ne.g. \n\n`fn -v deploy --app img2pdf --build-arg PRIVATE_KEY_NAME=oci_private_key.pem`\n\n## Create Events rule\n\n### Before you proceed...\n\nFind the function OCID (use the command below) and replace it in `actions.json` file\n\n`fn inspect fn img2pdf convertimg2pdf | jq '.id' | sed -e 's/^\"//' -e 's/\"$//'`\n\n    {\n        \"actions\": [\n            {\n            \"actionType\": \"FAAS\",\n            \"description\": \"Invoke function on object store event\",\n            \"isEnabled\": true,\n            \"functionId\": \"enter function OCID here\"\n            }\n        ]\n    }\n\nGo ahead and create the rule using OCI CLI\n\n`oci --profile \u003coci-config-profile-name\u003e cloud-events rule create --display-name \u003crule-name\u003e --is-enabled true --condition '{\"eventType\": [\"com.oraclecloud.objectstorage.object.create\"],\"data\": {\"bucketName\": [\"\u003cinput-bucket-name\u003e\"]}}' --compartment-id \u003ccompartment-ocid\u003e --actions file://\u003cjson-file-name\u003e`\n\nReplace `\u003cinput-bucket-name\u003e` with the (input) Object Storage bucket name where you will upload the image\n\ne.g.\n\n`oci --profile devrel-abhishek cloud-events rule create --display-name invoke-img2pdf-function --is-enabled true --condition '{\"eventType\": [\"com.oraclecloud.objectstorage.object.create\"],\"data\": {\"bucketName\": [\"image-input-bucket\"]}}' --compartment-id ocid1.compartment.oc1..aaaaaaaaokbzj2jn3hf5kwdwqoxl2dq7u54p3tsmxrjd7s3uu7x23tfoobar --actions file://actions.json`\n\n## Test\n\nUpload an image file to the Object Storage bucket which you configured as the input bucket (in the above rule). Wait for a bit and check the bucket which you configured as the output - you should see the converted PDF file there.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhirockzz%2Ffn-img2pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhirockzz%2Ffn-img2pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhirockzz%2Ffn-img2pdf/lists"}