Closed
Description
Hi! I've been dealing with this for a couple days already, I looked thru all issues and history in this repository but didn't find anyone else having the same issue.
So...All I do is to add an image to a PDFDoc that I am creating. This image is on portrait mode (which means that there is a field in EXIF
that indicates that image is Rotated 90 degrees. However, when I look to the generated PDF the image shows landscape.
Any thoughts or ideas? Problem surely is that I am doing something wrong because haven't seen anyone else having that issue.
This is a taste of my code:
const DOCUMENT_DEFAULTS = {
DEFAULT_MARGIN: 0,
MARGIN_LEFT: 0,
MARGIN_TOP: 20,
DOC_WIDTH: 612, // Letter Size @ 72 DPI
DOC_HEIGHT: 792, // Letter Size @ 72 DPI,
IMG_WIDTH: 612,
AUTHOR: 'COMPANY NAME'
}
/**
* Generates a PDF file with the supplied images in the specified file
* @param {string} outputFilename. Full path and filename where PDF file should be generated.
* @param {object[]} documents. List of document objects ({filename: 'FULL_PATH', name: 'DOC_NAME'}) to include in the PDF
*/
module.exports = function (outputFilename, documents, title) {
// ...
// Generate PDF document with all images and submit it to Carrier
let pdfDoc = new PDFDocument({
autoFirstPage: false,
margin: DOCUMENT_DEFAULTS.DEFAULT_MARGIN,
width: DOCUMENT_DEFAULTS.DOC_WIDTH,
height: DOCUMENT_DEFAULTS.DOC_HEIGHT
})
// Add metadata
pdfDoc.info = {
Title: title,
Author: DOCUMENT_DEFAULTS.AUTHOR
}
// Create stream to disk
pdfDoc.pipe(fs.createWriteStream(outputFilename))
// Add documents to file
documents.forEach(doc => {
pdfDoc.addPage()
.text(doc.name, DOCUMENT_DEFAULTS.MARGIN_LEFT, DOCUMENT_DEFAULTS.MARGIN_TOP)
.image(doc.filename, DOCUMENT_DEFAULTS.MARGIN_LEFT, DOCUMENT_DEFAULTS.MARGIN_TOP * 2, { fit: [DOCUMENT_DEFAULTS.IMG_WIDTH, 792] })
})
pdfDoc.end()
// ...
Find attached the original image and the generated pdf
Metadata
Metadata
Assignees
Labels
No labels