Resume text from new page

Discuss PDF file handling with the Polybios plugin here
Post Reply
sashapont
Posts: 152
Joined: Thu Aug 03, 2017 2:49 pm

Resume text from new page

Post by sashapont »

I have arrays of strings
For Local W = 1 TO 10000

page:ShowText(array1$[W-1]..";"..array2$[W-1]..";"..array3$[W-1]..";"..array4$[W-1]..";"..array5$[W-1]..";"..array6$[W-1]..";"..array7$[W-1]..";"..array8$[W-1]..";"..array9$[W-1]..";"..array10$[W-1])
page:MoveTextPos(0, -27)
pw = Max(pw, page:TextWidth(array1$[W-1]))

Next
How I can resume text on next page after this page is ended?
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Resume text from new page

Post by airsoftsoftwair »

Add a new page to the document and use the new page's handle?
sashapont
Posts: 152
Joined: Thu Aug 03, 2017 2:49 pm

Re: Resume text from new page

Post by sashapont »

I try but it is not work& text always on first page
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Resume text from new page

Post by airsoftsoftwair »

Well, post your complete code then...
sashapont
Posts: 152
Joined: Thu Aug 03, 2017 2:49 pm

Re: Resume text from new page

Post by sashapont »

Code: Select all

 Function p_print()
  
  if (exportformat=1)

; create new document
doc = pdf.CreateDocument()

; declaration for using Japanese encoding
doc:UseUTFEncodings()

; enable compression
doc:SetCompressionMode(#HPDF_COMP_ALL)

; load ttf file
detail_font_name = doc:LoadTTFont("DejaVuSans.ttf", True)

; add a new page object
page = doc:AddPage()

title_font = doc:GetFont("Helvetica")
detail_font = doc:GetFont(detail_font_name, "UTF-8")

page:SetFontAndSize(title_font, 10)

page:BeginText()

; move the position of the text to top of the page
page:MoveTextPos(50, 770)

page:SetFontAndSize(detail_font, 16)
pw = 0

page:SetSize(#HPDF_PAGE_SIZE_A4, #HPDF_PAGE_PORTRAIT)

; finish to print text
page:EndText()

kolvosranic=Round(countb/27)
For Local q = 1 TO kolvosranic
page = doc:AddPage()

Next

page:BeginText()
page:MoveTextPos(50, 770)

page:SetFontAndSize(detail_font, 16)
pw = 0

For Local W = 1 TO countb

	page:ShowText(array1$[W-1]..";"..array2$[W-1]..";"..array3$[W-1]..";"..array4$[W-1]..";"..array5$[W-1]..";"..array6$[W-1]..";"..array7$[W-1]..";"..array8$[W-1]..";"..array9$[W-1]..";"..array10$[W-1])
	page:MoveTextPos(0, -27)
	pw = Max(pw, page:TextWidth(array1$[W-1]))	
	
Next

page:EndText()

page:SetLineWidth(0.5)

; save the document to a file
p_SaveAndView(doc, "TTFontUnicode.pdf")

; clean up
doc:Free()

EndIf  
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Resume text from new page

Post by airsoftsoftwair »

Well, you always use the same page object in your loop so the text obviously is always put to the same page.
sashapont
Posts: 152
Joined: Thu Aug 03, 2017 2:49 pm

Re: Resume text from new page

Post by sashapont »

Ок I try to understand examples and now I write this

Code: Select all

Function p_DrawText(page)
kolvosranic=Round(countb/27)
    	For Local i = 0 To kolvosranic
    		 		
            		page:BeginText()
            		page:MoveTextPos(x + 5, 850 - 75)
For Local W = 0 TO countb-1
        page:ShowText(array1$[W])
	page:MoveTextPos(0, -27)	
Next
			page:EndText()
        Next
        EndFunction

  
  Function p_print()
  
  if (exportformat=1)

; create new document
doc = pdf.CreateDocument()

; declaration for using Japanese encoding
doc:UseUTFEncodings()

; enable compression
doc:SetCompressionMode(#HPDF_COMP_ALL)

; load ttf file
detail_font_name = doc:LoadTTFont("DejaVuSans.ttf", True)

kolvosranic=Round(countb/27)
For Local i = 0 To kolvosranic
	
        Local page = doc:AddPage()
	Local font2
	
page:SetSize(#HPDF_PAGE_SIZE_A4, #HPDF_PAGE_PORTRAIT)

     ;   Local outline = doc:CreateOutline(root, encodings[i], Nil)
        Local dst = page:CreateDestination()
        dst:SetXYZ(0, page:GetHeight(), 1)
      detail_font = doc:GetFont(detail_font_name, "UTF-8")

page:SetFontAndSize(detail_font, 14)


    ;    page:SetFontAndSize(font, 15)
        p_DrawText(page)

        page:BeginText()
        page:SetFontAndSize(detail_font, 20)
        page:MoveTextPos(50, 770)
        page:ShowText(array2$[i])
        page:EndText()

/*	If encodings[i] = "Symbol-Set"
        	font2 = doc:GetFont("Symbol")
        ElseIf encodings[i] = "ZapfDingbats-Set"
            	font2 = doc:GetFont("ZapfDingbats")
        Else
            	font2 = doc:GetFont(font_name, encodings[i])
	EndIf
	
        page:SetFontAndSize(font2, 14)
        p_DrawFonts(page)*/
Next

; save the document to a file
p_SaveAndView(doc, "TTFontUnicode.pdf")

; clean up
doc:Free()

EndIf  
Now I have this text on all pages from first W
How I can change line page:ShowText(array1$[W]) for making text on page 2 from 27 on page 3 from 55 etc
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Resume text from new page

Post by airsoftsoftwair »

Sorry, I'm not familiar with the libharu API used by Polybios either. I'm afraid you have to do some trial and error to see how it works.
Post Reply