Print Page | Close Window

lexicographic sorting issue

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=3068
Printed Date: 01 May 24 at 9:54AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: lexicographic sorting issue
Posted By: puneethcm
Subject: lexicographic sorting issue
Date Posted: 08 Feb 15 at 3:49PM
hi i have a question regarding quick pdf conversion. In my application we covert two or more pdf files (which each pdf page is alphanumeric) am trying to  convert all this pdf files into one pdf file but the order of the pages is sorting in lexicographic order(like  1,10, 11,12,13.....2,20,21,.....and so on).may i know the solution for this issue. the application converts each pdf page to .emf file and from .emf to final pdf file(which is combination of all pdf pages of pdf files) .....

May i know why the the issue is arising and solution for the problem...

Thanks in advance....Smile





Replies:
Posted By: AndrewC
Date Posted: 09 Feb 15 at 9:34AM
Hello,

This sounds more like a coding problem than a Debenu Quick PDF Libary file.  Files in an operating system are sorted on an ASCII sort.  If you want page numbers sorted numerically then you will need to load the filenames into a custom sort algorithm that sorts the files numerically.

If you post some code as to how you load each file then we may be able to help you.

Andrew.


Posted By: puneethcm
Date Posted: 10 Feb 15 at 3:29AM
Thanks andrew for the reply...

We use VB for scripting...
Set qp = reportobject("QPDF.QuickPDF")
Qp.renderdocumenttofile picture quality,   1, inumpage, 3 , docpath + "\" + zero + picturequality.emf

Here QP.renderdocumenttofile converts the PDF pages to .emf and .emf to final single PDF file which has sorting issues....

Inumpages is total number of PDF files
Docpath is temporary folder where the .emf images are created.

Zero is a variable where zeros are appended to solve some issue.
The file name of images are pucturequality1, picturequality so on.... can't we access these image file individually?? I tried but dint find the solution...


Posted By: erico
Date Posted: 10 Feb 15 at 3:35PM
Format you page numbers with leading zeros, as in

01, 02, 03 . . . 10, 11, . . . 20

Use as many leading zeroes as necessary. (001 . . . 999) (0001 . . . 9999) etc.


-------------
Eric O


Posted By: puneethcm
Date Posted: 10 Feb 15 at 3:54PM
The thing is it generates .emf file name as picturequality1, picturrqualit2, .....picturequality10.....we can't access the .emf file and modify the name...



Posted By: erico
Date Posted: 10 Feb 15 at 4:03PM
'it' generates emf file names --  what is 'it'? Perhaps you can take the files from 'it' and rename them before feeding them to Debenu.

Or if 'it' is an application under your control, you can modify the behavior to name the files differently


-------------
Eric O


Posted By: puneethcm
Date Posted: 25 Feb 15 at 3:24AM
Application is not under our control and we can't access these .emf files and rename it..emf file is image of PDF pages...


Posted By: tfrost
Date Posted: 26 Feb 15 at 12:48PM
Why are you using temporary EMF files at all?  If the objective is, as you say, to merge multiple PDF documents into a single PDF, go to the scripts section in the Library Dashboard, then Document Manipulation, then Merge a List of PDFs, and look at the example there.  This will add the documents to the merged file in the order that you specify them.

Having said that, it seems that RenderDocumenttofile has a design flaw.  It knows in advance how many pages will be output, so it should really provide at least an option to use a variant of %p to add the correct number of leading zeros to the filenames.


Posted By: AndrewC
Date Posted: 06 May 15 at 10:23AM
puneethcm,

Instead of using RenderDocumentToFile you will need to use add your own loop and call RenderPageToFile instead.  This will allow you to control the filename for each page and to add leading zeros.

' -------------------------------------------------------------------------------------------------------------------------

Set qp = reportobject("QPDF.QuickPDF")

QP.LoadFromFile("input.pdf", "");
lNumPages = QP.PageCount();

for page = 1 tp lNumpages
begin

  ' Here you need to create a unique filename for each page with leading zero's.

  filename = docpath + "\" + picturequality + String.Format("{0:0000}", page)   '  Visual Basic - Google Search for 'VBScript leading zeros' if you need VBScript

  QP.RenderPageToFile(dpi, page, 3, filename);

end;
QP.RemoveDocument(QP.SelectedDocument())

' --------------------------------------------------------------------------------------------------------------------------

Andrew



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