Func _QPDF_A4toA5()
Local $oQP
If _QPDF_CreateObjectAndUnlock($oQP) = 1 Then
#Region create a A4 test PDF
$oQP.SetPageSize('A4')
$oQP.SetOrigin($__QPDF_SORIGIN_TopLeft);
$oQP.SetMeasurementUnits($__QPDF_MUNITS_Milimeters)
$oQP.SetTextSize(10);
Local $iTableID = $oQP.CreateTable(2, 1);
$oQP.SetTableColumnWidth($iTableID, 1, 1, $__QPDF_A4_WidthInMM);
$oQP.SetTableRowHeight($iTableID, 1, 2, $__QPDF_A4_HeightInMM / 2);
$oQP.SetTableCellBorderColor($iTableID, 1, 1, 2, 1, 0, 1, 0, 2);
$oQP.SetTableCellBorderWidth($iTableID, 1, 1, 2, 1, $__QPDF_BORDERINDEX_All, 0.1);
$oQP.SetTableCellTextSize($iTableID, 1, 1, 2, 1, 100)
$oQP.SetTableCellAlignment($iTableID, 1, 1, 2, 1, $__QPDF_CELLALIGNMENT_MiddleCenter);
$oQP.SetTableCellContent($iTableID, 1, 1, 'TOP')
$oQP.SetTableCellContent($iTableID, 2, 1, 'BOTTOM')
$oQP.DrawTableRows($iTableID, 0, 0, $__QPDF_A4_HeightInMM, 1, 2)
$oQP.SaveToFile(@ScriptDir & '\A4_TEST.pdf');
#EndRegion create a A4 test PDF
#Region Create New PDF File with 2* new A5 Landscape Page
Local $iIDMainDocument = $oQP.SelectedDocument()
$oQP.NewDocument()
$oQP.CopyPageRanges($iIDMainDocument, '1') ; it is 2 page but will be first Page
$oQP.SetOrigin($__QPDF_SORIGIN_TopLeft);
$oQP.SetMeasurementUnits($__QPDF_MUNITS_Milimeters)
$oQP.CopyPageRanges($iIDMainDocument, '1') ; it is 3 page but will be second Page
$oQP.SetOrigin($__QPDF_SORIGIN_TopLeft);
$oQP.SetMeasurementUnits($__QPDF_MUNITS_Milimeters)
$oQP.DeletePages(1, 1); Remove the "NewDocument first" empty page.
$oQP.NewPage() ; Top ; it will be third Page
$oQP.SetPageSize('A5 Landscape');
$oQP.SetOrigin($__QPDF_SORIGIN_TopLeft);
$oQP.SetMeasurementUnits($__QPDF_MUNITS_Milimeters)
$oQP.NewPage() ; Top ; it will be fourth Page
$oQP.SetPageSize('A5 Landscape');
$oQP.SetOrigin($__QPDF_SORIGIN_TopLeft);
$oQP.SetMeasurementUnits($__QPDF_MUNITS_Milimeters)
$oQP.RemoveDocument($iIDMainDocument)
$oQP.SaveToFile(@ScriptDir & "\__test_1.pdf")
$oQP.SelectPage(1) ; yet, for a little while Page #1
$oQP.SetPageBox($__QPDF_BOXTYPE_CropBox, 0, 0, $__QPDF_A4_WidthInMM, $__QPDF_A4_HeightInMM / 2) ; Media Box - Set Region to Capture
Local $iIDCapture1 = $oQP.CapturePageEx($oQP.SelectedPage(), $__QPDF_BOXTYPE_CropBox - 1)
; Remember Once a page has been captured it is removed from the document.
$oQP.SelectPage(2) ; previously Page #3
$oQP.DrawCapturedPage($iIDCapture1, 0, 0, $__QPDF_A4_WidthInMM, $__QPDF_A4_HeightInMM / 2) ; draw CaptuedPage to SelectedPage
$oQP.SaveToFile(@ScriptDir & "\__test_2.pdf");
$oQP.SelectPage(1) ; previously Page #2
$oQP.SetPageBox($__QPDF_BOXTYPE_CropBox, 0, $__QPDF_A4_HeightInMM / 2, $__QPDF_A4_WidthInMM, $__QPDF_A4_HeightInMM / 2) ; Media Box - Set Region to Capture
Local $iIDCapture2 = $oQP.CapturePageEx($oQP.SelectedPage(), $__QPDF_BOXTYPE_CropBox - 1)
; Remember Once a page has been captured it is removed from the document.
$oQP.SelectPage(2) ; previously Page #4
$oQP.DrawCapturedPage($iIDCapture2, 0, 0, $__QPDF_A4_WidthInMM, $__QPDF_A4_HeightInMM / 2) ; draw CaptuedPage to SelectedPage
$oQP.SaveToFile(@ScriptDir & "\__test_3.pdf")
$oQP.SaveToFile(@ScriptDir & "\A5Format_UpperAndBottom.pdf");
#EndRegion Create New PDF File with 2* new A5 Landscape Page
Sleep(100)
#Region Splitting
Local $sPDF_Destination = ''
$oQP.ExtractFilePages(@ScriptDir & "\A5Format_UpperAndBottom.pdf", '', @ScriptDir & '\A5Format_Upper.pdf', 1)
$oQP.ExtractFilePages(@ScriptDir & "\A5Format_UpperAndBottom.pdf", '', @ScriptDir & '\A5Format_Bottom.pdf', 2)
#EndRegion Splitting
EndIf
EndFunc ;==>_QPDF_A4toA5