Problems with PDF Files so Big!
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=1696
Printed Date: 04 Apr 26 at 7:25PM Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com
Topic: Problems with PDF Files so Big!
Posted By: Tharos
Subject: Problems with PDF Files so Big!
Date Posted: 28 Dec 10 at 3:29PM
Hi everyone!
Im using the library for add text to a existing pdf file, using this code:
QuickPDFAX0723.PDFLibrary QP = new QuickPDFAX0723.PDFLibrary(); int result = QP.UnlockKey("mykey"); int descriptor = QP.LoadFromFile(fich); if (descriptor == 0) { MessageBox.Show("Error","error"); } int paginas=QP.PageCount(); for (int i = 1; i <= paginas; i++) { try {
QP.SelectPage(i); QP.NewLayer(); QP.AddTrueTypeFont("Arial", 1); QP.SetTextSize(60); QP.SetTransparency(50); QP.DrawRotatedText(155, 600, 315, "CONFIDENCIAL"); int OC1 = QP.NewOptionalContentGroup("Conf"); QP.SetLayerOptional(OC1);
QP.CompressContent(); QP.CompressImages(1); QP.CompressFonts(1); QP.CompressPage();
QP.NewLayer(); QP.AddTrueTypeFont("Arial", 1); QP.SetTextSize(20); QP.SetTransparency(50); QP.DrawText(100, 750, usuario + " " + System.DateTime.Now); int OC2 = QP.NewOptionalContentGroup("Nombre"); QP.SetLayerOptional(OC2);
QP.MoveLayer(descriptor, 1);
QP.CompressContent(); QP.CompressImages(1); QP.CompressFonts(1); QP.CompressPage();
QP.SetOptionalContentGroupVisible(OC1, 0); QP.SetOptionalContentGroupPrintable(OC1, 1); QP.SetOptionalContentGroupVisible(OC2, 0); QP.SetOptionalContentGroupPrintable(OC2, 1); }
Im trying to draw "Confidential" and the date and user of the document as a Watermark in all pages of pdf file. So, if my file size before this treatment is aprox 900 kb, after is aprox 24,5 MB!!!! I think this is impossible because drawrotatetext online writes text...
I Like to solve this problem, if there are solution, because the disk space is important to me about this pdf file because its not only one: aprox i have to apply this treatment to 500 pdf files.
thanksss everyone!!!
PD: My english is horrible because i´m from spain and i´m not speak much!!!
|
Replies:
Posted By: BEvans
Date Posted: 29 Dec 10 at 1:02AM
A quick look: A lot of the stuff in your per page loop is only needed once per PDF. Some time reading the documentation on what each function does would help a lot as well.
// Once per PDF before per page loop QP.CompressImages(1); QP.CompressFonts(1); QP.AddTrueTypeFont("Arial", 1);
// Once per PDF after after the per page loop completes // skip CompressPage as it just does the same only for a single page QP.CompressContent();
|
Posted By: Tharos
Date Posted: 29 Dec 10 at 7:42AM
perfect!!! it worksss!!! with other changes in the document but adding some more code!!!!
thanksssss a lot!
|
|