Print Page | Close Window

Simple Imposition

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: General Discussion
Forum Description: Discussion board for Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3334
Printed Date: 26 Nov 24 at 1:56PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Simple Imposition
Posted By: WilliamFaulkner
Subject: Simple Imposition
Date Posted: 24 May 16 at 12:45AM
Greetings,

I simply have to take two distinct portrait Letter-sized Pdf files and impose them on a landscape Tabloid-sized blank Pdf.

The code currently only outputs the second page on the left side of the tabloid.

Here is my code...


Sub Impose_2up_Letter_On_Tabloid

    Dim ClassName
    Dim LicenseKey
    Dim PdfLib
    Dim Result
    
    
ClassName = "QuickPDFAX0725.PDFLibrary"
LicenseKey = "######censured##########" ' KEY
    Set PdfLib = CreateObject(ClassName)
Result = PdfLib.UnlockKey(LicenseKey)
    
    If Result = 1 Then
    
        intTabloidLandscapeTemplate =         PdfLib.LoadFromFile(Pdf_File_Tabloid_Landscape_Template)
        intTabloidLandscapeTemplate = PdfLib.SelectedDocument()
        
        intTabloidLandscapeTemplate = PdfLib.setorigin(1) ' Top left
        intTabloidLandscapeTemplate = PdfLib.setmeasurementunits(2) ' Inches
        intTabloidLandscapeTemplate = PdfLib.setpagesize("Tabloid Landscape")
        
        counter = 1
        
While counter <= (Pdf_File_Names_Dictionary.Count - 2)
        
        Pdf_File_Left = Pdf_File_Names_Dictionary.Item(CStr(counter))
        PdfLib.LoadFromFile(Pdf_File_Left)
        intLeftPage = PdfLib.SelectedDocument()
            'intLeftPage = PdfLib.CapturePage(1)
            
        counter = counter + 1
            
        Pdf_File_Right = Pdf_File_Names_Dictionary.Item(CStr(counter))
        PdfLib.LoadFromFile(Pdf_File_Right)
        intRightPage = PdfLib.SelectedDocument()
            'intRightPage = PdfLib.CapturePage(1)
            
        counter = counter + 1
            
        intTabloidLandscapeTemplate = PdfLib.setpagesize("Tabloid Landscape")
        intTabloidLandscapeTemplate = PdfLib.DrawCapturedPage(intLeftPage,X1,Y,8.5,11)
        intTabloidLandscapeTemplate = PdfLib.setpagesize("Tabloid Landscape")
        intTabloidLandscapeTemplate = PdfLib.DrawCapturedPage(intRightPage,X2,Y,8.5,11)
                    
            
        Pdf_File_Imposed = Prod_Pdf_Files_Output_folder & "\" & CStr((counter - 2)) & "-" & CStr((counter-1)) &".pdf"
            
        intTabloidLandscapeTemplate = PdfLib.SaveToFile(Pdf_File_Imposed)
        
        
        Wend
        
    End If

End Sub






Thank you for your time,



Replies:
Posted By: Ingo
Date Posted: 24 May 16 at 5:42PM
Hi William ;-)

i think the empty landscape pdf wasn't landscape while creation but rotated later?
I think internally it's a portrait format with a rotate 90.
That's your hurdle i fear.
The newer versions of the library offers a NormalizePage to avoid problems like these ones.
But there's no need to use an existing, empty landscape pdf for this job.
You can do this from scratch on the fly.
In the developer guide and in the knowledge base you'll find enough samples for jobs like the described one.

Cheers and welcome here,
Ingo



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



Posted By: WilliamFaulkner
Date Posted: 24 May 16 at 7:01PM
hi Ingo,

Thanks for the help, its good to see.
I created it landscape in inDesign however working without it, as you mentioned, does seem simpler.

Could I bother you a bit more and ask you more details?

Thank you,


Posted By: Ingo
Date Posted: 24 May 16 at 7:40PM
Hi,

here i've found three posts/threads with the search-function
giving you an idea how this can be done:
http://www.debenu.com/kb/programmatically-impose-multiple-pages-on-one-page-imposition/
http://www.quickpdf.org/forum/what-does-drawcapturedpage-do_topic594.html
http://www.debenu.com/kb/merge-content-from-multiple-pages-into-one-page/
 


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



Posted By: WilliamFaulkner
Date Posted: 25 May 16 at 12:06AM
Hi Ingo,

Reading the links and developer pdf did help...
Not knowing how Pdf is implemented made me have wrong assumptions.
Thank you for reminding me to RTM, really, I should have started there.

I've merged my two letter sized documents prior to using CapturePage.
However, my output is a blank tabloid landscape.

While counter <= (Pdf_File_Names_Dictionary.Count - 2

   Pdf_File_Left = Pdf_File_Names_Dictionary.Item(CStr(counter))
   PdfLib.LoadFromFile(Pdf_File_Left)
   leftPage = PdfLib.SelectedDocument()
            
   Pdf_File_Right = Pdf_File_Names_Dictionary.Item(CStr(counter + 1))
   PdfLib.LoadFromFile(Pdf_File_Right)
   rightPage = PdfLib.SelectedDocument()
            
   PdfLib.SelectDocument(leftPage)
   PdfLib.MergeDocument(rightPage)
            
   PdfLib.NewPage()
   PdfLib.setpagesize("Tabloid Landscape")
            
   leftPage = PdfLib.CapturePage(1)
   rightPage = PdfLib.CapturePage(1)

   tabloid = PdfLib.DrawCapturedPage(leftPage,X1,Y,8.5,11) 'X1 = 0 = Y
   tabloid = PdfLib.DrawCapturedPage(rightPage,X2,Y,8.5,11) 'X2 = 8.5

   Pdf_File_Imposed = Prod_Pdf_Files_Output_folder & "\test.pdf"
   PdfLib.SaveToFile(Pdf_File_Imposed)
           
   counter = counter + 1
Wend

Any hints is appreciated!

ps: I am not a professional programmer, but am learning, thanks for your patience.









Posted By: WilliamFaulkner
Date Posted: 25 May 16 at 12:50AM
SUCCESS! :) 
I had forgotten to set measurement and origins!


Posted By: Shaare
Date Posted: 25 May 16 at 2:14AM
Here's the code for this:

Pdf_File_Left_Path = Pdf_File_Names_Dictionary.Item(CStr(counter))
PdfLib.LoadFromFile(Pdf_File_Left_Path)
Pdf_File_Left_Selected_Document_Pointer = PdfLib.SelectedDocument()
counter = counter + 1

Pdf_File_Right_Path = Pdf_File_Names_Dictionary.Item(CStr(counter))
PdfLib.LoadFromFile(Pdf_File_Right_Path)
Pdf_File_Right_Selected_Document_Pointer = PdfLib.SelectedDocument()
counter = counter + 1
PdfLib.SelectDocument(Pdf_File_Left_Selected_Document_Pointer)
PdfLib.MergeDocument(Pdf_File_Right_Selected_Document_Pointer)

PdfLib.NewPage()
PdfLib.setpagesize("Tabloid Landscape")

Pdf_File_Left_Captured_Page_Pointer = PdfLib.CapturePage(1)
Pdf_File_Right_Captured_Page_Pointer = PdfLib.CapturePage(1)

PdfLib.setorigin(1) 'Top left
PdfLib.setmeasurementunits(2) 'Inches
            
Result = PdfLib.DrawCapturedPage(Pdf_File_Left_Captured_Page_Pointer,X1,Y,8.5,11)      
Result = PdfLib.DrawCapturedPage(Pdf_File_Right_Captured_Page_Pointer,X2,Y,8.5,11)

Pdf_File_Name_Tabloid_Imposition = Prod_Pdf_Files_Output_folder & "\" & CStr((counter - 2)) & "-" & CStr((counter-1)) &".pdf"
PdfLib.SaveToFile(Pdf_File_Name_Tabloid_Imposition)



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