Annotations not displaying consistently on Web, iOS and Android when Image is displayed in viewer

Product Version:

  • Web: Webviewer ( 7.3.2 )
  • iOS : PDFnet ( 9.3.1.80205 )
  • Android : PDFnet (7.0.3)

Please give a brief summary of your issue:
Loading an image in viewer is not consistent from Web, Android and iOS.

Please describe your issue and provide steps to reproduce it:

I’m converting and loading an image (png) inside the viewers in web, iOS and Android and when I create an annotation on this image, there is an offset and a scale difference between platforms. (see picture below with the red circle annotation). When I load a PDF, the annotations are consistent but not with the image. What am I doing wrong please ? Thanks in advance,

In web, I’m converting and loading the image file like this:

viewerInstance.loadDocument(url, {filename: file.name});

In iOS, I’m converting and loading the image file like this:

doc = PTPDFDoc()
PTConvert.toPdf(doc, in_filename: selectedDoc)

In Android, I’m converting and loading the image file like this:

DocumentConversion mPdfDoc2 = mPdfViewCtrl.openNonPDFUri(ResourceHelper.getUriFromUrl( getActivity(), mFile.url ), null);
PdfDoc = mPdfDoc2.getDoc();

Hi Laurent,

Thank you for reaching out.

To keep the image sizes consistent between different platforms, you would have to adjust the page size option.
“PageSizes” is a page-sized array of 2 number [xPoints yPoints] arrays. determines the output page size in points.

The recommended API for conversion from image to PDF in iOS is StreamingPDFConversion.

PTConvert.streamingPDFConversionWithDoc(fromFilter: doc, in_stream: selectedDoc, options:  PTConversionOptions(value: "{\"PageSizes\": [[\(width), \(height)]]}"))

In web:

viewerInstance.loadDocument(url, {
  filename: file.name,
  pageSizes: [{width, height}]
})

Android:

String conversionOptions = null;
try {
    JSONArray firstPageSizeArray = new JSONArray();
    firstPageSizeArray.put(3024);
    firstPageSizeArray.put(3024);
    JSONArray pageArray = new JSONArray();
    pageArray.put(firstPageSizeArray);
    JSONObject convOpt = new JSONObject();
    convOpt.put("PageSizes", pageArray);
    conversionOptions = convOpt.toString();
} catch (Exception ignored) {}
ViewerConfig.Builder builder = new ViewerConfig.Builder();
builder = builder
        .conversionOptions(conversionOptions)

Please let us know if this works for you, or if you have any other questions or concerns.

Best Regards,
Sahil Behl.