Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Impresión (https://www.clubdelphi.com/foros/forumdisplay.php?f=4)
-   -   Poner contraseña a un pdf (https://www.clubdelphi.com/foros/showthread.php?t=85877)

Angel.Matilla 19-05-2014 17:42:52

Poner contraseña a un pdf
 
Con este código:
Código:

TQRPDFDocumentFilter *filtro = new TQRPDFDocumentFilter(cInforme);
filtro->AddFontMap("Arial:Helvetica");
filtro->StartConcat();
Informe->ExportToFilter(filtro);
filtro->EndConcat();
delete filtro;

genero un pdf a partir de un QR. Quiero ir un paso más allá: ¿Puedo establecer mediate código un contraseña a la hora de abrir el documento así creado?

Angel.Matilla 19-05-2014 18:02:42

Evidentemente aunque pido ayuda sigo buscando. San google me ha dado una dirección interesante: iText Sharp. En uno de los enlaces de este sitio viene este código:
Código:

1:  using System;
2:  using System.IO;
3:     
4:  using iTextSharp.text;
5:  using iTextSharp.text.pdf;
6:     
7:     
8:  namespace iTextSharp.tutorial.Chap01
9:  {
10:      /// <summary>
11:      /// Encryption
12:      /// </summary>
13:      public class Chap0110
14:      {
15:            public Chap0110()
16:            {
17:                Console.WriteLine("Chapter 1 example 10: encryption 128 bits");
18:             
19:                Document document = new Document(PageSize.A4, 50, 50, 50, 50);
20:                try
21:                {
22:                      PdfWriter writer = PdfWriter.GetInstance(document, new      FileStream("Chap0110.pdf", FileMode.Create));
23:                      writer.SetEncryption(PdfWriter.STRENGTH128BITS, "userpass", "ownerpass", PdfWriter.AllowCopy | PdfWriter.AllowPrinting);
24:                      document.Open();
25:                      document.Add(new Paragraph("This document is Top Secret!"));
26:                      document.Close();
27:                }
28:                catch (Exception de)
29:                {
30:                      Console.Error.WriteLine(de.StackTrace);
31:                }
32:     
33:            }
34:      }
35:  }

No sé si sería fácil adaptarla a C++.

ecfisa 19-05-2014 20:29:28

Hola Angel.Matilla.

Sin saber C#, te diría que es muy sencillo adaptar ese código a C++.
El verdadero problema y que hace inútil la traducción, es que aparentemente no existe una versión de iText que trabaje en C++...

Saludos :)

Angel.Matilla 20-05-2014 09:37:38

Muchas gracias.

Angel.Matilla 20-05-2014 10:42:41

He seguido buscando y encontré un mensaje de un hilo en el que se cita un componente TDFCreator, pero está escrito para Delphi. ¿Alguien lo ha traducido a Borland C++ 5 ó 6 o puede ayudarme a trasladarlo a este último? Lo agradecería infinito.


La franja horaria es GMT +2. Ahora son las 00:15:09.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi