@docverse-pdf/server 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -96,20 +96,21 @@ function processAnnotExtras(doc, extrasXml) {
96
96
  }
97
97
  }
98
98
  async function processStampImages(doc, stampXml) {
99
- // Parse stamp-images XML
100
99
  const stampRegex = /<stamp-image\s+type="([^"]*?)"\s+page="(\d+)"\s+left="([^"]*?)"\s+top="([^"]*?)"\s+width="([^"]*?)"\s+height="([^"]*?)">\s*<data>([\s\S]*?)<\/data>\s*<\/stamp-image>/g;
101
100
  let match;
102
101
  while ((match = stampRegex.exec(stampXml)) !== null) {
103
102
  const [, , pageStr, leftStr, topStr, widthStr, heightStr, dataUrl] = match;
104
103
  const pageIndex = parseInt(pageStr);
105
104
  const left = parseFloat(leftStr);
106
- const top = parseFloat(topStr);
105
+ const top = parseFloat(topStr); // screen coordinate (top-down)
107
106
  const width = parseFloat(widthStr);
108
107
  const height = parseFloat(heightStr);
109
- // Convert data URL to RGBA
110
108
  const rgbaData = await dataUrlToRGBA(dataUrl);
111
109
  if (rgbaData) {
112
- const pdfY = top - height;
110
+ // Screen Y (top-down) → PDF Y (bottom-up)
111
+ const pageSize = doc.getPageSize(pageIndex);
112
+ const pageHeight = pageSize?.height ?? pageSize?.h ?? 792;
113
+ const pdfY = pageHeight - top - height;
113
114
  doc.addImageObject(pageIndex, rgbaData.data, rgbaData.width, rgbaData.height, left, pdfY, width, height);
114
115
  }
115
116
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docverse-pdf/server",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "DocVerse Server SDK — server-side PDF processing, XFDF merge, Word to PDF, image extraction",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
Binary file