From 9aed7b37ac2740cf577165d4e3e348fcf17ab4f7 Mon Sep 17 00:00:00 2001
From: wang--ge <wang__ge@126.com>
Date: Fri, 19 Apr 2024 15:37:37 +0800
Subject: [PATCH] rewrite papersize

---
 PSUtils.pm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/PSUtils.pm b/PSUtils.pm
index 9a95056..8b64247 100644
--- a/PSUtils.pm
+++ b/PSUtils.pm
@@ -73,13 +73,16 @@ sub paper {
 sub paper_size {
   my ($paper_name) = @_;
   chomp($paper_name = paper([])) unless defined($paper_name);
-  my $dimensions = paper(["--unit=pt", "$paper_name"], 1) or return;
-  $dimensions =~ / ([.0-9]+)x([.0-9]+) pt$/;
+  my $dimensions_w = paper(["-p", "$paper_name", "-m", "-w"], 1) or return;
+  $dimensions_w =~ / ([.0-9]+) mm$/;
   my $old_locale = setlocale(LC_ALL);
   setlocale(LC_ALL, "");
-  my ($w, $w_unparsed) = strtod($1);
-  my ($h, $h_unparsed) = strtod($2);
+  my ($w, $w_unparsed) = strtod($dimensions_w);
+  my $dimensions_h = paper(["-p", "$paper_name", "-m", "-h"], 1) or return;
+  $dimensions_h =~ / ([.0-9]+) mm$/;
+  my ($h, $h_unparsed) = strtod($dimensions_h);
   setlocale(LC_ALL, $old_locale);
+  print($w,$h, $dimensions_w, $dimensions_h);
   return int($w + 0.5), int($h + 0.5); # round dimensions to nearest point
 }
 
-- 
2.33.0

