How to convert a jpg to PDF

New Here ,
Feb 11, 2019

Copy link to clipboard

Copied

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.

Most Valuable Participant
Correct answer by Test Screen Name | Most Valuable Participant

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.

TOPICS
Acrobat SDK and JavaScript

Views

264

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to convert a jpg to PDF

New Here ,
Feb 11, 2019

Copy link to clipboard

Copied

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.

Most Valuable Participant
Correct answer by Test Screen Name | Most Valuable Participant

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.

TOPICS
Acrobat SDK and JavaScript

Views

265

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 11, 2019 0
Most Valuable Participant ,
Feb 11, 2019

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 11, 2019 1