bonjour,
je souhaite afficher un fichier PS dans ma forme, Est ce que c'est possible?
j'ai pensé aux activeX d'adobe mais j'ai eu un message d'erreur en les installant.
merci d'avance.
bonjour,
je souhaite afficher un fichier PS dans ma forme, Est ce que c'est possible?
j'ai pensé aux activeX d'adobe mais j'ai eu un message d'erreur en les installant.
merci d'avance.
Salut dz_robotix
A la suite d'une discution sur ce Post
Voici un bout de code que j'avais teste sans aller plus loin, ici on utilise Acrobat
et deux liens interressants
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" #include <utilcls.h> //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; Variant vAcrobatApp, vAcrobatPDDoc, PDDocument; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { // executer l'application vAcrobatApp = CreateOleObject("AcroExch.App"); // executer le document // vAcrobatPDDoc = CreateOleObject("AcroExch.PDDoc"); vAcrobatPDDoc = CreateOleObject("AcroExch.AVDoc"); // ouvrir acrobat vide vAcrobatApp.OleFunction("Show"); // deux facon d'ouvrir un fichier vAcrobatPDDoc.OleFunction("Open", "C:\\essaipdf.pdf", true); // vAcrobatPDDoc.OleFunction("OpenAVDoc", "C:\\essaipdf.pdf"); // rendre acrobat invisible // vAcrobatApp.OleFunction("Hide"); // PDDocument = vAcrobatPDDoc.OleFunction("GetActiveDoc"); // GetPDDoc // int NumPages = (vAcrobatPDDoc.OleFunction("GetNumPages") - 1); long retVal = vAcrobatPDDoc.OleFunction("PrintPagesSilent", 0, // First page -1, // Last page (-1 is all pages) 1, // Postscript level 0, // Binary ok 1 // Shrink to fit ); // if (retVal != 0) // AfxMessageBox(_T("The Print was a success")); // iNumPages = PDDoc.GetNumPages //AVDoc.printPagesSilent 0, iNumPages - 1, 2, True, true } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { vAcrobatPDDoc.OleFunction("Close"); vAcrobatApp.OleFunction("CloseAllDocs"); vAcrobatApp.OleFunction("Exit"); vAcrobatPDDoc = Unassigned; vAcrobatApp = Unassigned; } //---------------------------------------------------------------------------
Un bout de code Delphie trouve sur le site que j'ai converti, le texte est insere dans un TMemo
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" #include <utilcls.h> //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; Variant vAcrobatApp, vAcrobatPDDoc; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { // executer l'application vAcrobatApp = CreateOleObject("AcroExch.App"); // executer le document // vAcrobatPDDoc = CreateOleObject("AcroExch.PDDoc"); vAcrobatPDDoc = CreateOleObject("AcroExch.AVDoc"); // ouvrir acrobat vide vAcrobatApp.OleFunction("Show"); // deux facon d'ouvrir un fichier vAcrobatPDDoc.OleFunction("Open", "D:\\ADO_DOC\\09.pdf", true); // C:\\essaipdf.pdf", true); // vAcrobatPDDoc.OleFunction("OpenAVDoc", "C:\\essaipdf.pdf"); // rendre acrobat invisible // vAcrobatApp.OleFunction("Hide"); if(vAcrobatPDDoc.OleFunction("IsValid")) { vAcrobatApp.OleFunction("MenuItemExecute", "Edit"); //select all and copy to clipboard vAcrobatApp.OleFunction("MenuItemExecute", "SelectAll"); vAcrobatApp.OleFunction("MenuItemExecute", "Edit"); vAcrobatApp.OleFunction("MenuItemExecute", "Copy"); Memo1->PasteFromClipboard(); Memo1->Lines->SaveToFile("c:\\essai_pdf.doc"); } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { // vAcrobatPDDoc.OleFunction("Close"); vAcrobatApp.OleFunction("CloseAllDocs"); vAcrobatApp.OleFunction("Exit"); vAcrobatPDDoc = Unassigned; vAcrobatApp = Unassigned; } //---------------------------------------------------------------------------
L'emploie d'un TRichEdit donne un meilleur resultat sur le texte mais le graphique et les images sont ignorees
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 RichEdit1->PasteFromClipboard(); RichEdit1->Lines->SaveToFile("C:\\essai_pdf.doc");
Partager