Print Page | Close Window

Combine 4 pages to 1 page - error

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=3519
Printed Date: 26 Apr 24 at 7:52PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Combine 4 pages to 1 page - error
Posted By: mLipok
Subject: Combine 4 pages to 1 page - error
Date Posted: 28 Oct 17 at 2:04AM
I'm working on function which should Combine 4 pages to 1 page.

I was working on few pdf documents and but I get error when I use:
"Foxit Quick PDF Library 14 Upgrade Warnings.pdf" as my test file to processing.

Here is my result file:
http://lipok.pl/Debenu/Foxit Quick PDF Library 14 Upgrade Warnings.pdf__Splitted_2.pdf

Try to open this in Acrobat Reader .
Did you get Error ?
What this mean ? What I'm doing wrong ?



-------------
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600



Replies:
Posted By: Ingo
Date Posted: 28 Oct 17 at 10:06AM
Directly open in Firefox browser with pdf-plugin - no problem
Open with SumatraPDF - no problem
Open with Foxit - no problem
Open with Acrobat Reader DC:
"The page structure data contains an invalid node".
From my opinion there's an unused node or the same node twice inside the structure.
It should have to do with not starting from scratch and that you're copying too much together.
There will be same things on the four pages...




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



Posted By: mLipok
Date Posted: 28 Oct 17 at 1:53PM
Thanks for your answer.

Soon I share my code.
I hope, you will be able to send to me any tips, saying what I can code better.



-------------
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600


Posted By: mLipok
Date Posted: 28 Oct 17 at 3:01PM
Is it possible that the source pdf have Bookmarks/Links ?



-------------
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600


Posted By: Nick
Date Posted: 26 Feb 18 at 8:57AM

Hi mLipok!

If you mean the message "The page structure data contains an invalid node", then I use the QP.SetOpenActionDestination (1, -1) function to remove this message before saving the file.
Try it.

Nick.



Posted By: mLipok
Date Posted: 26 Feb 18 at 9:17AM
Do you do this trick for every saving ?

-------------
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600


Posted By: Nick
Date Posted: 26 Feb 18 at 1:20PM
Of necessity. You can use QP.RemoveOpenAction function. Same result.


Posted By: mLipok
Date Posted: 28 Feb 18 at 2:34PM
Finally tested.
It works like a charm.

Thanks again


-------------
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600


Posted By: mLipok
Date Posted: 28 Feb 18 at 2:39PM
; #FUNCTION# ====================================================================================================================
; Name ..........: _QPDF_Page_2in1
; Description ...: TODO
; Syntax ........: _QPDF_Page_2in1(Byref $oQP[, $bAddSplitter = False[, $bReverseUpDown = False[, $bTurnRight = True]]])
; Parameters ....: $oQP                 - [in/out] Reference to a QuickPDF object.
;                  $bAddSplitter        - [optional] A boolean value. Default is False.
;                  $bReverseUpDown      - [optional] A boolean value. Default is False.
;                  $bTurnRight          - [optional] a boolean value. Default is True.
; Return values .: TODO
; Author ........: mLipok
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _QPDF_Page_2in1(ByRef $oQP, $bAddSplitter = False, $bReverseUpDown = False, $bTurnRight = True)
__QPDF_IsUnlocked($oQP)
If @error Then Return SetError(@error, @extended, $QPDF_RET_FAILURE)

;~ _QPDF_Display() - only for testing - This is my own function
;~ _QPDF_Display($oQP, 'Loaded document 1 - Page 1', -1, 0, 600, 1)
;~ _QPDF_Display($oQP, 'Loaded document 1 - Page 2', -1, 0, 600, 2)

Local $iOrginalPageCount = $oQP.PageCount()

Local $iNewPageCounter = 0
Local $bNewPageHaveDrawedTopOfPage = False ; 1 = true ,  0 = false

Local $iID_CapturedPage

If Not $iOrginalPageCount > 1 Then Return SetError($QPDF_ERR_GENERAL, $QPDF_EXT_DEFAULT, 0)

For $iCurrentPage = 1 To $iOrginalPageCount
; MsgBox() - only for testing
; MsgBox(0, '$iCurrentPage', $iCurrentPage & ' / ' & $iOrginalPageCount)
If Not $bNewPageHaveDrawedTopOfPage Then
$oQP.NewPage()
$oQP.NormalizePage(0)
$iNewPageCounter += 1
$oQP.MovePage($iNewPageCounter)
$oQP.SetPageSize('A4')
$oQP.SetMeasurementUnits($__eQPDF_MUNITS_Milimeters)
If $bAddSplitter Then
$oQP.SetLineWidth(1)
$oQP.SetLineColor(1, 0, 0)
; @TODO _QPDF_SetDefaultCoordinates($oQP)
$oQP.DrawLine(0, $__eQPDF_A4_HeightInMM / 2, $__eQPDF_A4_WidthInMM, $__eQPDF_A4_HeightInMM / 2)
; MsgBox() - only for testing
; MsgBox(0, '$oQP.GetOrigin', $oQP.GetOrigin())

EndIf
EndIf

;~ _QPDF_Display() - only for testing - This is my own function
;~ _QPDF_Display($oQP, 'Page: $iCurrentPage + $iNewPageCounter: ' & $iCurrentPage & '/' & $iNewPageCounter & '/' & $iNewPageCounter + 1, $iNewPageCounter + 1)

$iID_CapturedPage = $oQP.CapturePage($iNewPageCounter + 1)

; select Page to which you want Insert content - Draw Captutred Page
$oQP.SelectPage($iNewPageCounter)
$oQP.NormalizePage(0)

#CS
Foxit Quick PDF Library 13.12 Reference Guide.pdf

Function DebenuPDFLibrary1312.PDFLibrary::DrawRotatedCapturedPage(
CaptureID As Long, Left As Double, Bottom As Double,
Width As Double, Height As Double, Angle As Double) As Long

Note that the anchor point is the bottom-left corner
#CE
ConsoleWrite("! " & $bNewPageHaveDrawedTopOfPage & "  " & $bReverseUpDown & @CRLF)
If $bTurnRight Then
If _
($bNewPageHaveDrawedTopOfPage = False And $bReverseUpDown = False) _
Or _
($bNewPageHaveDrawedTopOfPage = True And $bReverseUpDown = True) _
Then
; draw on top of page
$oQP.DrawRotatedCapturedPage( _
$iID_CapturedPage, 0, $__eQPDF_A4_HeightInMM, _
$__eQPDF_A4_HeightInMM / 2, $__eQPDF_A4_WidthInMM, 270 _
)
$bNewPageHaveDrawedTopOfPage = (Not $bReverseUpDown)
Else
; draw on bootom of page
$oQP.DrawRotatedCapturedPage( _
$iID_CapturedPage, 0, $__eQPDF_A4_HeightInMM / 2, _
$__eQPDF_A4_HeightInMM / 2, $__eQPDF_A4_WidthInMM, 270 _
)
$bNewPageHaveDrawedTopOfPage = ($bReverseUpDown)
EndIf
Else
If _
($bNewPageHaveDrawedTopOfPage = False And $bReverseUpDown = False) _
Or _
($bNewPageHaveDrawedTopOfPage = True And $bReverseUpDown = True) _
Then
; draw on top of page
$oQP.DrawRotatedCapturedPage( _
$iID_CapturedPage, $__eQPDF_A4_WidthInMM, $__eQPDF_A4_HeightInMM / 2, _
$__eQPDF_A4_HeightInMM / 2, $__eQPDF_A4_WidthInMM, 90 _
)
$bNewPageHaveDrawedTopOfPage = (Not $bReverseUpDown)
Else
; draw on bootom of page
$oQP.DrawRotatedCapturedPage( _
$iID_CapturedPage, $__eQPDF_A4_WidthInMM, 0, _
$__eQPDF_A4_HeightInMM / 2, $__eQPDF_A4_WidthInMM, 90 _
)
$bNewPageHaveDrawedTopOfPage = ($bReverseUpDown)
EndIf
EndIf
Next
;~ _QPDF_Display($oQP, 'After Change', -1, 0, 600, 1)
EndFunc   ;==>_QPDF_Page_2in1

How to use:

_QPDF_Page_2in1($oQP, True, False, True)
_QPDF_Page_2in1($oQP, True, False, False)
_QPDF_SaveToFile($oQP, $sPDF_FileFullPath & '__Splitted.pdf')



-------------
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600



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