Skip to main content
thomasm16477343
Participating Frequently
February 11, 2019
Answered

How to convert a jpg to PDF

  • February 11, 2019
  • 1 reply
  • 935 views

I am currently trying to convert a jpg image into a pdf with the following code:

function JpgToPdf (doc, img)

{

     var myDoc = app.newDoc();

     // myDoc.Open("/C/Users/tmuñoz/Desktop/Thuban-Nivel 2.pdf");

     myDoc.disclosed = true;

     doc.disclosed = true;

     newDoc = app.openDoc({

          oDoc: doc,

          cPath: img,

          bUseConv: true

     })

     newDoc.disclosed = true;

     var filePath = "/C/Users/tmuñoz/Desktop/Adobe/temp.pdf";

     //MySaveAs(newDoc,"/C/Users/tmuñoz/Desktop/Adobe","Thomas23.pdf");

     newDoc.saveAs({

             cPath:"/C/Users/tmuñoz/Desktop/Adobe/temp.pdf"

         })

newDoc.closeDoc(true);

}

The following code is not working and it sends me the following error:

RaiseError: The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder.

This topic has been closed for replies.
Correct answer Test Screen Name

Some ideas to try:

- try saving to a folder with only Latin1 characters (no ñ)

- quit Acrobat, restart and run the code once

- if the file exists delete it and check it has gone

I assume this is called from or part of a trusted function.

1 reply

Test Screen NameCorrect answer
Legend
February 11, 2019

Some ideas to try:

- try saving to a folder with only Latin1 characters (no ñ)

- quit Acrobat, restart and run the code once

- if the file exists delete it and check it has gone

I assume this is called from or part of a trusted function.