• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to decode file after extracting it from annotation

Community Beginner ,
Jun 04, 2019 Jun 04, 2019

Copy link to clipboard

Copied

I have the following code for extracting 3d data ( file ) from my annotation , but as the result I have encoded ( compressed ) file , how I can get the decoded file ( not compressed ) ?

I've tried cosOpenFiltered and cosOpenRaw and it doesn't work

char* ptr1 = new char[2800000];

                        ASFile asGLTFFile = NULL;

                        CosObj stm = PDAnnotGetCosObj(annot);

                       

                        CosObj stm3d = CosDictGetKeyString(stm,"3DD");

                      

                        ASStm streamopen = CosStreamOpenStm(stm3d,cosOpenUnfiltered);

                      

                        ASTArraySize lenghth = CosStreamLength(stm3d);

                        ASTCount a = ASStmRead(ptr1,1,lenghth,streamopen);

                       

#if WIN_PLATFORM

                        const char* GLTFStringName = "C:\\setDefaultCamera.gltf";

#else

                        const char* GLTFStringName = "/Users/Shared/file1.gltf";

#endif

                        BuildFile(GLTFStringName);

                   

#ifdef    WIN_PLATFORM

                        const char* strPathFlag = "Cstring";

#else

                        const char* strPathFlag = "POSIXPath";

#endif

                       

                        ASPathName GLTFPathName = ASFileSysCreatePathName (ASGetDefaultFileSys(),

                                                              ASAtomFromString(strPathFlag), GLTFStringName, 0);

                        ASInt32 BRet = ASFileSysOpenFile(ASGetDefaultFileSys(), GLTFPathName, ASFILE_WRITE, &asGLTFFile);

     

                        ASFileSysReleasePath (ASGetDefaultFileSys(), GLTFPathName);

                            ASTArraySize Bret = ASFileWrite(asGLTFFile,ptr1,lenghth);

                                ASStmClose(streamopen);

                                ASFileClose(asGLTFFile);

TOPICS
Acrobat SDK and JavaScript

Views

1.2K

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
community guidelines

correct answers 1 Correct answer

Adobe Employee , Jun 04, 2019 Jun 04, 2019

Keep reading until you run out of data….

char buffer[9999];

ASInt32 readItems, totalRead = 0;

do {

readItems = Read(buffer, sizeof(buffer));

outBuffer.insert(outBuffer.end(), buffer, buffer + readItems);

totalRead += readItems;

} while(readItems > 0);

Votes

Translate

Translate
Adobe Employee ,
Jun 04, 2019 Jun 04, 2019

Copy link to clipboard

Copied

cosOpenFiltered – that tells the SDK to do any decompression on the stream.

Votes

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
community guidelines
Community Beginner ,
Jun 04, 2019 Jun 04, 2019

Copy link to clipboard

Copied

Maybe I should write whole stream ? Not only under 3dd key ?

Votes

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
community guidelines
Adobe Employee ,
Jun 04, 2019 Jun 04, 2019

Copy link to clipboard

Copied

You are getting the COMPRESSED length and using that.

Yes, you need to write the entire stream…

Votes

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
community guidelines
Community Beginner ,
Jun 04, 2019 Jun 04, 2019

Copy link to clipboard

Copied

And how I can get the uncompressed length , I really can't get this , If I'm trying to read and write the entire stream , I have the document reading error (20 )

                        ASFile asGLTFFile = NULL;

// getting whole stream

                        CosObj stm = PDAnnotGetCosObj(annot);

                        CosObj stm3d = CosDictGetKeyString(stm,"3DD");

                      

                        ASStm streamopen = CosStreamOpenStm(stm,cosOpenFiltered);

                        ASTArraySize lenghth = CosStreamLength(stm);

                       

                       char* pBuff = (char*)ASmalloc(lenghth);

                        ASTCount a = ASStmRead(pBuff,1,lenghth,streamopen);

                       

#if WIN_PLATFORM

                        const char* GLTFStringName = "C:\\setDefaultCamera.gltf";

#else

                        const char* GLTFStringName = "/Users/Shared/file1.gltf";

#endif

                        BuildFile(GLTFStringName);

                   

#ifdef    WIN_PLATFORM

                        const char* strPathFlag = "Cstring";

#else

                        const char* strPathFlag = "POSIXPath";

#endif

                       

                        ASPathName GLTFPathName = ASFileSysCreatePathName (ASGetDefaultFileSys(),

                                                              ASAtomFromString(strPathFlag), GLTFStringName, 0);

                        ASInt32 BRet = ASFileSysOpenFile64(ASGetDefaultFileSys(), GLTFPathName, ASFILE_READ|ASFILE_WRITE, &asGLTFFile);

                      

                        ASFileSysReleasePath (ASGetDefaultFileSys(), GLTFPathName);

                       

                        if ((BRet == 0) && (asGLTFFile != NULL))

                        {

                            ASTArraySize Bret = ASFileWrite(asGLTFFile,pBuff,strlen(pBuff));

                           

                            if(Bret!=0)

                            {

                                ASStmClose(streamopen);

                                ASFileClose(asGLTFFile);

                               

                            }

                            else

                            {

                                AVAlertNote("Error in writting");

                            }

                           

                        }

Votes

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
community guidelines
Adobe Employee ,
Jun 04, 2019 Jun 04, 2019

Copy link to clipboard

Copied

Keep reading until you run out of data….

char buffer[9999];

ASInt32 readItems, totalRead = 0;

do {

readItems = Read(buffer, sizeof(buffer));

outBuffer.insert(outBuffer.end(), buffer, buffer + readItems);

totalRead += readItems;

} while(readItems > 0);

Votes

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
community guidelines
Community Beginner ,
Jun 05, 2019 Jun 05, 2019

Copy link to clipboard

Copied

LATEST

Thank you for your help!

Votes

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
community guidelines
Community Beginner ,
Jun 04, 2019 Jun 04, 2019

Copy link to clipboard

Copied

I've tried but it still doesn't work, as the result I have compressed file when I use cosOpenFiltered , for example I have the source file 2.8 megabytes , then I add this file to pdf with the help of annotation , as the result after saving pdf with 3d annotation , I have the pdf file that is 1.9 mb ( with compressed file ) ,then im extract file from annotation , and my new file ( from Annot ) is also 1.9 mb , when source file is 2.8mb , I've tried cosOpenFilter cosOpenUnfiltered and it doesn't work

Votes

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
community guidelines