feat: 实现 Chromium PDF 导出与精确预览
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
export const PDF_POINTS_PER_INCH = 72;
|
||||
export const CSS_PIXELS_PER_INCH = 96;
|
||||
export const PDF_PAGE_CSS_SCALE =
|
||||
CSS_PIXELS_PER_INCH / PDF_POINTS_PER_INCH;
|
||||
|
||||
export function getPdfPageCssDimensions(
|
||||
widthPoints: number,
|
||||
heightPoints: number
|
||||
) {
|
||||
return {
|
||||
width: widthPoints * PDF_PAGE_CSS_SCALE,
|
||||
height: heightPoints * PDF_PAGE_CSS_SCALE
|
||||
};
|
||||
}
|
||||
|
||||
export function getPdfCanvasRenderScale(
|
||||
widthPoints: number,
|
||||
displayWidthCssPixels: number,
|
||||
devicePixelRatio: number
|
||||
) {
|
||||
if (
|
||||
widthPoints <= 0 ||
|
||||
displayWidthCssPixels <= 0 ||
|
||||
devicePixelRatio <= 0
|
||||
) {
|
||||
return 0;
|
||||
}
|
||||
return (displayWidthCssPixels / widthPoints) * devicePixelRatio;
|
||||
}
|
||||
Reference in New Issue
Block a user