Quantcast
Channel: Adobe Community : All Content - Acrobat SDK
Viewing all 2571 articles
Browse latest View live

How to read from pdf file?

$
0
0

I am new to reading pdf using C# where I have below function in my project. How to recognize text position in pdf file?

 

Here _dblRect has 151.0, 696.0, 400.0, 500.0

_strFileName is txt file name.

 

Can someone explain how this function works?

 

private string fcnTextFromCrop(string _strFileName, double[] _dblRect, CAcroPDDoc _docOriginal, int _intPage)

        {

            string str = "";

            try

            {

                object jSObject = _docOriginal.GetJSObject();

                System.Type type = jSObject.GetType();

                object target = null;

                object[] args = new object[] { _intPage };

                target = type.InvokeMember("extractPages", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, jSObject, args);

                object[] objArray2 = new object[] { "Crop", 0, 0, _dblRect };

                type.InvokeMember("setPageBoxes", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, target, objArray2);

                object[] objArray3 = new object[] { _strFileName, "com.adobe.acrobat.plain-text" };

                type.InvokeMember("saveAs", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, target, objArray3);

                object[] objArray4 = new object[] { true };

                type.InvokeMember("closeDoc", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, target, objArray4);

                using (StreamReader reader = new StreamReader(_strFileName))

                {

                    str = reader.ReadToEnd();

                    reader.Close();

                }

                System.IO.File.Delete(_strFileName);

            }

            catch

            {

                str = "";

            }

            return str;

        }


How to batch paginate multiple pdf files consecutively?

$
0
0

How to batch paginate multiple pdf files consecutively?


Thanks.

How to check CM operator's presence in pdf ContentSteams

$
0
0

HI,

 

Does anyone knows how to cofirm whether CM (Concatenate matrix to current transformation matrix) operator is present in the pdf content stream.

 

Actually I need to verify whether matrix returned by PDEElementGetMatrix() is an identity matrix or not. For that I found CM operators presence is responsible.

So anyone if knows how to check CM operator is present in a pdecontent dictionary object.

 

 

Thank you

Saffiuddin Sheikh.

How to speed up PDEPath object Reflow

$
0
0

Hi friends,

 

I have written a plug-in which works for reflowing objects. I found that if a pdf contains more no of path objects, it takes much more time to reflow.

Infact more pdf having more than 5000 path objects, plug-in takes even 10-15 min to process.

 

I use PDEElementSetMatrix for reflow. And it takes more time for path objects.

 

So I wanted to know whether there is any mechanism to speed up reflow of path objects ...?

 

 

Thank you,

Saffiuddin Sheikh.

How to call GUI/Dialog in Acrobat sdk Plugin

$
0
0

How to call GUI/Dialog in Acrobat sdk Plugin using VC++ here is my code

 

ACCB1 void ACCB2 MyPluginCommand(void *clientData)

{

 

 

  HMODULE hAppInst = GetModuleHandle(NULL);

 

  DialogBox(hAppInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, NULL);

  HWND hWnd = ::CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc);

  ::ShowWindow(hWnd, SW_SHOW);

}

how to use AVDocPrintPagesWithParams for printing without any prompt dialog or alert message ?

$
0
0

Hi Friends,

 

I have a problem to print the pages of a pdf, but with out any dialog box prompt. So I choosed the api AVDocPrintPagesWithParams(avDoc, avDocPrintParam);

 

But I don't know how to set parameter for 2nd parameter of the funtion. My requirement is I want to print pdf's using default printer of the system i.e. Print As PDF using Abode PDF print.

 

Page Dimension should be same as previous, with postscript value 3 (best print).

 

I have used AVDocPrintPages (AVDoc doc, ASInt32 firstPage,ASInt32 lastPage, ASInt32 psLevel, ASBool binaryOK,ASBool shrinkToFit); But it gives an error message for some pdf's that PDF may not printed correctly because font information couldn't be found.

 

So can anyone let me know please how to set the parameter of AVDocPrintParam, so that I can use AVDocPrintPagesWithParams and do the same job.

 

 

 

Thanks and Regards,

Saffiuddin Sheikh.

MFC in Acrobat Plugin

$
0
0

Hi

   I have tried to create plugin using MFC support but the dialogue has not been displayed in acrobat 11

my Code is

 

LRESULT CALLBACK MyDialogProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)

{

  static AVWindow sAVWin;

    switch(Msg)

    {

        case WM_INITDIALOG:

        {

            sAVWin = AVWindowNewFromPlatformThing(AVWLfloating, 0, NULL, gExtensionID, reinterpret_cast<AVPlatformWindowRef>(hWndDlg));

            ShowWindow(hWndDlg, SW_SHOW);

  AVAppBeginModal(sAVWin);

            return TRUE;

        }

        break;

        case WM_COMMAND:

        {

            switch(wParam)

            {

                case IDOK:

                {

                    // TODO:: Write code here for OK button click handling

                    EndDialog(hWndDlg, 0);

                    return TRUE;

                }

                break;

                case IDCANCEL:

                {

                    // TODO:: Write code here for CANCEL button click handling

                    EndDialog(hWndDlg, 0);

                    return FALSE;

                }

                break;

            }

        }

        break;

        case WM_DESTROY:

        {

            //AVWindowDestroy(sAVWin);

        }

        break;

    }

    return FALSE;

}

 

 

void CreateDialogs()

{

   INT_PTR nRetVal ;

    HWND CapturehWnd, hParent;

    CapturehWnd = GetCapture();

   

    if ( CapturehWnd != NULL )

    {

        ReleaseCapture();

    }

    hParent = WinAppGetModalParent(AVAppGetActiveDoc());

    dialog = CreateDialog(gHINSTANCE, MAKEINTRESOURCE(IDD_DIALOG1), hParent, (DLGPROC) MyDialogProc);

   

    if ( CapturehWnd != NULL )

    {

        SetCapture( CapturehWnd );

    }

}

 

 

 

 

ACCB1 void ACCB2 MyPluginCommand(void *clientData)

{

  CreateDialogs();

}

ask a acropdf.dll question

$
0
0

void __fastcall TForm1::BitBtn1Click(TObject *Sender)

{   

  AcroPDF1->LoadFile(WideString("G:\\1.pdf"));   

  AcroPDF1->printAll();

}

when i print, warning arise(content is :"Warning! The script called for the Acrobat file, this may print the whole

 

 

document. To continue printing?").

How can I avoid pop-up this warning, but let the program automatically print?????

thanks1.JPG


ask a acropdf.dll question

$
0
0

void __fastcall TForm1::BitBtn1Click(TObject *Sender)

{   

  AcroPDF1->LoadFile(WideString("G:\\1.pdf"));   

  AcroPDF1->printAll();

}

when i print, warning arise(content is :"Warning! The script called for the Acrobat file, this may print the whole

 

 

document. To continue printing?").

How can I avoid pop-up this warning, but let the program automatically print?????

thanks1.JPG

How to automate distribution of pdf documents to new sources from queue?

$
0
0

our site is gathering user submissions for ebook typos

 

we have a routing system setup to automatically find email and street address information based on twitter handle searches and best guess methodology in cases with no matches.

 

our current system relies upon the source being pre-configured.

 

Can anyone point me to the SDK calls with keeping documents in a queue until actions are taken to release them? 

How to get page size

$
0
0

Hi

I would like to get the page size

I used PDPageGetMediaBox (pdPage, &bbox);

where else I got

left  - 0
top - 51904512
right - 40108032

bottom - 0

 

but my actual page size is 8.25 and 11.0

how to obtain this value

 

PDEImageCreate

$
0
0

hi

I use PDEImageCreate for make picture from PDEElement. I used this method for create new image

 

//load image

  PDEImage pdeImage;

  PDEImage pdi;

  memset(&pdi, 0, sizeof(PDEImage));

  pdi = (PDEImage)ele;

  // image att

  PDEImageAttrs pdiATT;

  //memset(&pdiATT, 0, sizeof(pdiATT));   

  PDEImageGetAttrs(pdi,&pdiATT,sizeof(pdiATT));

 

  //img data

  ASInt32 pdiLen = PDEImageGetDataLen(pdi);

  byte *imgBuf = (byte *)malloc(pdiLen);

  PDEImageGetData(pdi, 0, imgBuf);

  //encoded Flag

  ASUns32* encodedLenP;

  ASBool encodedFlag =  PDEImageDataIsEncoded(pdi,encodedLenP);

  //color Space

  PDEColorSpace pdiCS ;

  memset(&pdiCS,0,sizeof(PDEColorSpace));

  pdiCS= PDEImageGetColorSpace (pdi);

  //ASFmatrix

  ASFixedMatrix pdiASFXM;

  //memset(&pdiASFXM,0,sizeof(ASFixedMatrix));

  PDEElementGetMatrix(ele,&pdiASFXM);

  //image stream

  ASStm pdiSTM ;

  //memset(&pdiSTM,0,sizeof(ASStm));

  pdiSTM= PDEImageGetDataStm(pdi,1);

  //

  PDEFilterArrayP filterArrayP1;

  //memset(&filterArrayP,0,sizeof(PDEFilterArrayP));

  //ASInt32 filterNum = PDEImageGetFilterArray(pdi,filterArrayP1);

  PDEFilterArrayP  pFilter;

  PDEFilterArrayP  pFilterDes;

  //ColorValue

  ASInt32  filtCount =  PDEImageGetFilterArray(pdi,  NULL);

  if  ( filtCount > 0 ) 

  {

  /* PDEImageGetFilterArray expects enough memory for all filters 

  so we need to allocate */

  pFilter= (PDEFilterArrayP)  ASmalloc (offsetof(PDEFilterArray, spec) + ( sizeof (PDEFilterSpec) * filtCount));

  pFilterDes= (PDEFilterArrayP)  ASmalloc (offsetof(PDEFilterArray, spec) + ( sizeof (PDEFilterSpec) * filtCount));

  ASInt32   err  = 0;

  DURING

  PDEImageGetFilterArray(pdi, pFilter);

  *pFilterDes = *pFilter;

  HANDLER

  err =  ERRORCODE;

  END_HANDLER

  //ASfree( pFilter );

  //if  ( err != 0 )

  //                ASRaise(err);

  }

pdeImage=PDEImageCreate(&pdiATT,sizeof(pdiATT),&pdiASFXM,0,pdiCS,NULL,pFilterDes,pdiSTM,im gBufEnc,lllen);

 

for some images this method works correctly and for some not.

for example for image with these attributes, this source code works fine:

PDEImageAttr.flag = 1

PDEImageAttr.bitpercomponnent=8

PDEImageAttr.decode={0,0,0,0,0,0,0,0}

PDEImageAttr.intent = 65535

but for an image with these attributes, this method doesn't work

PDEImageAttr.flag = 5

PDEImageAttr.bitpercomponnent=8

PDEImageAttr.decode={0,0,0,0,0,0,0,0}

PDEImageAttr.intent = 65535

 

my question is how I can solve this problem and make image from PDEElement ? As you can see and I suppose the problem the only parameter which is different is 'flag'.

Set Resolution thru Acrobat.CAcroPDDoc

$
0
0

Hi, I am looking for setting the Resolution thru Acrobat.CAcroPDDoc API when we convert from PDF to TIFF.

 

Need to know how to do this. Thanks in advance.

 

Thanks

Prabhu

Is there a way to tell if a pdf is a portfolio without the Portfolio SDK installed?

$
0
0

I am developing a plugin that I do not want active when the document is a Portfolio. Is there a way to determine if a pdf is a Portfolio using only the Adobe Acrobat SDK?

 

Thanks,

using the save as other> optimize PDF in Acrobat XI on many pdf files

$
0
0

I have many scanned documents in PDF form from an old scanner and I would like to reduce the image size with Acrobat XI.  How can I do this with many files without manually opening each of them and executing the menu item for each document?  It will take a long time for 3000 documents.

 

Bob


How do I compress PDF files using Acrobat SDK?

$
0
0

have a web service created in a .net environment that examines existing pdf files in a staging directory prior to sending them over the wire using FTP.

 

Part of that process requires that I rename individual files in order to associate them with a particular batch.

 

I also have a requirement to reduce the size of individual files as much as possible in order to reduce the traffic going over the line.

 

So far I have managed about a 30% compression rate by using an open source library (iTextSharp).

 

I  am hoping that I can get a better compression rate using the Acrobat SDK, but I need someone to show me how, hopefully with an example that I can follow.

 

The following code snippet is a model I wrote that accomplishes the rename and file compression...

 

            const string filePrefix = "19512-";

            string[] fileArray = Directory.GetFiles(@"c:\temp");

 

            foreach (var pdffile in fileArray) {

                string[] filePath = pdffile.Split('\\');

                var newFile = filePath[0] + '\\' + filePath[1] + '\\' + filePrefix + filePath[2];               

                var reader = new PdfReader(pdffile);

                var stamper = new PdfStamper(reader, new FileStream(newFile, FileMode.Create), PdfWriter.VERSION_1_5);

 

                int pageNum = 1;

                for (int i = 1; i <= pageNum; i++) {

                    reader.SetPageContent(i, reader.GetPageContent(i), PdfStream.BEST_COMPRESSION);

                }

 

                stamper.Writer.CompressionLevel = PdfStream.BEST_COMPRESSION;

                stamper.FormFlattening = true;

                stamper.SetFullCompression();

                stamper.Close();

          }

 

Any assistance is appreciated.

add hidden data to pdf

$
0
0

HI

I need to save some data to pdf document but i want these data be hidden and with preview the document nothing show

but plugin can read these data

how can i insert data?

to where?

do i have any limitation to add data for example size or ...

I read 32000 but in sdk I don't know use which function or layer

 

thanks for your attention

Font encoding, PDEFontCreateFromSysFont, PDEFontCreateFromSysFontAndEncoding

$
0
0

Hi All,

   I want to change font of the text in a PDF. My develop the code On Mac os 10.9.

 

Here is my code:

Original:

1. PDSysFont sysFont = PDFindSysFont(&fontAttrs, attrsSize, kPDSysFontMatchFontType);   //the font name is 'helvetica', type is 'TrueType'

2. PDEFont pdeFont = PDEFontCreateFromSysFont(sysFont, kPDEFontCreateEmbedded);

3... then use the pdeFont to change the text's font Which exists in PDF.


Then I open the edited pdf file by Adobe Acrobat, It pop a warning message:

  "The font 'Helvetica' contains an invalid encoding.Some characters may not display."

 

So I changed my code in Step2:

Changed:

PDSysEncoding fontEncoding = PDSysEncodingCreateFromBaseName(fontAttrs.encoding, NULL);

PDEFont pdeFont = PDEFontCreateFromSysFontAndEncoding(sysFont, fontEncoding, fontAttrs.name, kPDEFontCreateEmbedded);


The problem looks like be resolved.

But It confused me. I don't know the change is right or not? Dose someone who can explain the difference of the two method to men. Thanks.


NOTE

I use Adobe Acrobat to open open the 'correct' and 'incorrect' file:

[File]->[Properties...]->[Fonts]

incorrect file:

  Helvetica(Embedded)

          Type:TrueType

          Encoding:Custom


correct file:

   Helvetica(Embedded)

         Type:TrueType

        Encoding:Roman



I use a tool to open the 'correct' and 'incorrect' file to see the detail information of the font. I find the encoding in file is

incorrect file:

encoding:

               Type: encoding

                baseEncoding:MacRomanEncoding

                Differences:[219 Euro]


correct file:

encoding: MacRomanEncoding;



System.InvalidCastException: Unable to cast COM object of type 'Acrobat.AcroAppClass' to interface type 'Acrobat.CAcroApp'

$
0
0

Hi,

 

We are using acrobat in our project to procees PDF files.

 

In one of our client machine, we are getting bellow exception while creating 'Acrobat.AcroAppClass' object.

 

"System.InvalidCastException: Unable to cast COM object of type 'Acrobat.AcroAppClass' to interface type 'Acrobat.CAcroApp'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{9B4CD3E6-4981-101B-9CA8-9240CE2738AE}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))."

 

Code we used:

--------------------

CAcroApp objApp = new AcroAppClass();

.......

objApp.Exit();

 

AcroAPPClass is derived from CAroApp interface, so type casting is correct only, but we are getting issues.

 

This issue is happening in particular machine only.

 

Acrobat version in client machine:

Acrobat.png

 

Please help us to solve the issue.

rundistributeformwizard

$
0
0

how use this rundistributeformwizard(string)

 

please help me.

 

my gol is convert pdf to pdf forms from code csharp or javascript.

 

thank

Viewing all 2571 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>