Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - How to re-index PDF pages ?
  FAQ FAQ  Forum Search   Register Register  Login Login

How to re-index PDF pages ?

 Post Reply Post Reply
Author
Message
DrCizor View Drop Down
Beginner
Beginner


Joined: 13 Apr 15
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote DrCizor Quote  Post ReplyReply Direct Link To This Post Topic: How to re-index PDF pages ?
    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


Edited by DrCizor - 03 Apr 16 at 2:36PM
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
DrCizor View Drop Down
Beginner
Beginner


Joined: 13 Apr 15
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote DrCizor Quote  Post ReplyReply Direct Link To This Post 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


Edited by DrCizor - 03 Apr 16 at 8:55PM
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
DrCizor View Drop Down
Beginner
Beginner


Joined: 13 Apr 15
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote DrCizor Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 05 Apr 16 at 7:52PM
Hi,

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

Cheers,
Ingo

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store