Skip to content

Commit

Permalink
1.2: fix page size rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Nov 15, 2019
1 parent c23fd6c commit 5f8b145
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/jpeg2pdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ PJPEG2PDF Jpeg2PDF_BeginDocument(double pdfW, double pdfH, double margin) // w
{
memset(pPDF, 0, sizeof(JPEG2PDF));
if(JPEG2PDF_DEBUG) logMsg("PDF List Inited (pPDF = %p)\n", (int)pPDF, 2,3,4,5,6);
pPDF->pageW = (UINT32)(pdfW * PDF_DOT_PER_INCH);
pPDF->pageH = (UINT32)(pdfH * PDF_DOT_PER_INCH);
pPDF->pageW = (double)(pdfW * PDF_DOT_PER_INCH);
pPDF->pageH = (double)(pdfH * PDF_DOT_PER_INCH);
//Maximum image size without margins
pPDF->margin = margin;
pPDF->maxImgW = (double) pPDF->pageW - (2 * margin * PDF_DOT_PER_INCH);
pPDF->maxImgH = (double) pPDF->pageH - (2 * margin * PDF_DOT_PER_INCH);
pPDF->maxImgW = (double) pPDF->pageW - (2.0 * margin * PDF_DOT_PER_INCH);
pPDF->maxImgH = (double) pPDF->pageH - (2.0 * margin * PDF_DOT_PER_INCH);
if(JPEG2PDF_DEBUG) logMsg("PDF Page Size (%d %d) Max Image Size (%f %f)\n", pPDF->pageW, pPDF->pageH, pPDF->maxImgW, pPDF->maxImgH,3,4,5,6);

pPDF->currentOffSet = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/jpeg2pdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ typedef struct
UINT8 pdfHeader[MAX_PDF_HEADER];
UINT8 pdfTailer[MAX_PDF_TAILER]; /* 28K Bytes */
UINT8 pdfXREF[MAX_PDF_XREF][XREF_ENTRY_LEN + 1]; /* 27K Bytes */
UINT32 pageW, pageH, pdfObj, currentOffSet, imgObj;
double margin;
UINT32 pdfObj, currentOffSet, imgObj;
double pageW, pageH, margin;
double maxImgW, maxImgH;
} JPEG2PDF, *PJPEG2PDF;

Expand Down
4 changes: 2 additions & 2 deletions src/jpeg2pdfcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,8 @@ int main(int argc, char *argv[])
#ifdef HAVE_FINDFIRST
findMaximumDimensions(filesarray, globlen, pageDpi, pageOrientation==Portrait || pageOrientation==Landscape, &pageWidth, &pageHeight);
#endif
pageWidth += (pageMargins * 2);
pageHeight += (pageMargins * 2);
pageWidth += (pageMargins * 2.0);
pageHeight += (pageMargins * 2.0);
printf("Selected paper size: %.2f x %.2f \" or %.2f x %.2f cm.\n", pageWidth, pageHeight, pageWidth*2.54, pageHeight*2.54);
}
}
Expand Down

0 comments on commit 5f8b145

Please sign in to comment.