Convert base64 PDF to base64 image file - node.js

I have an application where i am creating a PDF using PDFKit npm module.
I have a use case where i am provided the base64 string of a pdf document that needs to be converted to an image, so i can then embed that into another PDF document using PDFKit.
I wish to do this in memory and not save any actual documents, i need to input a base64 string in PDF format and get one back in an image format.
How can i convert base64 string PDF to a base64 string image (png, jpg, etc) using javascript/node?

Related

Chromium pdf renderer generates large pdf

I am trying to generate pdf from node using puppetter. We have large data, so we generate small html files(app 3mb) each, and then convert these html files to pdf's, then we merge these pdf's to generate the final pdf. The issue is the generated pdf is very large in size. for e.g pdf generated using paid pdflib generates 60mb of pdf, but pdf with similar content generated using puppetter is almost double the size (120mb). If we remove the image from the header(which is just 3kb in size), that also reduces the size to a considerable extent. Are there any flags or tricks to optimize the size of pdf generated using puppetter(chromium).

Node js - converting pdf to valid version

I have various pdf files which fail a certain logic process due to them being invalid.
I use - https://www.pdf-online.com/osa/validate.aspx
and when I validate a pdf, I get a message that says the pdf does not conform to the PDF 1.3 standard or 1.4 standard.
I'm familiar with converting the pdf to text/json/buffer and then rebuild it and save it as a new pdf file, but was wondering is there an alternative? Because each pdf is different and is basically user input and the rebuilding it using jspdf for example, will be different for every file.
Is it possible to convert such pdf document to conform to the PDF 1.3/1.4 standards?

Convert any document, image, text file into PDF

I want to convert any documents or image or text file into PDF for all the OS.
I tried the approach with node-msoffice-pdf, and its working fine for Windows OS but not working in other OS.
Question:
How to convert docs, images, textfile to pdf in nodejs?
I used wkhtmltopdf from years to manage pdf conversion.
https://github.com/devongovett/node-wkhtmltopdf
You can either render an html file and pass it to the module, or render a pdf directly from an url.
If fidelity/conversion quality is important to you, for Word documents (doc/docx) you could try our freemium https://www.npmjs.com/package/#nativedocuments/docx-wasm which will perform the conversion locally (ie where node is running), without the need to LibreOffice etc.

PDF form to HTML conversion in angular 2?

In my application I am uploading a PDF file after uploading, I should display the information present in PDF file to a HTML form we are using angular 2 for frontend and node js for backend. Can any one help me with this.
Please remember PDF to HTML.
You can do one thing. Convert your pdf to a JSON. Use pdf2json.
pdf2json is a node.js module that parses and converts PDF from binary to json format, it's built with pdf.js and extends it with
interactive form elements and text content parsing outside browser.
The goal is to enable server side PDF parsing with interactive form
elements when wrapped in web service, and also enable parsing local
PDF to json file when using as a command line utility.
perform npm install pdf2json
Create an empty JSON whose key values will be the main headings from the pdf like a customer, age etc. Its values are obtained from the uploaded pdf.
Using this JSON values fill your form, on saving the form using, node.js save it to your DB. Is this what you want?
Simply what you need is to render a PDF in your application.
You could use this library ng2-pdf-viewer
Almost all the basic functionalities are available as properties to this component. You could manipulate it to your requirement.

How to identify encoded format is base64 or not

I have a code that looks like a base64. I used multiple decoders online but it retrieved blank,. Now I'm not sure if it's a base64. This is the code cXdJM50PIEUBe31uLYIC/A==
Its not a baase64 image, if its base 64 encoded image after paste the browser, display the image in browser check yourself,
src="data:image/png;base64,cXdJM50PIEUBe31uLYIC/A=="
paste only,
data:image/png;base64,cXdJM50PIEUBe31uLYIC/A==
Actual base64 image looks like this,
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAMAAAC5zwKfAAAB4FBMVEX/////KRD/Mhj/KBn/LBn+MiD/KBb/Mx3/LhX/KRP8///1////PSX5//9Ft/99AAD///nxLhpDqv/r//+DAABIBxRqAABhopBme4e2saO31dH0JRTAAABZKTZ3cm2fGxOxAABgHhx/NSjQ48V9a0p0NS+dDgBVT0nYIhmnEAPDIxhYHh0AFh66JBl6HRlnBwrm8vPZIQvt18W9xsTx+vNtk251s8CLs7up1diSNDJDbFUwGhxHHi3U6eAkYVGQHhpHNjZOGR0PAAAATD6MHBefHxhqHhwhHCAzHwXf///b5dm/qZeom3ZIIBnB9ekWW1dNn7qQw8tkiptqX1hcmKhdABVyeHq5p2mVXSJ8vrxvua6NtJCkrqTq8L/Q7fRJnp1/CRzIvZQ+QDlKAACVdltTWW2MABpGb3l5NklsYW+S6eeK1Mu24t5Pcm4yPEP07NpJVlJIYXd6j5BWTTlnh4hjQUG99/dAWWJjOUp6Hi7Hn3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