Print Page | Close Window

How to re-index PDF pages ?

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=3299
Printed Date: 17 Jan 26 at 9:25PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: How to re-index PDF pages ?
Posted By: DrCizor
Subject: How to re-index PDF pages ?
Date Posted: 03 Apr 16 at 6:44AM
Hi everyone,

I have to re-index a large PDF file (3 to 4000 pages ) containing invoices.
I am constrained to sort it by postal code of the recipient, add text on the fly and add a separator page between cities !!!
I have already managed to extract and sort informations into a CSV file but now my problem is how to merge pages from the PDF source ?

Here is my code to append pages from the PDF source to the current but it doesn't work...Confused


var PdfOriginal = new ActiveXObject("DebenuPDFLibraryAX1211.PDFLibrary");
var myPDF = new ActiveXObject("DebenuPDFLibraryAX1211.PDFLibrary");
r1=PdfOriginal.UnlockKey("********") ;
r2=myPDF.UnlockKey("********") ;
var DocID = PdfOriginal.LoadFromFile("d:\\MySourceFile.pdf", "");

myPDF.SetOrigin(1);
myPDF.SetMeasurementUnits(1);
myPDF.SetPageDimensions(210,297) ;

// first separator page
myPDF.SetFillColor(1,0,0);
myPDF.DrawBox(115,56,80,35,2);
myPDF.SetFillColor(0,0,0);
myPDF.InsertPages(2,1);

// Loop
myPDF.CopyPageRanges(DocID,'1644');
myPDF.DrawText(10, 50, "0000114");

// next
myPDF.CopyPageRanges(DocID,'2845');
myPDF.DrawText(10, 50, "0000224");

//etc...

myPDF.SaveToFile("d:\Result.pdf");


thanks for the help



Replies:
Posted By: Ingo
Date Posted: 03 Apr 16 at 7:20PM
Hi,

myPDF will be the new - still empty - file?
There still aren't any pages but you want to insert a blank page after the second page?
CopyPageRanges needs a string with the page ranges. 
In your code snippet sometimes there are double quotes and sometimes there are single quotes round your strings. What's correct... single or double?
At LoadFromFile you have written d:\\ and at the end at SaveToFile there is a d:\ ... what's correct?


-------------
Cheers,
Ingo



Posted By: DrCizor
Date Posted: 03 Apr 16 at 8:52PM
Hi Ingo,

Thank you for the answer.
For the blank page, it is because I have to manage recto/verso.
In Javascript usage single or double quote are similar, but it will be the same character to round a string.
For the path to save ... I miss the the second "\" Ouch


I modify the code with a loop who gives static values for test and using a single object.
This code works, however, to copy 4000 pages it takes about 30 minutes and the output file is about 500Mo ... Angry

I think I did stupids things in my code and it is not optimized, how to improve it ?

var QP = new ActiveXObject("DebenuPDFLibraryAX1211.PDFLibrary");
r1=QP.UnlockKey("********") ;

QP.LoadFromFile("d:\\MySourceFile.pdf","");
var DocOriginal = QP.SelectedDocument();
 
QP.NewDocument();
var cpt=1;
QP.SetOrigin(1);
QP.SetMeasurementUnits(1);
QP.SetPageDimensions(210,297);


for(var i=0;i<2000;i++)
 {
  QP.CopyPageRanges(DocOriginal, "1-2");
  QP.SelectPage(cpt+1);
  cpt += 2;
  QP.SetTextSize(5); 
  QP.DrawText(180, 56, "T 208");      // writing on the recto
 }


QP.DeletePages(1,1);   // Delete first blank page
QP.SaveToFile("d:\\Result.pdf");


thanks in advance


Posted By: Ingo
Date Posted: 03 Apr 16 at 9:37PM
Hi,

try the search functionality here:
http://www.quickpdf.org/forum/search_results_posts.asp?SearchID=20160403213345&KW=CopyPageRanges
If SetTextSize is always the same you should call it only at the top one time?
Older posts are telling that CopyPageRanges copies always the fonts, too.
So size will increase...
Try the compress functionalities, too.



-------------
Cheers,
Ingo



Posted By: DrCizor
Date Posted: 05 Apr 16 at 1:27PM
Hi Ingo,

I don't have found anything relevant in your search link and in this part of forum.
I continue to seek a faster method to append pages and reduce this size...
Is there other methods to quickly copy pages from one document to an other ?
It seems after each CopyPageRanges the value of TextSize is loose, I have to set it before drawing the text.

thank you


Posted By: Ingo
Date Posted: 05 Apr 16 at 7:52PM
Hi,

here you can search for better solution, code snippets, samples:
http://www.quickpdf.org/



-------------
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