Print Page | Close Window

iTextSharp can Merge encrypted Pdf files

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2022
Printed Date: 05 May 25 at 8:28AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: iTextSharp can Merge encrypted Pdf files
Posted By: mjohn
Subject: iTextSharp can Merge encrypted Pdf files
Date Posted: 31 Oct 11 at 9:39PM
Hi.
Use iTextSharp for .net can Merge encrypted Pdf files,
but use QuickPDF can't Merge encrypted Pdf files?

Thanks!







Replies:
Posted By: Ingo
Date Posted: 01 Nov 11 at 8:01AM
Hi John!
 
Many pdf-files are encrypted - so QuickPDF can do this job, too.
I don't know if it's a problem merging encrypted pdf-files but:
QuickPDF can load a pdf...
then you can check if it's encrypted...
if so you can decrypt it with an easy function call ;-)
 
Cheers and welcome here,
Ingo 


Posted By: mjohn
Date Posted: 01 Nov 11 at 2:06PM
Hi.
Can you see
https://skydrive.live.com/?cid=4c90f2a935f13d29&sc=documents&uc=1&id=4C90F2A935F13D29%21112#
this is what i do use itextsharp.dll to merge 3 encrypted pdf files to a pdf file.
when you double click ConsoleApplication1.exe, then it will create a PDFS.pdf that is merge from the  3 encrypted pdf files.
but i can't do it use QuickPDF.
How can do it use QuickPDF with vb6?

Thanks!
when use c#, below is the whole code:
////////////////////Code Begin//////////////////////
sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            MergePdfDoc(System.AppDomain.CurrentDomain.BaseDirectory + "PDFS");
        }

        static private void MergePdfDoc(string sPath)
        {
            try
            {
                Document document = new Document(PageSize.A4, 50f, 50f, 50f, 50f);
                PdfReader reader = null;
                PdfCopy copy = new PdfCopy(document, new FileStream(sPath + ".pdf", FileMode.Append));

                document.Open();
                for (int i = 0; i <= Directory.GetFiles(sPath).Length; i++)
                {
                    if (System.IO.File.Exists(string.Concat(new object[] { sPath, @"\", i, ".pdf" })) )
                    {
                        reader = new PdfReader(string.Concat(new object[] { sPath, @"\", i, ".pdf" }));
                        document.NewPage();
                        PdfImportedPage importedPage = copy.GetImportedPage(reader,  1);
                        copy.AddPage(importedPage);
                    }
                }
                if ((document != null) && document.IsOpen())
                {
                    if (copy.PageNumber == 0)
                    {
                        document.NewPage();
                    }
                    document = null;
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    copy.Close();
                }
            }
            catch (Exception exception)
            {
            }
        }
    }
}

//////////////////Code End////////////////////////

whether i use ExtractFilePages or CapturePage or CopyPageRanges I can't merge the  3 encrypted pdf files to a pdf file as itextsharp.dll.

Can you help?
Thanks!
 


Posted By: Ingo
Date Posted: 01 Nov 11 at 2:24PM
Hi John!
 
What you have to do is ...
first the create ...
then LoadFromFile or similar ...
then check if the file is encrypted:
If ( QP.EncryptionStatus > 0 ) Then
   QP.Decrypt;
then the merge-syntax ...
then the save.
 
About encryption you can read here:
http://www.quickpdflibrary.com/help/quickpdf/DocumentProperties.php - http://www.quickpdflibrary.com/help/quickpdf/DocumentProperties.php

About merge you can read here:
http://www.quickpdflibrary.com/help/quickpdf/DocumentManipulation.php - http://www.quickpdflibrary.com/help/quickpdf/DocumentManipulation.php
 
Samples in different development languages (packed as zip) are here:
http://www.quickpdflibrary.com/samples/index.php - http://www.quickpdflibrary.com/samples/index.php
 
In the developer-guide starting at page 28 you'll find a good merge-sample:
http://www.quickpdflibrary.com/docs/Quick%20PDF%20Library%207%20Developer%20Guide.pdf - http://www.quickpdflibrary.com/docs/Quick%20PDF%20Library%207%20Developer%20Guide.pdf
It's a pascal-sample but for a developer it shouldn't be a problem to convert it to any other language.
 
Cheers, Ingo


Posted By: mjohn
Date Posted: 01 Nov 11 at 2:34PM
Hi. 
Thank you for your reply!
But I can't use QP.Decrypt, because I has no password.
If I have password, I know I can!
But I has no password.
So I want merge 3 encrypted pdf files to 1 pdf file when I has no password!

Above c# code, I has no password, I didn't need Decrypt the 3 pdf files, but I can merge them in 1 pdf file too.

So when I know when I has no password, I use QuickPDF, how can I merge encrypted pdf files to 1 pdf file as I did in itextsharp.

Thanks@




Posted By: mjohn
Date Posted: 01 Nov 11 at 2:49PM
Sorry!
I am wrong!
you are right!
 I can do it follow your instruction now!
Thanks very much!


Posted By: Ingo
Date Posted: 01 Nov 11 at 6:28PM
Hi John!

Seems that your password is only the main (and not the user password) password.
This doesn't have any effects - if you load such a document it's unprotected temporary and you can do the merge.

Cheers, Ingo



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk